diff options
author | Dundar Goc <gocdundar@gmail.com> | 2022-05-08 14:43:16 +0200 |
---|---|---|
committer | Dundar Goc <gocdundar@gmail.com> | 2022-05-11 23:19:57 +0200 |
commit | 85aae12a6dea48621ea2d24a946b3e7b86f9014d (patch) | |
tree | d9d45a2bdde3b462f58d98b88694bad0183c2b16 | |
parent | 5359be78935dc639c481d74f010fe133dd40290c (diff) | |
download | rneovim-85aae12a6dea48621ea2d24a946b3e7b86f9014d.tar.gz rneovim-85aae12a6dea48621ea2d24a946b3e7b86f9014d.tar.bz2 rneovim-85aae12a6dea48621ea2d24a946b3e7b86f9014d.zip |
refactor: replace char_u variables and functions with char
Work on https://github.com/neovim/neovim/issues/459
48 files changed, 672 insertions, 679 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index c5b576b106..51a0521231 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1521,11 +1521,10 @@ bool apply_autocmds(event_T event, char_u *fname, char_u *fname_io, bool force, /// @param exarg Ex command arguments /// /// @return true if some commands were executed. -bool apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf, +bool apply_autocmds_exarg(event_T event, char *fname, char *fname_io, bool force, buf_T *buf, exarg_T *eap) { - return apply_autocmds_group(event, (char *)fname, (char *)fname_io, force, AUGROUP_ALL, buf, - eap); + return apply_autocmds_group(event, fname, fname_io, force, AUGROUP_ALL, buf, eap); } /// Like apply_autocmds(), but handles the caller's retval. If the script @@ -1541,14 +1540,14 @@ bool apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, bool f /// @param[in,out] retval caller's retval /// /// @return true if some autocommands were executed -bool apply_autocmds_retval(event_T event, char_u *fname, char_u *fname_io, bool force, buf_T *buf, +bool apply_autocmds_retval(event_T event, char *fname, char *fname_io, bool force, buf_T *buf, int *retval) { if (should_abort(*retval)) { return false; } - bool did_cmd = apply_autocmds_group(event, (char *)fname, (char *)fname_io, force, + bool did_cmd = apply_autocmds_group(event, fname, fname_io, force, AUGROUP_ALL, buf, NULL); if (did_cmd && aborting()) { *retval = FAIL; @@ -1659,9 +1658,9 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force } // Save the autocmd_* variables and info about the current buffer. - char *save_autocmd_fname = (char *)autocmd_fname; + char *save_autocmd_fname = autocmd_fname; int save_autocmd_bufnr = autocmd_bufnr; - char *save_autocmd_match = (char *)autocmd_match; + char *save_autocmd_match = autocmd_match; int save_autocmd_busy = autocmd_busy; int save_autocmd_nested = autocmd_nested; bool save_changed = curbuf->b_changed; @@ -1675,18 +1674,18 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force || event == EVENT_OPTIONSET || event == EVENT_MODECHANGED) { autocmd_fname = NULL; } else if (fname != NULL && !ends_excmd(*fname)) { - autocmd_fname = (char_u *)fname; + autocmd_fname = fname; } else if (buf != NULL) { - autocmd_fname = buf->b_ffname; + autocmd_fname = (char *)buf->b_ffname; } else { autocmd_fname = NULL; } } else { - autocmd_fname = (char_u *)fname_io; + autocmd_fname = fname_io; } if (autocmd_fname != NULL) { // Allocate MAXPATHL for when eval_vars() resolves the fullpath. - autocmd_fname = vim_strnsave(autocmd_fname, MAXPATHL); + autocmd_fname = xstrnsave(autocmd_fname, MAXPATHL); } // Set the buffer number to be used for <abuf>. @@ -1754,11 +1753,11 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force #endif // Set the name to be used for <amatch>. - autocmd_match = (char_u *)fname; + autocmd_match = fname; // Don't redraw while doing autocommands. RedrawingDisabled++; - char *save_sourcing_name = (char *)sourcing_name; + char *save_sourcing_name = sourcing_name; sourcing_name = NULL; // don't free this one linenr_T save_sourcing_lnum = sourcing_lnum; sourcing_lnum = 0; // no line number here @@ -1793,7 +1792,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force did_filetype = true; } - char *tail = (char *)path_tail((char_u *)fname); + char *tail = path_tail(fname); // Find first autocommand that matches AutoPatCmd patcmd; @@ -1860,12 +1859,12 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force filechangeshell_busy = false; autocmd_nested = save_autocmd_nested; xfree(sourcing_name); - sourcing_name = (char_u *)save_sourcing_name; + sourcing_name = save_sourcing_name; sourcing_lnum = save_sourcing_lnum; xfree(autocmd_fname); - autocmd_fname = (char_u *)save_autocmd_fname; + autocmd_fname = save_autocmd_fname; autocmd_bufnr = save_autocmd_bufnr; - autocmd_match = (char_u *)save_autocmd_match; + autocmd_match = save_autocmd_match; current_sctx = save_current_sctx; restore_funccal(); if (do_profiling == PROF_YES) { @@ -1933,7 +1932,7 @@ void block_autocmds(void) { // Remember the value of v:termresponse. if (!is_autocmd_blocked()) { - old_termresponse = (char *)get_vim_var_str(VV_TERMRESPONSE); + old_termresponse = get_vim_var_str(VV_TERMRESPONSE); } autocmd_blocked++; } @@ -1946,7 +1945,7 @@ void unblock_autocmds(void) // the autocommands now. Esp. useful when executing a shell command // during startup (nvim -d). if (!is_autocmd_blocked() - && get_vim_var_str(VV_TERMRESPONSE) != (char_u *)old_termresponse) { + && get_vim_var_str(VV_TERMRESPONSE) != old_termresponse) { apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, false, curbuf); } } @@ -1979,9 +1978,9 @@ void auto_next_pat(AutoPatCmd *apc, int stop_at_last) if (ap->buflocal_nr == 0 ? match_file_pat(NULL, &ap->reg_prog, - (char_u *)apc->fname, - (char_u *)apc->sfname, - (char_u *)apc->tail, + apc->fname, + apc->sfname, + apc->tail, ap->allow_dirs) : ap->buflocal_nr == apc->arg_bufnr) { const char *const name = event_nr2name(apc->event); @@ -1991,7 +1990,7 @@ void auto_next_pat(AutoPatCmd *apc, int stop_at_last) = (STRLEN(s) + strlen(name) + (size_t)ap->patlen + 1); sourcing_name = xmalloc(sourcing_name_len); - snprintf((char *)sourcing_name, sourcing_name_len, s, name, ap->pat); + snprintf(sourcing_name, sourcing_name_len, s, name, ap->pat); if (p_verbose >= 8) { verbose_enter(); smsg(_("Executing %s"), sourcing_name); @@ -2064,7 +2063,7 @@ static bool call_autocmd_callback(const AutoCmd *ac, const AutoPatCmd *apc) /// Get next autocommand command. /// Called by do_cmdline() to get the next line for ":if". /// @return allocated string, or NULL for end of autocommands. -char_u *getnextac(int c, void *cookie, int indent, bool do_concat) +char *getnextac(int c, void *cookie, int indent, bool do_concat) { // These arguments are required for do_cmdline. (void)c; @@ -2155,7 +2154,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat) acp->nextcmd = ac->next; } - return (char_u *)retval; + return retval; } /// Return true if there is a matching autocommand for "fname". @@ -2165,12 +2164,13 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat) /// @param event event that occurred. /// @param sfname filename the event occurred in. /// @param buf buffer the file is open in -bool has_autocmd(event_T event, char_u *sfname, buf_T *buf) FUNC_ATTR_WARN_UNUSED_RESULT +bool has_autocmd(event_T event, char *sfname, buf_T *buf) + FUNC_ATTR_WARN_UNUSED_RESULT { - char *tail = (char *)path_tail(sfname); + char *tail = path_tail(sfname); bool retval = false; - char *fname = FullName_save((char *)sfname, false); + char *fname = FullName_save(sfname, false); if (fname == NULL) { return false; } @@ -2188,9 +2188,9 @@ bool has_autocmd(event_T event, char_u *sfname, buf_T *buf) FUNC_ATTR_WARN_UNUSE && (ap->buflocal_nr == 0 ? match_file_pat(NULL, &ap->reg_prog, - (char_u *)fname, + fname, sfname, - (char_u *)tail, + tail, ap->allow_dirs) : buf != NULL && ap->buflocal_nr == buf->b_fnum)) { retval = true; @@ -2208,12 +2208,12 @@ bool has_autocmd(event_T event, char_u *sfname, buf_T *buf) FUNC_ATTR_WARN_UNUSE // Function given to ExpandGeneric() to obtain the list of autocommand group // names. -char_u *expand_get_augroup_name(expand_T *xp, int idx) +char *expand_get_augroup_name(expand_T *xp, int idx) { // Required for ExpandGeneric (void)xp; - return (char_u *)augroup_name(idx + 1); + return augroup_name(idx + 1); } /// @param doautocmd true for :doauto*, false for :autocmd @@ -2263,7 +2263,7 @@ char *set_context_in_autocmd(expand_T *xp, char *arg, int doautocmd) } // Function given to ExpandGeneric() to obtain the list of event names. -char_u *expand_get_event_name(expand_T *xp, int idx) +char *expand_get_event_name(expand_T *xp, int idx) { // xp is a required parameter to be used with ExpandGeneric (void)xp; @@ -2273,14 +2273,14 @@ char_u *expand_get_event_name(expand_T *xp, int idx) if (name != NULL) { // skip when not including groups or skip deleted entries if (!autocmd_include_groups || name == get_deleted_augroup()) { - return (char_u *)""; + return ""; } - return (char_u *)name; + return name; } // List event names - return (char_u *)event_names[idx - next_augroup_id].name; + return event_names[idx - next_augroup_id].name; } /// Check whether given autocommand is supported @@ -2373,7 +2373,7 @@ bool au_exists(const char *const arg) FUNC_ATTR_WARN_UNUSED_RESULT && (group == AUGROUP_ALL || ap->group == group) && (pattern == NULL || (buflocal_buf == NULL - ? FNAMECMP(ap->pat, (char_u *)pattern) == 0 + ? FNAMECMP(ap->pat, pattern) == 0 : ap->buflocal_nr == buflocal_buf->b_fnum))) { retval = true; break; @@ -2410,7 +2410,7 @@ int aupat_get_buflocal_nr(char *pat, int patlen) } // "<buffer=123>" - if (skipdigits((char_u *)pat + 8) == (char_u *)pat + patlen - 1) { + if (skipdigits(pat + 8) == pat + patlen - 1) { return atoi(pat + 8); } } @@ -2434,10 +2434,10 @@ void aupat_normalize_buflocal_pat(char *dest, char *pat, int patlen, int bufloca buflocal_nr); } -int autocmd_delete_event(int group, event_T event, char_u *pat) +int autocmd_delete_event(int group, event_T event, char *pat) FUNC_ATTR_NONNULL_ALL { - return do_autocmd_event(event, (char *)pat, false, false, "", true, group); + return do_autocmd_event(event, pat, false, false, "", true, group); } /// Deletes an autocmd by ID. diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index ab804cc42f..30e5edb4d0 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -111,8 +111,8 @@ 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 : curbuf->b_ffname, - read_stdin ? NULL : curbuf->b_fname, + retval = readfile(read_stdin ? NULL : (char *)curbuf->b_ffname, + read_stdin ? NULL : (char *)curbuf->b_fname, line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap, flags | READ_BUFFER, silent); if (retval == OK) { @@ -229,7 +229,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags) } #endif - retval = readfile(curbuf->b_ffname, curbuf->b_fname, + retval = readfile((char *)curbuf->b_ffname, (char *)curbuf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap, flags | READ_NEW | (read_fifo ? READ_FIFO : 0), silent); #ifdef UNIX @@ -3175,7 +3175,7 @@ void maketitle(void) SPACE_FOR_FNAME + 1); buf_p += MIN(size, SPACE_FOR_FNAME); } else { - buf_p += transstr_buf((const char *)path_tail(curbuf->b_fname), + buf_p += transstr_buf((const char *)path_tail((char *)curbuf->b_fname), buf_p, SPACE_FOR_FNAME + 1, true); } @@ -3285,7 +3285,7 @@ void maketitle(void) if (buf_spname(curbuf) != NULL) { buf_p = buf_spname(curbuf); } else { // use file name only in icon - buf_p = path_tail(curbuf->b_ffname); + buf_p = (char_u *)path_tail((char *)curbuf->b_ffname); } *icon_str = NUL; // Truncate name at 100 bytes. @@ -3841,7 +3841,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san if (opt != STL_FILENAME) { str = (char *)NameBuff; } else { - str = (char *)path_tail(NameBuff); + str = path_tail((char *)NameBuff); } break; case STL_VIM_EXPR: // '{' @@ -3909,7 +3909,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_san // Check if the evaluated result is a number. // If so, convert the number to an int and free the string. if (str != NULL && *str != 0) { - if (*skipdigits((char_u *)str) == NUL) { + if (*skipdigits(str) == NUL) { num = atoi(str); XFREE_CLEAR(str); itemisflag = false; @@ -5201,9 +5201,9 @@ static int chk_modeline(linenr_T lnum, int flags) s = linecopy = vim_strsave(s); // copy the line, it will change save_sourcing_lnum = sourcing_lnum; - save_sourcing_name = sourcing_name; + save_sourcing_name = (char_u *)sourcing_name; sourcing_lnum = lnum; // prepare for emsg() - sourcing_name = (char_u *)"modelines"; + sourcing_name = "modelines"; end = false; while (end == false) { @@ -5259,7 +5259,7 @@ static int chk_modeline(linenr_T lnum, int flags) } sourcing_lnum = save_sourcing_lnum; - sourcing_name = save_sourcing_name; + sourcing_name = (char *)save_sourcing_name; xfree(linecopy); @@ -5594,7 +5594,7 @@ bool buf_contents_changed(buf_T *buf) aucmd_prepbuf(&aco, newbuf); if (ml_open(curbuf) == OK - && readfile(buf->b_ffname, buf->b_fname, + && readfile((char *)buf->b_ffname, (char *)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/change.c b/src/nvim/change.c index 767e6d3837..b15e90e0bc 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -557,7 +557,7 @@ void ins_char(int c) if (buf[0] == 0) { buf[0] = '\n'; } - ins_char_bytes(buf, n); + ins_char_bytes((char_u *)buf, n); } void ins_char_bytes(char_u *buf, size_t charlen) diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 5b93973f54..4f6033cbfa 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1187,16 +1187,16 @@ intptr_t getwhitecols(const char_u *p) /// @param[in] q String to skip digits in. /// /// @return Pointer to the character after the skipped digits. -char_u *skipdigits(const char_u *q) +char *skipdigits(const char *q) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { - const char_u *p = q; + const char *p = q; while (ascii_isdigit(*p)) { // skip to next non-digit p++; } - return (char_u *)p; + return (char *)p; } /// skip over binary digits diff --git a/src/nvim/context.c b/src/nvim/context.c index 0e0d8fdfde..db26667009 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -129,8 +129,8 @@ bool ctx_restore(Context *ctx, const int flags) free_ctx = true; } - char_u *op_shada; - get_option_value("shada", NULL, (char **)&op_shada, OPT_GLOBAL); + char *op_shada; + get_option_value("shada", NULL, &op_shada, OPT_GLOBAL); set_option_value("shada", 0L, "!,'100,%", OPT_GLOBAL); if (flags & kCtxRegs) { @@ -157,7 +157,7 @@ bool ctx_restore(Context *ctx, const int flags) ctx_free(ctx); } - set_option_value("shada", 0L, (char *)op_shada, OPT_GLOBAL); + set_option_value("shada", 0L, op_shada, OPT_GLOBAL); xfree(op_shada); return true; diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 6fab70d4c2..0f76c3e884 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -60,7 +60,7 @@ void do_debug(char_u *cmd) int save_ignore_script = 0; int n; char_u *cmdline = NULL; - char_u *p; + char *p; char *tail = NULL; static int last_cmd = 0; #define CMD_CONT 1 @@ -141,7 +141,7 @@ void do_debug(char_u *cmd) // If this is a debug command, set "last_cmd". // If not, reset "last_cmd". // For a blank line use previous command. - p = (char_u *)skipwhite((char *)cmdline); + p = skipwhite((char *)cmdline); if (*p != NUL) { switch (*p) { case 'c': @@ -200,7 +200,7 @@ void do_debug(char_u *cmd) if (last_cmd != 0) { // Check that the tail matches. p++; - while (*p != NUL && *p == (char_u)(*tail)) { + while (*p != NUL && *p == *tail) { p++; tail++; } @@ -242,8 +242,8 @@ void do_debug(char_u *cmd) if (*p == NUL) { do_showbacktrace(cmd); } else { - p = (char_u *)skipwhite((char *)p); - do_setdebugtracelevel(p); + p = skipwhite(p); + do_setdebugtracelevel((char_u *)p); } continue; case CMD_UP: diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 55992f3fae..dcc9b51431 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -744,7 +744,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) for (char_u *s = ml_get_buf(buf, lnum, false); *s != NUL;) { if (diff_flags & DIFF_ICASE) { int c; - char_u cbuf[MB_MAXBYTES + 1]; + char cbuf[MB_MAXBYTES + 1]; if (*s == NL) { c = NUL; @@ -794,7 +794,7 @@ static int diff_write(buf_T *buf, diffin_T *din) // Writing the buffer is an implementation detail of performing the diff, // so it shouldn't update the '[ and '] marks. cmdmod.lockmarks = true; - int r = buf_write(buf, din->din_fname, NULL, + int r = buf_write(buf, (char *)din->din_fname, NULL, (linenr_T)1, buf->b_ml.ml_line_count, NULL, false, false, false, true); cmdmod.lockmarks = save_lockmarks; @@ -1178,7 +1178,7 @@ void ex_diffpatch(exarg_T *eap) } // Write the current buffer to "tmp_orig". - if (buf_write(curbuf, tmp_orig, NULL, + if (buf_write(curbuf, (char *)tmp_orig, NULL, (linenr_T)1, curbuf->b_ml.ml_line_count, NULL, false, false, false, true) == FAIL) { goto theend; @@ -1982,8 +1982,8 @@ static int diff_cmp(char_u *s1, char_u *s2) return mb_stricmp((const char *)s1, (const char *)s2); } - char_u *p1 = s1; - char_u *p2 = s2; + char *p1 = (char *)s1; + char *p2 = (char *)s2; // Ignore white space changes and possibly ignore case. while (*p1 != NUL && *p2 != NUL) { @@ -1991,11 +1991,11 @@ static int diff_cmp(char_u *s1, char_u *s2) && ascii_iswhite(*p1) && ascii_iswhite(*p2)) || ((diff_flags & DIFF_IWHITEALL) && (ascii_iswhite(*p1) || ascii_iswhite(*p2)))) { - p1 = (char_u *)skipwhite((char *)p1); - p2 = (char_u *)skipwhite((char *)p2); + p1 = skipwhite(p1); + p2 = skipwhite(p2); } else { int l; - if (!diff_equal_char(p1, p2, &l)) { + if (!diff_equal_char((char_u *)p1, (char_u *)p2, &l)) { break; } p1 += l; @@ -2004,8 +2004,8 @@ static int diff_cmp(char_u *s1, char_u *s2) } // Ignore trailing white space. - p1 = (char_u *)skipwhite((char *)p1); - p2 = (char_u *)skipwhite((char *)p2); + p1 = skipwhite(p1); + p2 = skipwhite(p2); if ((*p1 != NUL) || (*p2 != NUL)) { return 1; diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index da96379700..43ea32fc09 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -2087,7 +2087,7 @@ void ex_loadkeymap(exarg_T *eap) // Get each line of the sourced file, break at the end. for (;;) { - char_u *line = eap->getline(0, eap->cookie, 0, true); + char *line = eap->getline(0, eap->cookie, 0, true); if (line == NULL) { break; diff --git a/src/nvim/edit.c b/src/nvim/edit.c index f7ce9f4b5f..90a6f81cc0 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1325,14 +1325,14 @@ normalchar: if (!p_paste) { // Trigger InsertCharPre. - char_u *str = do_insert_char_pre(s->c); - char_u *p; + char *str = (char *)do_insert_char_pre(s->c); + char *p; if (str != NULL) { if (*str != NUL && stop_arrow() != FAIL) { // Insert the new value of v:char literally. for (p = str; *p != NUL; MB_PTR_ADV(p)) { - s->c = utf_ptr2char((char *)p); + s->c = utf_ptr2char(p); if (s->c == CAR || s->c == K_KENTER || s->c == NL) { ins_eol(s->c); } else { @@ -3505,11 +3505,11 @@ static void ins_compl_addleader(int c) return; } if ((cc = utf_char2len(c)) > 1) { - char_u buf[MB_MAXBYTES + 1]; + char buf[MB_MAXBYTES + 1]; utf_char2bytes(c, (char *)buf); buf[cc] = NUL; - ins_char_bytes(buf, (size_t)cc); + ins_char_bytes((char_u *)buf, (size_t)cc); } else { ins_char(c); } @@ -5939,11 +5939,11 @@ void insertchar(int c, int flags, int second_indent) int cc; if ((cc = utf_char2len(c)) > 1) { - char_u buf[MB_MAXBYTES + 1]; + char buf[MB_MAXBYTES + 1]; utf_char2bytes(c, (char *)buf); buf[cc] = NUL; - ins_char_bytes(buf, (size_t)cc); + ins_char_bytes((char_u *)buf, (size_t)cc); AppendCharToRedobuff(c); } else { ins_char(c); @@ -6840,7 +6840,7 @@ char_u *add_char2buf(int c, char_u *s) char_u temp[MB_MAXBYTES + 1]; const int len = utf_char2bytes(c, (char *)temp); for (int i = 0; i < len; i++) { - c = temp[i]; + c = (uint8_t)temp[i]; // Need to escape K_SPECIAL like in the typeahead buffer. if (c == K_SPECIAL) { *s++ = K_SPECIAL; @@ -9460,7 +9460,7 @@ static char_u *do_insert_char_pre(int c) // character. Only use it when changed, otherwise continue with the // original character to avoid breaking autoindent. if (STRCMP(buf, get_vim_var_str(VV_CHAR)) != 0) { - res = vim_strsave(get_vim_var_str(VV_CHAR)); + res = vim_strsave((char_u *)get_vim_var_str(VV_CHAR)); } } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 01f913dd70..ba7e34b541 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1327,7 +1327,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd) int mi = 0; int ti = 0; - char *theline = (char *)eap->getline(NUL, eap->cookie, 0, false); + char *theline = eap->getline(NUL, eap->cookie, 0, false); if (theline == NULL) { semsg(_("E990: Missing end marker '%s'"), marker); break; @@ -3170,7 +3170,7 @@ char *cat_prefix_varname(int prefix, const char *name) /// Function given to ExpandGeneric() to obtain the list of user defined /// (global/buffer/window/built-in) variable names. -char_u *get_user_var_name(expand_T *xp, int idx) +char *get_user_var_name(expand_T *xp, int idx) { static size_t gdone; static size_t bdone; @@ -3195,9 +3195,9 @@ char_u *get_user_var_name(expand_T *xp, int idx) ++hi; } if (STRNCMP("g:", xp->xp_pattern, 2) == 0) { - return (char_u *)cat_prefix_varname('g', (char *)hi->hi_key); + return cat_prefix_varname('g', (char *)hi->hi_key); } - return hi->hi_key; + return (char *)hi->hi_key; } // b: variables @@ -3211,7 +3211,7 @@ char_u *get_user_var_name(expand_T *xp, int idx) while (HASHITEM_EMPTY(hi)) { ++hi; } - return (char_u *)cat_prefix_varname('b', (char *)hi->hi_key); + return cat_prefix_varname('b', (char *)hi->hi_key); } // w: variables @@ -3225,7 +3225,7 @@ char_u *get_user_var_name(expand_T *xp, int idx) while (HASHITEM_EMPTY(hi)) { ++hi; } - return (char_u *)cat_prefix_varname('w', (char *)hi->hi_key); + return cat_prefix_varname('w', (char *)hi->hi_key); } // t: variables @@ -3239,12 +3239,12 @@ char_u *get_user_var_name(expand_T *xp, int idx) while (HASHITEM_EMPTY(hi)) { ++hi; } - return (char_u *)cat_prefix_varname('t', (char *)hi->hi_key); + return cat_prefix_varname('t', (char *)hi->hi_key); } // v: variables if (vidx < ARRAY_SIZE(vimvars)) { - return (char_u *)cat_prefix_varname('v', vimvars[vidx++].vv_name); + return cat_prefix_varname('v', vimvars[vidx++].vv_name); } XFREE_CLEAR(varnamebuf); @@ -4057,7 +4057,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) case '7': case '8': case '9': { - char *p = (char *)skipdigits((char_u *)(*arg) + 1); + char *p = skipdigits(*arg + 1); int get_float = false; // We accept a float when the format matches @@ -4067,7 +4067,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) // ":let vers = 1.2.3" doesn't fail. if (!want_string && p[0] == '.' && ascii_isdigit(p[1])) { get_float = true; - p = (char *)skipdigits((char_u *)p + 2); + p = skipdigits(p + 2); if (*p == 'e' || *p == 'E') { ++p; if (*p == '-' || *p == '+') { @@ -4076,7 +4076,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) if (!ascii_isdigit(*p)) { get_float = false; } else { - p = (char *)skipdigits((char_u *)p + 1); + p = skipdigits(p + 1); } } if (ASCII_ISALPHA(*p) || *p == '.') { @@ -8206,9 +8206,10 @@ varnumber_T get_vim_var_nr(int idx) FUNC_ATTR_PURE /// Get string v: variable value. Uses a static buffer, can only be used once. /// If the String variable has never been set, return an empty string. /// Never returns NULL; -char_u *get_vim_var_str(int idx) FUNC_ATTR_PURE FUNC_ATTR_NONNULL_RET +char *get_vim_var_str(int idx) + FUNC_ATTR_PURE FUNC_ATTR_NONNULL_RET { - return (char_u *)tv_get_string(&vimvars[idx].vv_tv); + return (char *)tv_get_string(&vimvars[idx].vv_tv); } /// Get List v: variable value. Caller must take care of reference count when @@ -10217,7 +10218,7 @@ repeat: } } - tail = (char *)path_tail((char_u *)(*fnamep)); + tail = path_tail(*fnamep); *fnamelen = STRLEN(*fnamep); // ":h" - head, remove "/file_name", can be repeated diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 520137af0a..cf5f86b3f7 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -116,7 +116,7 @@ static va_list dummy_ap; /// Function given to ExpandGeneric() to obtain the list of internal /// or user defined function names. -char_u *get_function_name(expand_T *xp, int idx) +char *get_function_name(expand_T *xp, int idx) { static int intidx = -1; char_u *name; @@ -125,13 +125,13 @@ char_u *get_function_name(expand_T *xp, int idx) intidx = -1; } if (intidx < 0) { - name = get_user_func_name(xp, idx); + name = (char_u *)get_user_func_name(xp, idx); if (name != NULL) { if (*name != NUL && *name != '<' && STRNCMP("g:", xp->xp_pattern, 2) == 0) { - return (char_u *)cat_prefix_varname('g', (char *)name); + return cat_prefix_varname('g', (char *)name); } - return name; + return (char *)name; } } while ((size_t)++intidx < ARRAY_SIZE(functions) @@ -151,12 +151,12 @@ char_u *get_function_name(expand_T *xp, int idx) } else { IObuff[key_len + 1] = NUL; } - return IObuff; + return (char *)IObuff; } /// Function given to ExpandGeneric() to obtain the list of internal or /// user defined variable or function names. -char_u *get_expr_name(expand_T *xp, int idx) +char *get_expr_name(expand_T *xp, int idx) { static int intidx = -1; char_u *name; @@ -165,9 +165,9 @@ char_u *get_expr_name(expand_T *xp, int idx) intidx = -1; } if (intidx < 0) { - name = get_function_name(xp, idx); + name = (char_u *)get_function_name(xp, idx); if (name != NULL) { - return name; + return (char *)name; } } return get_user_var_name(xp, ++intidx); @@ -1931,7 +1931,7 @@ typedef struct { const listitem_T *li; } GetListLineCookie; -static char_u *get_list_line(int c, void *cookie, int indent, bool do_concat) +static char *get_list_line(int c, void *cookie, int indent, bool do_concat) { GetListLineCookie *const p = (GetListLineCookie *)cookie; @@ -1942,7 +1942,7 @@ static char_u *get_list_line(int c, void *cookie, int indent, bool do_concat) char buf[NUMBUFLEN]; const char *const s = tv_get_string_buf_chk(TV_LIST_ITEM_TV(item), buf); p->li = TV_LIST_ITEM_NEXT(p->l, item); - return (char_u *)(s == NULL ? NULL : xstrdup(s)); + return s == NULL ? NULL : xstrdup(s); } static void execute_common(typval_T *argvars, typval_T *rettv, FunPtr fptr, int arg_off) @@ -2562,7 +2562,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr) foldstart = (linenr_T)get_vim_var_nr(VV_FOLDSTART); foldend = (linenr_T)get_vim_var_nr(VV_FOLDEND); - dashes = get_vim_var_str(VV_FOLDDASHES); + dashes = (char_u *)get_vim_var_str(VV_FOLDDASHES); if (foldstart > 0 && foldend <= curbuf->b_ml.ml_line_count) { // Find first non-empty line in the fold. for (lnum = foldstart; lnum < foldend; lnum++) { @@ -3082,7 +3082,7 @@ static void f_getcharstr(typval_T *argvars, typval_T *rettv, FunPtr fptr) getchar_common(argvars, rettv); if (rettv->v_type == VAR_NUMBER) { - char_u temp[7]; // mbyte-char: 6, NUL: 1 + char temp[7]; // mbyte-char: 6, NUL: 1 const varnumber_T n = rettv->vval.v_number; int i = 0; @@ -3092,7 +3092,7 @@ static void f_getcharstr(typval_T *argvars, typval_T *rettv, FunPtr fptr) assert(i < 7); temp[i++] = NUL; rettv->v_type = VAR_STRING; - rettv->vval.v_string = (char *)vim_strsave(temp); + rettv->vval.v_string = xstrdup(temp); } } @@ -3677,7 +3677,7 @@ static int getreg_get_regname(typval_T *argvars) } } else { // Default to v:register - strregname = get_vim_var_str(VV_REG); + strregname = (char_u *)get_vim_var_str(VV_REG); } return *strregname == 0 ? '"' : *strregname; @@ -5101,7 +5101,7 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en } // Set $NVIM (in the child process) to v:servername. #3118 - char *nvim_addr = (char *)get_vim_var_str(VV_SEND_SERVER); + char *nvim_addr = get_vim_var_str(VV_SEND_SERVER); if (nvim_addr[0] != '\0') { dictitem_T *dv = tv_dict_find(env, S_LEN("NVIM")); if (dv) { @@ -5646,7 +5646,7 @@ static void f_list2str(typval_T *argvars, typval_T *rettv, FunPtr fptr) } ga_init(&ga, 1, 80); - char_u buf[MB_MAXBYTES + 1]; + char buf[MB_MAXBYTES + 1]; TV_LIST_ITER_CONST(l, li, { buf[utf_char2bytes(tv_get_number(TV_LIST_ITEM_TV(li)), (char *)buf)] = NUL; @@ -5666,7 +5666,7 @@ static void f_localtime(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) { - char_u *keys_buf = NULL; + char *keys_buf = NULL; char_u *alt_keys_buf = NULL; bool did_simplify = false; char_u *rhs; @@ -5682,7 +5682,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; - char_u *keys = (char_u *)tv_get_string(&argvars[0]); + char *keys = (char *)tv_get_string(&argvars[0]); if (*keys == NUL) { return; } @@ -5707,14 +5707,14 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) mode = get_map_mode((char **)&which, 0); char_u *keys_simplified - = (char_u *)replace_termcodes((char *)keys, - STRLEN(keys), (char **)&keys_buf, flags, &did_simplify, + = (char_u *)replace_termcodes(keys, + STRLEN(keys), &keys_buf, flags, &did_simplify, CPO_TO_CPO_FLAGS); rhs = check_map(keys_simplified, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); if (did_simplify) { // When the lhs is being simplified the not-simplified keys are // preferred for printing, like in do_map(). - (void)replace_termcodes((char *)keys, + (void)replace_termcodes(keys, STRLEN(keys), (char **)&alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL, CPO_TO_CPO_FLAGS); @@ -6100,7 +6100,7 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - if (*path_tail((char_u *)dir) == NUL) { + if (*path_tail(dir) == NUL) { // Remove trailing slashes. *path_tail_with_sep((char_u *)dir) = NUL; } @@ -7402,11 +7402,11 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr) q[-1] = NUL; } - q = (char *)path_tail((char_u *)p); + q = path_tail(p); if (q > p && *q == NUL) { // Ignore trailing path separator. q[-1] = NUL; - q = (char *)path_tail((char_u *)p); + q = path_tail(p); } if (q > p && !path_is_absolute((const char_u *)buf)) { // Symlink is relative to directory of argument. Replace the @@ -7414,7 +7414,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr) const size_t p_len = strlen(p); const size_t buf_len = strlen(buf); p = xrealloc(p, p_len + buf_len + 1); - memcpy(path_tail((char_u *)p), buf, buf_len + 1); + memcpy(path_tail(p), buf, buf_len + 1); } else { xfree(p); p = xstrdup(buf); @@ -7524,15 +7524,15 @@ static void f_reduce(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - const char_u *func_name; + const char *func_name; partial_T *partial = NULL; if (argvars[1].v_type == VAR_FUNC) { - func_name = (char_u *)argvars[1].vval.v_string; + func_name = argvars[1].vval.v_string; } else if (argvars[1].v_type == VAR_PARTIAL) { partial = argvars[1].vval.v_partial; - func_name = (char_u *)partial_name(partial); + func_name = partial_name(partial); } else { - func_name = (const char_u *)tv_get_string(&argvars[1]); + func_name = tv_get_string(&argvars[1]); } if (*func_name == NUL) { return; // type error or empty name @@ -7881,7 +7881,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr) } sctx_T save_current_sctx; - uint8_t *save_sourcing_name, *save_autocmd_fname, *save_autocmd_match; + char *save_sourcing_name, *save_autocmd_fname, *save_autocmd_match; linenr_T save_sourcing_lnum; int save_autocmd_bufnr; funccal_entry_T funccal_entry; @@ -9854,13 +9854,13 @@ static void f_stdpath(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "str2float()" function static void f_str2float(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - char_u *p = (char_u *)skipwhite(tv_get_string(&argvars[0])); + char *p = skipwhite(tv_get_string(&argvars[0])); bool isneg = (*p == '-'); if (*p == '+' || *p == '-') { - p = (char_u *)skipwhite((char *)p + 1); + p = skipwhite(p + 1); } - (void)string2float((char *)p, &rettv->vval.v_float); + (void)string2float(p, &rettv->vval.v_float); if (isneg) { rettv->vval.v_float *= -1; } diff --git a/src/nvim/eval/typval_encode.h b/src/nvim/eval/typval_encode.h index d5cf431870..ed70ba87ec 100644 --- a/src/nvim/eval/typval_encode.h +++ b/src/nvim/eval/typval_encode.h @@ -85,9 +85,7 @@ static inline size_t tv_strlen(const typval_T *const tv) static inline size_t tv_strlen(const typval_T *const tv) { assert(tv->v_type == VAR_STRING); - return (tv->vval.v_string == NULL - ? 0 - : strlen((char *)tv->vval.v_string)); + return (tv->vval.v_string == NULL ? 0 : strlen(tv->vval.v_string)); } /// Code for checking whether container references itself diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index d6a63993c6..c6b6a8ead9 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -994,7 +994,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett // Don't redraw while executing the function. RedrawingDisabled++; - save_sourcing_name = sourcing_name; + save_sourcing_name = (char_u *)sourcing_name; save_sourcing_lnum = sourcing_lnum; sourcing_lnum = 1; @@ -1014,7 +1014,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett { if (save_sourcing_name != NULL && STRNCMP(save_sourcing_name, "function ", 9) == 0) { - vim_snprintf((char *)sourcing_name, + vim_snprintf(sourcing_name, len, "%s[%" PRId64 "]..", save_sourcing_name, @@ -1022,7 +1022,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett } else { STRCPY(sourcing_name, "function "); } - cat_func_name(sourcing_name + STRLEN(sourcing_name), fp); + cat_func_name((char_u *)sourcing_name + STRLEN(sourcing_name), fp); if (p_verbose >= 12) { ++no_wait_return; @@ -1175,7 +1175,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett } xfree(sourcing_name); - sourcing_name = save_sourcing_name; + sourcing_name = (char *)save_sourcing_name; sourcing_lnum = save_sourcing_lnum; current_sctx = save_current_sctx; if (do_profiling_yes) { @@ -2219,7 +2219,7 @@ void ex_function(exarg_T *eap) if (eap->getline == NULL) { theline = getcmdline(':', 0L, indent, do_concat); } else { - theline = eap->getline(':', eap->cookie, indent, do_concat); + theline = (char_u *)eap->getline(':', eap->cookie, indent, do_concat); } line_to_free = theline; } @@ -2644,7 +2644,7 @@ bool function_exists(const char *const name, bool no_deref) /// Function given to ExpandGeneric() to obtain the list of user defined /// function names. -char_u *get_user_func_name(expand_T *xp, int idx) +char *get_user_func_name(expand_T *xp, int idx) { static size_t done; static hashitem_T *hi; @@ -2666,11 +2666,11 @@ char_u *get_user_func_name(expand_T *xp, int idx) if ((fp->uf_flags & FC_DICT) || STRNCMP(fp->uf_name, "<lambda>", 8) == 0) { - return (char_u *)""; // don't show dict and lambda functions + return ""; // don't show dict and lambda functions } if (STRLEN(fp->uf_name) + 4 >= IOSIZE) { - return fp->uf_name; // Prevent overflow. + return (char *)fp->uf_name; // Prevent overflow. } cat_func_name(IObuff, fp); @@ -2680,7 +2680,7 @@ char_u *get_user_func_name(expand_T *xp, int idx) STRCAT(IObuff, ")"); } } - return IObuff; + return (char *)IObuff; } return NULL; } @@ -3137,7 +3137,7 @@ char_u *get_return_cmd(void *rettv) /// Called by do_cmdline() to get the next line. /// /// @return allocated string, or NULL for end of function. -char_u *get_func_line(int c, void *cookie, int indent, bool do_concat) +char *get_func_line(int c, void *cookie, int indent, bool do_concat) { funccall_T *fcp = (funccall_T *)cookie; ufunc_T *fp = fcp->func; @@ -3184,7 +3184,7 @@ char_u *get_func_line(int c, void *cookie, int indent, bool do_concat) fcp->dbg_tick = debug_tick; } - return retval; + return (char *)retval; } /// @return TRUE if the currently active function should be ended, because a diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index 060b432b18..1722f0ee1f 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -124,7 +124,7 @@ int socket_watcher_start(SocketWatcher *watcher, int backlog, socket_cb cb) if (result == UV_EACCES) { // Libuv converts ENOENT to EACCES for Windows compatibility, but if // the parent directory does not exist, ENOENT would be more accurate. - *path_tail((char_u *)watcher->addr) = NUL; + *path_tail(watcher->addr) = NUL; if (!os_path_exists((char_u *)watcher->addr)) { result = UV_ENOENT; } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b8ca00a9e8..1dbae13354 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1341,7 +1341,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b * Vi also doesn't do this and the messages are not very informative. */ no_wait_return++; // don't call wait_return() while busy - if (itmp != NULL && buf_write(curbuf, (char_u *)itmp, NULL, line1, line2, eap, + if (itmp != NULL && buf_write(curbuf, itmp, NULL, line1, line2, eap, false, false, false, true) == FAIL) { msg_putchar('\n'); // Keep message from buf_write(). no_wait_return--; @@ -1386,7 +1386,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b if (do_out) { if (otmp != NULL) { - if (readfile((char_u *)otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, + if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, READ_FILTER, false) != OK) { if (!aborting()) { msg_putchar('\n'); @@ -1930,7 +1930,7 @@ int do_write(exarg_T *eap) } name_was_missing = curbuf->b_ffname == NULL; - retval = buf_write(curbuf, (char_u *)ffname, (char_u *)fname, eap->line1, eap->line2, + retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2, eap, eap->append, eap->forceit, true, false); // After ":saveas fname" reset 'readonly'. @@ -5360,7 +5360,7 @@ void fix_help_buffer(void) * In the "help.txt" and "help.abx" file, add the locally added help * files. This uses the very first line in the help file. */ - char *const fname = (char *)path_tail(curbuf->b_fname); + char *const fname = path_tail((char *)curbuf->b_fname); if (FNAMECMP(fname, "help.txt") == 0 || (FNAMENCMP(fname, "help.", 5) == 0 && ASCII_ISALPHA(fname[5]) @@ -5413,8 +5413,8 @@ void fix_help_buffer(void) } const char *const f1 = fnames[i1]; const char *const f2 = fnames[i2]; - const char *const t1 = (char *)path_tail((char_u *)f1); - const char *const t2 = (char *)path_tail((char_u *)f2); + const char *const t1 = path_tail(f1); + const char *const t2 = path_tail(f2); const char *const e1 = (char *)STRRCHR(t1, '.'); const char *const e2 = (char *)STRRCHR(t2, '.'); if (e1 == NULL || e2 == NULL) { diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index d1dcb28dbd..8624f6d676 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -200,12 +200,12 @@ static char *pexpand_cmds[] = { /// Function given to ExpandGeneric() to obtain the profile command /// specific expansion. -char_u *get_profile_name(expand_T *xp, int idx) +char *get_profile_name(expand_T *xp, int idx) FUNC_ATTR_PURE { switch (pexpand_what) { case PEXP_SUBCMD: - return (char_u *)pexpand_cmds[idx]; + return pexpand_cmds[idx]; // case PEXP_FUNC: TODO default: return NULL; @@ -792,7 +792,7 @@ int buf_write_all(buf_T *buf, int forceit) int retval; buf_T *old_curbuf = curbuf; - retval = (buf_write(buf, buf->b_ffname, buf->b_fname, + retval = (buf_write(buf, (char *)buf->b_ffname, (char *)buf->b_fname, (linenr_T)1, buf->b_ml.ml_line_count, NULL, false, forceit, true, false)); if (curbuf != old_curbuf) { @@ -1571,12 +1571,12 @@ static void alist_add_list(int count, char **files, int after, bool will_edit) // Function given to ExpandGeneric() to obtain the possible arguments of the // argedit and argdelete commands. -char_u *get_arglist_name(expand_T *xp FUNC_ATTR_UNUSED, int idx) +char *get_arglist_name(expand_T *xp FUNC_ATTR_UNUSED, int idx) { if (idx >= ARGCOUNT) { return NULL; } - return alist_name(&ARGLIST[idx]); + return (char *)alist_name(&ARGLIST[idx]); } /// ":compiler[!] {name}" @@ -1766,7 +1766,7 @@ typedef struct { /// /// @return pointer to allocated line, or NULL for end-of-file or /// some error. -static char_u *get_str_line(int c, void *cookie, int indent, bool do_concat) +static char *get_str_line(int c, void *cookie, int indent, bool do_concat) { GetStrLineCookie *p = cookie; if (STRLEN(p->buf) <= p->offset) { @@ -1818,16 +1818,16 @@ scriptitem_T *new_script_item(char *const name, scid_T *const sid_out) static int source_using_linegetter(void *cookie, LineGetter fgetline, const char *traceback_name) { - char *save_sourcing_name = (char *)sourcing_name; + char *save_sourcing_name = sourcing_name; linenr_T save_sourcing_lnum = sourcing_lnum; char sourcing_name_buf[256]; if (save_sourcing_name == NULL) { - sourcing_name = (char_u *)traceback_name; + sourcing_name = (char *)traceback_name; } else { snprintf((char *)sourcing_name_buf, sizeof(sourcing_name_buf), "%s called at %s:%" PRIdLINENR, traceback_name, save_sourcing_name, save_sourcing_lnum); - sourcing_name = (char_u *)sourcing_name_buf; // -V507 reassigned below, before return. + sourcing_name = sourcing_name_buf; // -V507 reassigned below, before return. } sourcing_lnum = 0; @@ -1842,7 +1842,7 @@ static int source_using_linegetter(void *cookie, LineGetter fgetline, const char int retval = do_cmdline(NULL, fgetline, cookie, DOCMD_VERBOSE | DOCMD_NOWAIT | DOCMD_REPEAT); sourcing_lnum = save_sourcing_lnum; - sourcing_name = (char_u *)save_sourcing_name; + sourcing_name = save_sourcing_name; current_sctx = save_current_sctx; restore_funccal(); return retval; @@ -1935,7 +1935,7 @@ int do_source(char *fname, int check_other, int is_vimrc) } // Apply SourceCmd autocommands, they should get the file and source it. - if (has_autocmd(EVENT_SOURCECMD, (char_u *)fname_exp, NULL) + if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL) && apply_autocmds(EVENT_SOURCECMD, (char_u *)fname_exp, (char_u *)fname_exp, false, curbuf)) { retval = aborting() ? FAIL : OK; @@ -1953,7 +1953,7 @@ int do_source(char *fname, int check_other, int is_vimrc) if (cookie.fp == NULL && check_other) { // Try again, replacing file name ".vimrc" by "_vimrc" or vice versa, // and ".exrc" by "_exrc" or vice versa. - p = (char *)path_tail((char_u *)fname_exp); + p = path_tail(fname_exp); if ((*p == '.' || *p == '_') && (STRICMP(p + 1, "nvimrc") == 0 || STRICMP(p + 1, "exrc") == 0)) { *p = (*p == '_') ? '.' : '_'; @@ -2014,8 +2014,8 @@ int do_source(char *fname, int check_other, int is_vimrc) cookie.level = ex_nesting_level; // Keep the sourcing name/lnum, for recursive calls. - save_sourcing_name = (char *)sourcing_name; - sourcing_name = (char_u *)fname_exp; + save_sourcing_name = sourcing_name; + sourcing_name = fname_exp; save_sourcing_lnum = sourcing_lnum; sourcing_lnum = 0; @@ -2059,7 +2059,7 @@ int do_source(char *fname, int check_other, int is_vimrc) cookie.conv.vc_type = CONV_NONE; // no conversion // Read the first line so we can check for a UTF-8 BOM. - firstline = getsourceline(0, (void *)&cookie, 0, true); + firstline = (uint8_t *)getsourceline(0, (void *)&cookie, 0, true); if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef && firstline[1] == 0xbb && firstline[2] == 0xbf) { // Found BOM; setup conversion, skip over BOM and recode the line. @@ -2104,7 +2104,7 @@ int do_source(char *fname, int check_other, int is_vimrc) if (got_int) { emsg(_(e_interr)); } - sourcing_name = (char_u *)save_sourcing_name; + sourcing_name = save_sourcing_name; sourcing_lnum = save_sourcing_lnum; if (p_verbose > 1) { verbose_enter(); @@ -2302,7 +2302,7 @@ linenr_T get_sourced_lnum(LineGetter fgetline, void *cookie) /// /// @return pointer to the line in allocated memory, or NULL for end-of-file or /// some error. -char_u *getsourceline(int c, void *cookie, int indent, bool do_concat) +char *getsourceline(int c, void *cookie, int indent, bool do_concat) { struct source_cookie *sp = (struct source_cookie *)cookie; char *line; @@ -2382,7 +2382,7 @@ char_u *getsourceline(int c, void *cookie, int indent, bool do_concat) sp->dbg_tick = debug_tick; } - return (char_u *)line; + return line; } static char *get_one_sourceline(struct source_cookie *sp) @@ -2942,36 +2942,36 @@ void free_locales(void) /// Function given to ExpandGeneric() to obtain the possible arguments of the /// ":language" command. -char_u *get_lang_arg(expand_T *xp, int idx) +char *get_lang_arg(expand_T *xp, int idx) { if (idx == 0) { - return (char_u *)"messages"; + return "messages"; } if (idx == 1) { - return (char_u *)"ctype"; + return "ctype"; } if (idx == 2) { - return (char_u *)"time"; + return "time"; } if (idx == 3) { - return (char_u *)"collate"; + return "collate"; } init_locales(); if (locales == NULL) { return NULL; } - return (char_u *)locales[idx - 4]; + return locales[idx - 4]; } /// Function given to ExpandGeneric() to obtain the available locales. -char_u *get_locales(expand_T *xp, int idx) +char *get_locales(expand_T *xp, int idx) { init_locales(); if (locales == NULL) { return NULL; } - return (char_u *)locales[idx]; + return locales[idx]; } #endif diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index e4c85fbc9b..a51f805984 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -121,7 +121,7 @@ struct aucmd_executable_t { #define AUCMD_EXECUTABLE_INIT { .type = CALLABLE_NONE } -typedef char_u *(*LineGetter)(int, void *, int, bool); +typedef char *(*LineGetter)(int, void *, int, bool); /// Structure for command definition. typedef struct cmdname { diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 8278ef5cc6..fc66677537 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -111,7 +111,7 @@ struct loop_cookie { int current_line; // last read line from growarray int repeating; // TRUE when looping a second time // When "repeating" is FALSE use "getline" and "cookie" to get lines - char_u *(*getline)(int, void *, int, bool); + char *(*getline)(int, void *, int, bool); void *cookie; }; @@ -324,7 +324,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags) struct msglist *private_msg_list; // "fgetline" and "cookie" passed to do_one_cmd() - char_u *(*cmd_getline)(int, void *, int, bool); + char *(*cmd_getline)(int, void *, int, bool); void *cmd_cookie; struct loop_cookie cmd_loop_cookie; void *real_cookie; @@ -372,7 +372,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags) breakpoint = func_breakpoint(real_cookie); dbg_tick = func_dbg_tick(real_cookie); } else if (getline_equal(fgetline, cookie, getsourceline)) { - fname = (char *)sourcing_name; + fname = sourcing_name; breakpoint = source_breakpoint(real_cookie); dbg_tick = source_dbg_tick(real_cookie); } @@ -518,10 +518,10 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags) msg_didout = true; } if (fgetline == NULL - || (next_cmdline = (char *)fgetline(':', cookie, - cstack.cs_idx < - 0 ? 0 : (cstack.cs_idx + 1) * 2, - true)) == NULL) { + || (next_cmdline = fgetline(':', cookie, + cstack.cs_idx < + 0 ? 0 : (cstack.cs_idx + 1) * 2, + true)) == NULL) { // Don't call wait_return for aborted command line. The NULL // returned for the end of a sourced file or executed function // doesn't do this. @@ -832,9 +832,9 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags) break; } - saved_sourcing_name = (char *)sourcing_name; + saved_sourcing_name = sourcing_name; saved_sourcing_lnum = sourcing_lnum; - sourcing_name = (char_u *)current_exception->throw_name; + sourcing_name = current_exception->throw_name; sourcing_lnum = current_exception->throw_lnum; current_exception->throw_name = NULL; @@ -856,7 +856,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags) xfree(p); } xfree(sourcing_name); - sourcing_name = (char_u *)saved_sourcing_name; + sourcing_name = saved_sourcing_name; sourcing_lnum = saved_sourcing_lnum; } else if (got_int || (did_emsg && force_abort)) { // On an interrupt or an aborting error not converted to an exception, @@ -949,7 +949,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags) } /// Obtain a line when inside a ":while" or ":for" loop. -static char_u *get_loop_line(int c, void *cookie, int indent, bool do_concat) +static char *get_loop_line(int c, void *cookie, int indent, bool do_concat) { struct loop_cookie *cp = (struct loop_cookie *)cookie; wcmd_T *wp; @@ -963,21 +963,21 @@ static char_u *get_loop_line(int c, void *cookie, int indent, bool do_concat) if (cp->getline == NULL) { line = (char *)getcmdline(c, 0L, indent, do_concat); } else { - line = (char *)cp->getline(c, cp->cookie, indent, do_concat); + line = cp->getline(c, cp->cookie, indent, do_concat); } if (line != NULL) { store_loop_line(cp->lines_gap, line); ++cp->current_line; } - return (char_u *)line; + return line; } KeyTyped = false; cp->current_line++; wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line; sourcing_lnum = wp->lnum; - return vim_strsave((char_u *)wp->line); + return xstrdup(wp->line); } /// Store a line in "gap" so that a ":while" loop can execute it again. @@ -1328,7 +1328,7 @@ static int parse_count(exarg_T *eap, char **errormsg, bool validate) long n; if ((eap->argt & EX_COUNT) && ascii_isdigit(*eap->arg) - && (!(eap->argt & EX_BUFNAME) || *(p = (char *)skipdigits((char_u *)eap->arg + 1)) == NUL + && (!(eap->argt & EX_BUFNAME) || *(p = skipdigits(eap->arg + 1)) == NUL || ascii_iswhite(*p))) { n = getdigits_long((char_u **)&eap->arg, false, -1); eap->arg = skipwhite(eap->arg); @@ -3032,7 +3032,7 @@ int modifier_len(char *cmd) char *p = cmd; if (ascii_isdigit(*cmd)) { - p = skipwhite((char *)skipdigits((char_u *)cmd + 1)); + p = skipwhite(skipdigits(cmd + 1)); } for (int i = 0; i < (int)ARRAY_SIZE(cmdmods); i++) { int j; @@ -3660,7 +3660,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff) case CMD_isplit: case CMD_dsplit: // Skip count. - arg = (const char *)skipwhite((char *)skipdigits((const char_u *)arg)); + arg = (const char *)skipwhite(skipdigits(arg)); if (*arg == '/') { // Match regexp, not just whole words. for (++arg; *arg && *arg != '/'; arg++) { if (*arg == '\\' && arg[1] != NUL) { @@ -5325,12 +5325,12 @@ static int check_more(int message, bool forceit) } /// Function given to ExpandGeneric() to obtain the list of command names. -char_u *get_command_name(expand_T *xp, int idx) +char *get_command_name(expand_T *xp, int idx) { if (idx >= CMD_SIZE) { - return (char_u *)expand_user_command_name(idx); + return expand_user_command_name(idx); } - return (char_u *)cmdnames[idx].cmd_name; + return cmdnames[idx].cmd_name; } /// Check for a valid user command name @@ -6510,28 +6510,28 @@ static void do_ucmd(exarg_T *eap) static char *expand_user_command_name(int idx) { - return (char *)get_user_commands(NULL, idx - CMD_SIZE); + return get_user_commands(NULL, idx - CMD_SIZE); } /// Function given to ExpandGeneric() to obtain the list of user address type names. -char_u *get_user_cmd_addr_type(expand_T *xp, int idx) +char *get_user_cmd_addr_type(expand_T *xp, int idx) { - return (char_u *)addr_type_complete[idx].name; + return addr_type_complete[idx].name; } /// Function given to ExpandGeneric() to obtain the list of user command names. -char_u *get_user_commands(expand_T *xp FUNC_ATTR_UNUSED, int idx) +char *get_user_commands(expand_T *xp FUNC_ATTR_UNUSED, int idx) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { // In cmdwin, the alternative buffer should be used. const buf_T *const buf = prevwin_curwin()->w_buffer; if (idx < buf->b_ucmds.ga_len) { - return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name; + return (char *)USER_CMD_GA(&buf->b_ucmds, idx)->uc_name; } idx -= buf->b_ucmds.ga_len; if (idx < ucmds.ga_len) { - return USER_CMD(idx)->uc_name; + return (char *)USER_CMD(idx)->uc_name; } return NULL; } @@ -6558,7 +6558,7 @@ static char *get_user_command_name(int idx, int cmdidx) /// Function given to ExpandGeneric() to obtain the list of user command /// attributes. -char_u *get_user_cmd_flags(expand_T *xp, int idx) +char *get_user_cmd_flags(expand_T *xp, int idx) { static char *user_cmd_flags[] = { "addr", "bang", "bar", "buffer", "complete", "count", @@ -6567,31 +6567,31 @@ char_u *get_user_cmd_flags(expand_T *xp, int idx) if (idx >= (int)ARRAY_SIZE(user_cmd_flags)) { return NULL; } - return (char_u *)user_cmd_flags[idx]; + return user_cmd_flags[idx]; } /// Function given to ExpandGeneric() to obtain the list of values for -nargs. -char_u *get_user_cmd_nargs(expand_T *xp, int idx) +char *get_user_cmd_nargs(expand_T *xp, int idx) { static char *user_cmd_nargs[] = { "0", "1", "*", "?", "+" }; if (idx >= (int)ARRAY_SIZE(user_cmd_nargs)) { return NULL; } - return (char_u *)user_cmd_nargs[idx]; + return user_cmd_nargs[idx]; } /// Function given to ExpandGeneric() to obtain the list of values for -complete. -char_u *get_user_cmd_complete(expand_T *xp, int idx) +char *get_user_cmd_complete(expand_T *xp, int idx) { if (idx >= (int)ARRAY_SIZE(command_complete)) { return NULL; } char *cmd_compl = get_command_complete(idx); if (cmd_compl == NULL) { - return (char_u *)""; + return ""; } else { - return (char_u *)cmd_compl; + return cmd_compl; } } @@ -7879,13 +7879,13 @@ static void ex_read(exarg_T *eap) if (check_fname() == FAIL) { // check for no file name return; } - i = readfile(curbuf->b_ffname, curbuf->b_fname, + i = readfile((char *)curbuf->b_ffname, (char *)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); } - i = readfile((char_u *)eap->arg, NULL, + i = readfile(eap->arg, NULL, eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false); } if (i != OK) { @@ -9332,17 +9332,17 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum case SPEC_AFILE: // file name for autocommand if (autocmd_fname != NULL - && !path_is_absolute(autocmd_fname) + && !path_is_absolute((char_u *)autocmd_fname) // For CmdlineEnter and related events, <afile> is not a path! #9348 - && !strequal("/", (char *)autocmd_fname)) { + && !strequal("/", autocmd_fname)) { // Still need to turn the fname into a full path. It was // postponed to avoid a delay when <afile> is not used. - result = FullName_save((char *)autocmd_fname, false); + result = FullName_save(autocmd_fname, false); // Copy into `autocmd_fname`, don't reassign it. #8165 STRLCPY(autocmd_fname, result, MAXPATHL); xfree(result); } - result = (char *)autocmd_fname; + result = autocmd_fname; if (result == NULL) { *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); return NULL; @@ -9360,7 +9360,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum break; case SPEC_AMATCH: // match name for autocommand - result = (char *)autocmd_match; + result = autocmd_match; if (result == NULL) { *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); return NULL; @@ -9368,7 +9368,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum break; case SPEC_SFILE: // file name for ":so" command - result = (char *)sourcing_name; + result = sourcing_name; if (result == NULL) { *errormsg = _("E498: no :source file name to substitute for \"<sfile>\""); return NULL; @@ -9417,7 +9417,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum if (src[*usedlen] == '<') { (*usedlen)++; if ((s = (char *)STRRCHR(result, '.')) != NULL - && (char_u *)s >= path_tail((char_u *)result)) { + && s >= path_tail(result)) { resultlen = (size_t)(s - result); } } else if (!skip_mod) { @@ -9601,31 +9601,31 @@ static void ex_behave(exarg_T *eap) /// Function given to ExpandGeneric() to obtain the possible arguments of the /// ":behave {mswin,xterm}" command. -char_u *get_behave_arg(expand_T *xp, int idx) +char *get_behave_arg(expand_T *xp, int idx) { if (idx == 0) { - return (char_u *)"mswin"; + return "mswin"; } if (idx == 1) { - return (char_u *)"xterm"; + return "xterm"; } return NULL; } /// Function given to ExpandGeneric() to obtain the possible arguments of the /// ":messages {clear}" command. -char_u *get_messages_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) +char *get_messages_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) { if (idx == 0) { - return (char_u *)"clear"; + return "clear"; } return NULL; } -char_u *get_mapclear_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) +char *get_mapclear_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) { if (idx == 0) { - return (char_u *)"<buffer>"; + return "<buffer>"; } return NULL; } diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 976a19300b..46f3a31120 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -479,7 +479,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname) } excp->type = type; - excp->throw_name = (char *)vim_strsave(sourcing_name == NULL ? (char_u *)"" : sourcing_name); + excp->throw_name = xstrdup(sourcing_name == NULL ? "" : sourcing_name); excp->throw_lnum = sourcing_lnum; if (p_verbose >= 13 || debug_break_level > 0) { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 00bb0499b0..d4665ac031 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -292,7 +292,7 @@ static void init_incsearch_state(incsearch_state_T *s) /// Given to ExpandGeneric() to obtain all available heathcheck names. /// @param[in] idx Index of the healthcheck item. /// @param[in] xp Not used. -static char_u *get_healthcheck_names(expand_T *xp, int idx) +static char *get_healthcheck_names(expand_T *xp, int idx) { // Generate the first time or on new prompt. if (healthchecks.last_gen == 0 || healthchecks.last_gen != last_prompt_id) { @@ -310,8 +310,8 @@ static char_u *get_healthcheck_names(expand_T *xp, int idx) // Tracked to regenerate items on next prompt. healthchecks.last_gen = last_prompt_id; } - return idx < - healthchecks.names.ga_len ? ((char_u **)(healthchecks.names.ga_data))[idx] : NULL; + return idx < healthchecks.names.ga_len + ? ((char **)(healthchecks.names.ga_data))[idx] : NULL; } /// Transform healthcheck file path into it's name. @@ -325,7 +325,7 @@ static void get_healthcheck_cb(char *path, void *cookie) struct healthchecks_cookie *hcookie = (struct healthchecks_cookie *)cookie; char *pattern; char *sub = "\\1"; - char_u *res; + char *res; if (hcookie->is_lua) { // Lua: transform "../lua/vim/lsp/health.lua" into "vim.lsp" @@ -335,16 +335,16 @@ static void get_healthcheck_cb(char *path, void *cookie) pattern = ".*[\\/]\\([^\\/]*\\)\\.vim$"; } - res = (char_u *)do_string_sub(path, pattern, sub, NULL, "g"); + res = do_string_sub(path, pattern, sub, NULL, "g"); if (hcookie->is_lua && res != NULL) { // Replace slashes with dots as represented by the healthcheck plugin. - char_u *ares = (char_u *)do_string_sub((char *)res, "[\\/]", ".", NULL, "g"); + char *ares = do_string_sub(res, "[\\/]", ".", NULL, "g"); xfree(res); res = ares; } if (res != NULL) { - GA_APPEND(char_u *, hcookie->names, res); + GA_APPEND(char *, hcookie->names, res); } } } @@ -355,12 +355,12 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s int *skiplen, int *patlen) FUNC_ATTR_NONNULL_ALL { - char_u *cmd; + char *cmd; cmdmod_T save_cmdmod = cmdmod; - char_u *p; + char *p; bool delim_optional = false; int delim; - char_u *end; + char *end; char *dummy; exarg_T ea; pos_T save_cursor; @@ -396,14 +396,14 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s parse_command_modifiers(&ea, &dummy, true); cmdmod = save_cmdmod; - cmd = (char_u *)skip_range(ea.cmd, NULL); + cmd = skip_range(ea.cmd, NULL); if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) { goto theend; } // Skip over "substitute" to find the pattern separator. for (p = cmd; ASCII_ISALPHA(*p); p++) {} - if (*skipwhite((char *)p) == NUL) { + if (*skipwhite(p) == NUL) { goto theend; } @@ -419,9 +419,9 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s } else if (STRNCMP(cmd, "sort", MAX(p - cmd, 3)) == 0) { // skip over ! and flags if (*p == '!') { - p = (char_u *)skipwhite((char *)p + 1); + p = skipwhite(p + 1); } - while (ASCII_ISALPHA(*(p = (char_u *)skipwhite((char *)p)))) { + while (ASCII_ISALPHA(*(p = skipwhite((char *)p)))) { p++; } if (*p == NUL) { @@ -435,7 +435,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s // skip over "!/". if (*p == '!') { p++; - if (*skipwhite((char *)p) == NUL) { + if (*skipwhite(p) == NUL) { goto theend; } } @@ -446,10 +446,10 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s goto theend; } - p = (char_u *)skipwhite((char *)p); + p = skipwhite(p); delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++; *search_delim = delim; - end = skip_regexp(p, delim, p_magic, NULL); + end = (char *)skip_regexp((char_u *)p, delim, p_magic, NULL); use_last_pat = end == p && *end == delim; if (end == p && !use_last_pat) { @@ -458,11 +458,11 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s // Don't do 'hlsearch' highlighting if the pattern matches everything. if (!use_last_pat) { - char_u c = *end; + char c = *end; int empty; *end = NUL; - empty = empty_pattern(p); + empty = empty_pattern((char_u *)p); *end = c; if (empty) { goto theend; @@ -470,7 +470,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s } // found a non-empty pattern or // - *skiplen = (int)(p - ccline.cmdbuff); + *skiplen = (int)((char_u *)p - ccline.cmdbuff); *patlen = (int)(end - p); // parse the address range @@ -2601,14 +2601,14 @@ static void correct_screencol(int idx, int cells, int *col) /// /// @param c normally ':', NUL for ":append" /// @param indent indent for inside conditionals -char_u *getexline(int c, void *cookie, int indent, bool do_concat) +char *getexline(int c, void *cookie, int indent, bool do_concat) { // When executing a register, remove ':' that's in front of each line. if (exec_from_reg && vpeekc() == ':') { (void)vgetc(); } - return getcmdline(c, 1L, indent, do_concat); + return (char *)getcmdline(c, 1L, indent, do_concat); } bool cmdline_overstrike(void) @@ -2675,7 +2675,7 @@ static void realloc_cmdbuff(int len) } } -static char_u *arshape_buf = NULL; +static char *arshape_buf = NULL; #if defined(EXITFREE) void free_arshape_buf(void) @@ -3073,11 +3073,11 @@ static void draw_cmdline(int start, int len) u8c = arabic_shape(u8c, NULL, &u8cc[0], pc, pc1, nc); - newlen += utf_char2bytes(u8c, (char *)arshape_buf + newlen); + newlen += utf_char2bytes(u8c, arshape_buf + newlen); if (u8cc[0] != 0) { - newlen += utf_char2bytes(u8cc[0], (char *)arshape_buf + newlen); + newlen += utf_char2bytes(u8cc[0], arshape_buf + newlen); if (u8cc[1] != 0) { - newlen += utf_char2bytes(u8cc[1], (char *)arshape_buf + newlen); + newlen += utf_char2bytes(u8cc[1], arshape_buf + newlen); } } } else { @@ -3087,7 +3087,7 @@ static void draw_cmdline(int start, int len) } } - msg_outtrans_len(arshape_buf, newlen); + msg_outtrans_len((char_u *)arshape_buf, newlen); } else { draw_cmdline_no_arabicshape: if (kv_size(ccline.last_colors.colors)) { @@ -4490,7 +4490,7 @@ static int expand_showtail(expand_T *xp) return FALSE; } - end = path_tail((char_u *)xp->xp_pattern); + end = (char_u *)path_tail(xp->xp_pattern); if (end == (char_u *)xp->xp_pattern) { // there is no path separator return false; } @@ -4617,7 +4617,7 @@ char_u *addstar(char_u *fname, size_t len, int context) * ` could be anywhere in the file name. * When the name ends in '$' don't add a star, remove the '$'. */ - tail = path_tail(retval); + tail = (char_u *)path_tail((char *)retval); ends_in_star = (len > 0 && retval[len - 1] == '*'); #ifndef BACKSLASH_IN_FILENAME for (ssize_t k = (ssize_t)len - 2; k >= 0; k--) { @@ -4833,7 +4833,7 @@ static void cleanup_help_tags(int num_file, char_u **file) } } -typedef char_u *(*ExpandFunc)(expand_T *, int); +typedef char *(*ExpandFunc)(expand_T *, int); /// Do the expansion based on xp->xp_context and "pat". /// @@ -5098,8 +5098,8 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha char_u *str; // count the number of matching names - for (i = 0;; ++i) { - str = (*func)(xp, i); + for (i = 0;; i++) { + str = (char_u *)(*func)(xp, i); if (str == NULL) { // end of list break; } @@ -5120,7 +5120,7 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha // copy the matching names into allocated memory count = 0; for (i = 0;; i++) { - str = (*func)(xp, i); + str = (char_u *)(*func)(xp, i); if (str == NULL) { // End of list. break; } @@ -5570,7 +5570,7 @@ static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file) for (int i = 0; i < ga.ga_len; i++) { char_u *match = ((char_u **)ga.ga_data)[i]; - s = path_tail(match); + s = (char_u *)path_tail((char *)match); memmove(match, s, STRLEN(s) + 1); } @@ -5677,7 +5677,7 @@ static char *(history_names[]) = * Function given to ExpandGeneric() to obtain the possible first * arguments of the ":history command. */ -static char_u *get_history_arg(expand_T *xp, int idx) +static char *get_history_arg(expand_T *xp, int idx) { static char_u compl[2] = { NUL, NUL }; char *short_names = ":=@>?/"; @@ -5686,13 +5686,13 @@ static char_u *get_history_arg(expand_T *xp, int idx) if (idx < short_names_count) { compl[0] = (char_u)short_names[idx]; - return compl; + return (char *)compl; } if (idx < short_names_count + history_name_count) { - return (char_u *)history_names[idx - short_names_count]; + return history_names[idx - short_names_count]; } if (idx == short_names_count + history_name_count) { - return (char_u *)"all"; + return "all"; } return NULL; } @@ -5959,9 +5959,9 @@ char_u *get_cmdline_completion(void) if (p != NULL && p->xpc != NULL) { set_expand_context(p->xpc); - char_u *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context); + char *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context); if (cmd_compl != NULL) { - return vim_strsave(cmd_compl); + return vim_strsave((char_u *)cmd_compl); } } @@ -6641,8 +6641,8 @@ char *script_get(exarg_T *const eap, size_t *const lenp) const char *const end_pattern = (cmd[2] != NUL ? (const char *)skipwhite(cmd + 2) : "."); for (;;) { - char *const theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : - NUL, eap->cookie, 0, true); + char *const theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL, + eap->cookie, 0, true); if (theline == NULL || strcmp(end_pattern, theline) == 0) { xfree(theline); diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index fe2bf958b5..5da9febe71 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -48,7 +48,7 @@ typedef enum { /// Number of history tables #define HIST_COUNT (HIST_DEBUG + 1) -typedef char_u *(*CompleteListItemGetter)(expand_T *, int); +typedef char *(*CompleteListItemGetter)(expand_T *, int); /// History entry definition typedef struct hist_entry { diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 1235087500..045f778e4c 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -930,7 +930,7 @@ void ex_mkrc(exarg_T *eap) viewFile = fname; using_vdir = true; } else if (*eap->arg != NUL) { - fname = (char *)eap->arg; + fname = eap->arg; } else if (eap->cmdidx == CMD_mkvimrc) { fname = VIMRC_FILE; } else if (eap->cmdidx == CMD_mksession) { diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 6a3acef91d..02db5ded75 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -298,7 +298,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le && (vim_ispathsep(path[1]) || path[1] == NUL) && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL) && rel_fname != NULL) { - size_t len = (size_t)(path_tail(rel_fname) - rel_fname); + size_t len = (size_t)((char_u *)path_tail((char *)rel_fname) - rel_fname); if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) { // Make the start dir an absolute path name. @@ -477,7 +477,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path); add_pathsep((char *)ff_expand_buffer); } else { - char_u *p = path_tail(search_ctx->ffsc_fix_path); + char_u *p = (char_u *)path_tail((char *)search_ctx->ffsc_fix_path); char_u *wc_path = NULL; char_u *temp = NULL; int len = 0; @@ -1481,7 +1481,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first && rel_fname != NULL && STRLEN(rel_fname) + l < MAXPATHL) { STRCPY(NameBuff, rel_fname); - STRCPY(path_tail(NameBuff), ff_file_to_find); + STRCPY(path_tail((char *)NameBuff), ff_file_to_find); l = STRLEN(NameBuff); } else { STRCPY(NameBuff, ff_file_to_find); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index c802920fa9..c412af0eaa 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -173,7 +173,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr) /// @param eap can be NULL! /// /// @return FAIL for failure, NOTDONE for directory (failure), or OK -int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_skip, +int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, linenr_T lines_to_read, exarg_T *eap, int flags, bool silent) { int fd = stdin_fd >= 0 ? stdin_fd : 0; @@ -189,10 +189,10 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski colnr_T read_buf_col = 0; // next char to read from this line char_u c; linenr_T lnum = from; - char_u *ptr = NULL; // pointer into read buffer - char_u *buffer = NULL; // read buffer - char_u *new_buffer = NULL; // init to shut up gcc - char_u *line_start = NULL; // init to shut up gcc + char *ptr = NULL; // pointer into read buffer + char *buffer = NULL; // read buffer + char *new_buffer = NULL; // init to shut up gcc + char *line_start = NULL; // init to shut up gcc int wasempty; // buffer was empty before reading colnr_T len; long size = 0; @@ -227,11 +227,11 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski int bad_char_behavior = BAD_REPLACE; // BAD_KEEP, BAD_DROP or character to // replace with - char_u *tmpname = NULL; // name of 'charconvert' output file + char *tmpname = NULL; // name of 'charconvert' output file int fio_flags = 0; - char_u *fenc; // fileencoding to use + char *fenc; // fileencoding to use bool fenc_alloced; // fenc_next is in allocated memory - char_u *fenc_next = NULL; // next item in 'fencs' or NULL + char *fenc_next = NULL; // next item in 'fencs' or NULL bool advance_fenc = false; long real_size = 0; #ifdef HAVE_ICONV @@ -241,12 +241,12 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski #endif bool converted = false; // true if conversion done bool notconverted = false; // true if conversion wanted but it wasn't possible - char_u conv_rest[CONV_RESTLEN]; + char conv_rest[CONV_RESTLEN]; int conv_restlen = 0; // nr of bytes in conv_rest[] pos_T orig_start; buf_T *old_curbuf; - char_u *old_b_ffname; - char_u *old_b_fname; + char *old_b_ffname; + char *old_b_fname; int using_b_ffname; int using_b_fname; static char *msg_is_a_directory = N_("is a directory"); @@ -266,7 +266,7 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski && fname != NULL && vim_strchr(p_cpo, CPO_FNAMER) != NULL && !(flags & READ_DUMMY)) { - if (set_rw_fname(fname, sfname) == FAIL) { + if (set_rw_fname((char_u *)fname, (char_u *)sfname) == FAIL) { return FAIL; } } @@ -276,11 +276,11 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski // executing nasty autocommands. Also check if "fname" and "sfname" // point to one of these values. old_curbuf = curbuf; - old_b_ffname = curbuf->b_ffname; - old_b_fname = curbuf->b_fname; - using_b_ffname = (fname == curbuf->b_ffname) - || (sfname == curbuf->b_ffname); - using_b_fname = (fname == curbuf->b_fname) || (sfname == curbuf->b_fname); + old_b_ffname = (char *)curbuf->b_ffname; + old_b_fname = (char *)curbuf->b_fname; + using_b_ffname = ((char_u *)fname == curbuf->b_ffname) + || ((char_u *)sfname == curbuf->b_ffname); + using_b_fname = ((char_u *)fname == curbuf->b_fname) || ((char_u *)sfname == curbuf->b_fname); // After reading a file the cursor line changes but we don't want to // display the line. @@ -347,7 +347,7 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski // If the name is too long we might crash further on, quit here. if (namelen >= MAXPATHL) { - filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0); + filemess(curbuf, (char_u *)fname, (char_u *)_("Illegal file name"), 0); msg_end(); msg_scroll = msg_save; return FAIL; @@ -356,9 +356,9 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski // If the name ends in a path separator, we can't open it. Check here, // because reading the file may actually work, but then creating the // swap file may destroy it! Reported on MS-DOS and Win 95. - if (after_pathsep((const char *)fname, (const char *)(fname + namelen))) { + if (after_pathsep(fname, fname + namelen)) { if (!silent) { - filemess(curbuf, fname, (char_u *)_(msg_is_a_directory), 0); + filemess(curbuf, (char_u *)fname, (char_u *)_(msg_is_a_directory), 0); } msg_end(); msg_scroll = msg_save; @@ -367,23 +367,23 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski } if (!read_buffer && !read_stdin && !read_fifo) { - perm = os_getperm((const char *)fname); + perm = os_getperm(fname); // On Unix it is possible to read a directory, so we have to // check for it before os_open(). if (perm >= 0 && !S_ISREG(perm) // not a regular file ... && !S_ISFIFO(perm) // ... or fifo && !S_ISSOCK(perm) // ... or socket #ifdef OPEN_CHR_FILES - && !(S_ISCHR(perm) && is_dev_fd_file(fname)) + && !(S_ISCHR(perm) && is_dev_fd_file((char_u *)fname)) // ... or a character special file named /dev/fd/<n> #endif ) { if (S_ISDIR(perm)) { if (!silent) { - filemess(curbuf, fname, (char_u *)_(msg_is_a_directory), 0); + filemess(curbuf, (char_u *)fname, (char_u *)_(msg_is_a_directory), 0); } } else { - filemess(curbuf, fname, (char_u *)_("is not a file"), 0); + filemess(curbuf, (char_u *)fname, (char_u *)_("is not a file"), 0); } msg_end(); msg_scroll = msg_save; @@ -407,7 +407,7 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski if (newfile && !read_stdin && !read_buffer && !read_fifo) { // Remember time of file. - if (os_fileinfo((char *)fname, &file_info)) { + if (os_fileinfo(fname, &file_info)) { buf_store_file_info(curbuf, &file_info); curbuf->b_mtime_read = curbuf->b_mtime; curbuf->b_mtime_read_ns = curbuf->b_mtime_ns; @@ -443,10 +443,10 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski bool file_readonly = false; if (!read_buffer && !read_stdin) { if (!newfile || readonlymode || !(perm & 0222) - || !os_file_is_writable((char *)fname)) { + || !os_file_is_writable(fname)) { file_readonly = true; } - fd = os_open((char *)fname, O_RDONLY, 0); + fd = os_open(fname, O_RDONLY, 0); } if (fd < 0) { // cannot open at all @@ -467,18 +467,18 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski // SwapExists autocommand may mess things up if (curbuf != old_curbuf || (using_b_ffname - && (old_b_ffname != curbuf->b_ffname)) + && ((char_u *)old_b_ffname != curbuf->b_ffname)) || (using_b_fname - && (old_b_fname != curbuf->b_fname))) { + && ((char_u *)old_b_fname != curbuf->b_fname))) { emsg(_(e_auchangedbuf)); return FAIL; } } if (!silent) { - if (dir_of_file_exists(fname)) { - filemess(curbuf, sfname, (char_u *)new_file_message(), 0); + if (dir_of_file_exists((char_u *)fname)) { + filemess(curbuf, (char_u *)sfname, (char_u *)new_file_message(), 0); } else { - filemess(curbuf, sfname, (char_u *)_("[New DIRECTORY]"), 0); + filemess(curbuf, (char_u *)sfname, (char_u *)_("[New DIRECTORY]"), 0); } } // Even though this is a new file, it might have been @@ -498,15 +498,16 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski } return OK; // a new file is not an error } else { - filemess(curbuf, sfname, (char_u *)( - (fd == UV_EFBIG) ? _("[File too big]") : + filemess(curbuf, (char_u *)sfname, (char_u *)((fd == UV_EFBIG) ? _("[File too big]") : #if defined(UNIX) && defined(EOVERFLOW) - // libuv only returns -errno in Unix and in Windows open() does not - // set EOVERFLOW - (fd == -EOVERFLOW) ? _("[File too big]") : + // libuv only returns -errno + // in Unix and in Windows + // open() does not set + // EOVERFLOW + (fd == -EOVERFLOW) ? _("[File too big]") : #endif - _("[Permission Denied]")), 0); - curbuf->b_p_ro = TRUE; // must use "w!" now + _("[Permission Denied]")), 0); + curbuf->b_p_ro = true; // must use "w!" now } return FAIL; @@ -538,8 +539,8 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski check_need_swap(newfile); if (!read_stdin && (curbuf != old_curbuf - || (using_b_ffname && (old_b_ffname != curbuf->b_ffname)) - || (using_b_fname && (old_b_fname != curbuf->b_fname)))) { + || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) + || (using_b_fname && ((char_u *)old_b_fname != curbuf->b_fname)))) { emsg(_(e_auchangedbuf)); if (!read_buffer) { close(fd); @@ -644,10 +645,10 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski * (cd for example) if it invalidates fname or sfname. */ if (!read_stdin && (curbuf != old_curbuf - || (using_b_ffname && (old_b_ffname != curbuf->b_ffname)) - || (using_b_fname && (old_b_fname != curbuf->b_fname)) - || (fd = os_open((char *)fname, O_RDONLY, 0)) < 0)) { - --no_wait_return; + || (using_b_ffname && ((char_u *)old_b_ffname != curbuf->b_ffname)) + || (using_b_fname && ((char_u *)old_b_fname != curbuf->b_fname)) + || (fd = os_open(fname, O_RDONLY, 0)) < 0)) { + no_wait_return--; msg_scroll = msg_save; if (fd < 0) { emsg(_("E200: *ReadPre autocommands made the file unreadable")); @@ -664,7 +665,7 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski if (!recoverymode && !filtering && !(flags & READ_DUMMY) && !silent) { if (!read_stdin && !read_buffer) { - filemess(curbuf, sfname, (char_u *)"", 0); + filemess(curbuf, (char_u *)sfname, (char_u *)"", 0); } } @@ -690,27 +691,27 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski * Decide which 'encoding' to use or use first. */ if (eap != NULL && eap->force_enc != 0) { - fenc = enc_canonize((char_u *)eap->cmd + eap->force_enc); + fenc = (char *)enc_canonize((char_u *)eap->cmd + eap->force_enc); fenc_alloced = true; keep_dest_enc = true; } else if (curbuf->b_p_bin) { - fenc = (char_u *)""; // binary: don't convert + fenc = ""; // binary: don't convert fenc_alloced = false; } else if (curbuf->b_help) { // Help files are either utf-8 or latin1. Try utf-8 first, if this // fails it must be latin1. // It is needed when the first line contains non-ASCII characters. // That is only in *.??x files. - fenc_next = (char_u *)"latin1"; - fenc = (char_u *)"utf-8"; + fenc_next = "latin1"; + fenc = "utf-8"; fenc_alloced = false; } else if (*p_fencs == NUL) { - fenc = curbuf->b_p_fenc; // use format from buffer + fenc = (char *)curbuf->b_p_fenc; // use format from buffer fenc_alloced = false; } else { - fenc_next = p_fencs; // try items in 'fileencodings' - fenc = next_fenc(&fenc_next, &fenc_alloced); + fenc_next = (char *)p_fencs; // try items in 'fileencodings' + fenc = (char *)next_fenc((char_u **)&fenc_next, &fenc_alloced); } /* @@ -797,21 +798,21 @@ retry: if (fenc_alloced) { xfree(fenc); } - fenc = (char_u *)""; + fenc = ""; fenc_alloced = false; } else { if (fenc_alloced) { xfree(fenc); } if (fenc_next != NULL) { - fenc = next_fenc(&fenc_next, &fenc_alloced); + fenc = (char *)next_fenc((char_u **)&fenc_next, &fenc_alloced); } else { - fenc = (char_u *)""; + fenc = ""; fenc_alloced = false; } } if (tmpname != NULL) { - os_remove((char *)tmpname); // delete converted file + os_remove(tmpname); // delete converted file XFREE_CLEAR(tmpname); } } @@ -821,7 +822,7 @@ retry: * from 'encoding' or 'encoding' is UTF-16, UCS-2 or UCS-4. */ fio_flags = 0; - converted = need_conversion(fenc); + converted = need_conversion((char_u *)fenc); if (converted) { // "ucs-bom" means we need to check the first bytes of the file // for a BOM. @@ -835,7 +836,7 @@ retry: // appears not to handle this correctly. This works just like // conversion to UTF-8 except how the resulting character is put in // the buffer. - fio_flags = get_fio_flags(fenc); + fio_flags = get_fio_flags((char_u *)fenc); } @@ -843,7 +844,7 @@ retry: // Try using iconv() if we can't convert internally. if (fio_flags == 0 && !did_iconv) { - iconv_fd = (iconv_t)my_iconv_open((char_u *)"utf-8", fenc); + iconv_fd = (iconv_t)my_iconv_open((char_u *)"utf-8", (char_u *)fenc); } #endif @@ -863,7 +864,7 @@ retry: // Skip conversion when it's already done (retry for wrong // "fileformat"). if (tmpname == NULL) { - tmpname = readfile_charconvert(fname, fenc, &fd); + tmpname = (char *)readfile_charconvert((char_u *)fname, (char_u *)fenc, &fd); if (tmpname == NULL) { // Conversion failed. Try another one. advance_fenc = true; @@ -1128,8 +1129,8 @@ retry: if (size < 2 || curbuf->b_p_bin) { ccname = NULL; } else { - ccname = check_for_bom(ptr, size, &blen, - fio_flags == FIO_UCSBOM ? FIO_ALL : get_fio_flags(fenc)); + ccname = check_for_bom((char_u *)ptr, size, &blen, + fio_flags == FIO_UCSBOM ? FIO_ALL : get_fio_flags((char_u *)fenc)); } if (ccname != NULL) { // Remove BOM from the text @@ -1151,7 +1152,7 @@ retry: if (fenc_alloced) { xfree(fenc); } - fenc = ccname; + fenc = (char *)ccname; fenc_alloced = false; } // retry reading without getting new bytes or rewinding @@ -1182,10 +1183,10 @@ retry: size_t from_size; size_t to_size; - fromp = (char *)ptr; + fromp = ptr; from_size = size; ptr += size; - top = (char *)ptr; + top = ptr; to_size = real_size - size; /* @@ -1201,8 +1202,7 @@ retry: goto rewind_retry; } if (conv_error == 0) { - conv_error = readfile_linenr(linecnt, - ptr, (char_u *)top); + conv_error = readfile_linenr(linecnt, (char_u *)ptr, (char_u *)top); } // Deal with a bad byte and continue with the next. @@ -1227,14 +1227,14 @@ retry: // move the linerest to before the converted characters line_start = ptr - linerest; memmove(line_start, buffer, (size_t)linerest); - size = ((char_u *)top - ptr); + size = (top - ptr); } #endif if (fio_flags != 0) { unsigned int u8c; - char_u *dest; - char_u *tail = NULL; + char *dest; + char *tail = NULL; // Convert Unicode or Latin1 to UTF-8. // Go from end to start through the buffer, because the number @@ -1243,7 +1243,7 @@ retry: // to after the next character to convert. dest = ptr + real_size; if (fio_flags == FIO_LATIN1 || fio_flags == FIO_UTF8) { - p = ptr + size; + p = (uint8_t *)ptr + size; if (fio_flags == FIO_UTF8) { // Check for a trailing incomplete UTF-8 sequence tail = ptr + size - 1; @@ -1253,16 +1253,16 @@ retry: if (tail + utf_byte2len(*tail) <= ptr + size) { tail = NULL; } else { - p = tail; + p = (uint8_t *)tail; } } } else if (fio_flags & (FIO_UCS2 | FIO_UTF16)) { // Check for a trailing byte - p = ptr + (size & ~1); + p = (uint8_t *)ptr + (size & ~1); if (size & 1) { - tail = p; + tail = (char *)p; } - if ((fio_flags & FIO_UTF16) && p > ptr) { + if ((fio_flags & FIO_UTF16) && p > (uint8_t *)ptr) { // Check for a trailing leading word if (fio_flags & FIO_ENDIAN_L) { u8c = (*--p << 8); @@ -1272,16 +1272,16 @@ retry: u8c += (*--p << 8); } if (u8c >= 0xd800 && u8c <= 0xdbff) { - tail = p; + tail = (char *)p; } else { p += 2; } } } else { // FIO_UCS4 // Check for trailing 1, 2 or 3 bytes - p = ptr + (size & ~3); + p = (uint8_t *)ptr + (size & ~3); if (size & 3) { - tail = p; + tail = (char *)p; } } @@ -1294,7 +1294,7 @@ retry: } - while (p > ptr) { + while (p > (uint8_t *)ptr) { if (fio_flags & FIO_LATIN1) { u8c = *--p; } else if (fio_flags & (FIO_UCS2 | FIO_UTF16)) { @@ -1309,14 +1309,13 @@ retry: && u8c >= 0xdc00 && u8c <= 0xdfff) { int u16c; - if (p == ptr) { + if (p == (uint8_t *)ptr) { // Missing leading word. if (can_retry) { goto rewind_retry; } if (conv_error == 0) { - conv_error = readfile_linenr(linecnt, - ptr, p); + conv_error = readfile_linenr(linecnt, (char_u *)ptr, p); } if (bad_char_behavior == BAD_DROP) { continue; @@ -1344,8 +1343,7 @@ retry: goto rewind_retry; } if (conv_error == 0) { - conv_error = readfile_linenr(linecnt, - ptr, p); + conv_error = readfile_linenr(linecnt, (char_u *)ptr, p); } if (bad_char_behavior == BAD_DROP) { continue; @@ -1375,7 +1373,7 @@ retry: if (*--p < 0x80) { u8c = *p; } else { - len = utf_head_off(ptr, p); + len = utf_head_off((char_u *)ptr, p); p -= len; u8c = utf_ptr2char((char *)p); if (len == 0) { @@ -1386,8 +1384,7 @@ retry: goto rewind_retry; } if (conv_error == 0) { - conv_error = readfile_linenr(linecnt, - ptr, p); + conv_error = readfile_linenr(linecnt, (char_u *)ptr, p); } if (bad_char_behavior == BAD_DROP) { continue; @@ -1401,7 +1398,7 @@ retry: assert(u8c <= INT_MAX); // produce UTF-8 dest -= utf_char2len((int)u8c); - (void)utf_char2bytes((int)u8c, (char *)dest); + (void)utf_char2bytes((int)u8c, dest); } // move the linerest to before the converted characters @@ -1413,8 +1410,8 @@ retry: bool incomplete_tail = false; // Reading UTF-8: Check if the bytes are valid UTF-8. - for (p = ptr;; p++) { - int todo = (int)((ptr + size) - p); + for (p = (uint8_t *)ptr;; p++) { + int todo = (int)(((uint8_t *)ptr + size) - p); int l; if (todo <= 0) { @@ -1431,13 +1428,13 @@ retry: // a truncated file is more likely, or attempting // to read the rest of an incomplete sequence when // we have already done so. - if (p > ptr || filesize > 0) { + if (p > (uint8_t *)ptr || filesize > 0) { incomplete_tail = true; } // Incomplete byte sequence, move it to conv_rest[] // and try to read the rest of it, unless we've // already done so. - if (p > ptr) { + if (p > (uint8_t *)ptr) { conv_restlen = todo; memmove(conv_rest, p, conv_restlen); size -= conv_restlen; @@ -1454,12 +1451,12 @@ retry: #ifdef HAVE_ICONV // When we did a conversion report an error. if (iconv_fd != (iconv_t)-1 && conv_error == 0) { - conv_error = readfile_linenr(linecnt, ptr, p); + conv_error = readfile_linenr(linecnt, (char_u *)ptr, p); } #endif // Remember the first linenr with an illegal byte if (conv_error == 0 && illegal_byte == 0) { - illegal_byte = readfile_linenr(linecnt, ptr, p); + illegal_byte = readfile_linenr(linecnt, (char_u *)ptr, p); } // Drop, keep or replace the bad byte. @@ -1475,7 +1472,7 @@ retry: } } } - if (p < ptr + size && !incomplete_tail) { + if (p < (uint8_t *)ptr + size && !incomplete_tail) { // Detected a UTF-8 error. rewind_retry: // Retry reading with another conversion. @@ -1509,10 +1506,10 @@ rewind_retry: try_mac = 1; } - for (p = ptr; p < ptr + size; ++p) { + for (p = (uint8_t *)ptr; p < (uint8_t *)ptr + size; p++) { if (*p == NL) { if (!try_unix - || (try_dos && p > ptr && p[-1] == CAR)) { + || (try_dos && p > (uint8_t *)ptr && p[-1] == CAR)) { fileformat = EOL_DOS; } else { fileformat = EOL_UNIX; @@ -1528,9 +1525,9 @@ rewind_retry: // Need to reset the counters when retrying fenc. try_mac = 1; try_unix = 1; - for (; p >= ptr && *p != CAR; p--) {} - if (p >= ptr) { - for (p = ptr; p < ptr + size; ++p) { + for (; p >= (uint8_t *)ptr && *p != CAR; p--) {} + if (p >= (uint8_t *)ptr) { + for (p = (uint8_t *)ptr; p < (uint8_t *)ptr + size; p++) { if (*p == NL) { try_unix++; } else if (*p == CAR) { @@ -1584,12 +1581,12 @@ rewind_retry: if (skip_count == 0) { *ptr = NUL; // end of line len = (colnr_T)(ptr - line_start + 1); - if (ml_append(lnum, (char *)line_start, len, newfile) == FAIL) { + if (ml_append(lnum, line_start, len, newfile) == FAIL) { error = true; break; } if (read_undo_file) { - sha256_update(&sha_ctx, line_start, len); + sha256_update(&sha_ctx, (char_u *)line_start, len); } ++lnum; if (--read_count == 0) { @@ -1640,12 +1637,12 @@ rewind_retry: ff_error = EOL_DOS; } } - if (ml_append(lnum, (char *)line_start, len, newfile) == FAIL) { + if (ml_append(lnum, line_start, len, newfile) == FAIL) { error = true; break; } if (read_undo_file) { - sha256_update(&sha_ctx, line_start, len); + sha256_update(&sha_ctx, (char_u *)line_start, len); } ++lnum; if (--read_count == 0) { @@ -1688,11 +1685,11 @@ failed: } *ptr = NUL; len = (colnr_T)(ptr - line_start + 1); - if (ml_append(lnum, (char *)line_start, len, newfile) == FAIL) { + if (ml_append(lnum, line_start, len, newfile) == FAIL) { error = true; } else { if (read_undo_file) { - sha256_update(&sha_ctx, line_start, len); + sha256_update(&sha_ctx, (char_u *)line_start, len); } read_no_eol_lnum = ++lnum; } @@ -1703,7 +1700,7 @@ failed: save_file_ff(curbuf); // If editing a new file: set 'fenc' for the current buffer. // Also for ":read ++edit file". - set_string_option_direct("fenc", -1, fenc, OPT_FREE | OPT_LOCAL, 0); + set_string_option_direct("fenc", -1, (char_u *)fenc, OPT_FREE | OPT_LOCAL, 0); } if (fenc_alloced) { xfree(fenc); @@ -1738,7 +1735,7 @@ failed: } if (tmpname != NULL) { - os_remove((char *)tmpname); // delete converted file + os_remove(tmpname); // delete converted file xfree(tmpname); } --no_wait_return; // may wait for return now @@ -1783,7 +1780,7 @@ failed: if (got_int) { if (!(flags & READ_DUMMY)) { - filemess(curbuf, sfname, (char_u *)_(e_interr), 0); + filemess(curbuf, (char_u *)sfname, (char_u *)_(e_interr), 0); if (newfile) { curbuf->b_p_ro = TRUE; // must use "w!" now } @@ -1932,7 +1929,7 @@ failed: char_u hash[UNDO_HASH_SIZE]; sha256_finish(&sha_ctx, hash); - u_read_undo(NULL, hash, fname); + u_read_undo(NULL, hash, (char_u *)fname); } if (!read_stdin && !read_fifo && (!read_buffer || sfname != NULL)) { @@ -1993,7 +1990,7 @@ bool is_dev_fd_file(char_u *fname) { return STRNCMP(fname, "/dev/fd/", 8) == 0 && ascii_isdigit(fname[8]) - && *skipdigits(fname + 9) == NUL + && *skipdigits((char *)fname + 9) == NUL && (fname[9] != NUL || (fname[8] != '0' && fname[8] != '1' && fname[8] != '2')); } @@ -2188,18 +2185,18 @@ char *new_file_message(void) /// @param append append to the file /// /// @return FAIL for failure, OK otherwise -int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, +int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering) { int fd; - char_u *backup = NULL; - int backup_copy = FALSE; // copy the original file? + char *backup = NULL; + int backup_copy = false; // copy the original file? int dobackup; - char_u *ffname; - char_u *wfname = NULL; // name of file to write to - char_u *s; - char_u *ptr; - char_u c; + char *ffname; + char *wfname = NULL; // name of file to write to + char *s; + char *ptr; + char c; int len; linenr_T lnum; long nchars; @@ -2213,9 +2210,9 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ char *errmsg = NULL; int errmsgarg = 0; bool errmsg_allocated = false; - char_u *buffer; - char_u smallbuf[SMBUFSIZE]; - char_u *backup_ext; + char *buffer; + char smallbuf[SMBUFSIZE]; + char *backup_ext; int bufsize; long perm; // file permissions int retval = OK; @@ -2238,10 +2235,10 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ int fileformat; int write_bin; struct bw_info write_info; // info for buf_write_bytes() - int converted = FALSE; - int notconverted = FALSE; - char_u *fenc; // effective 'fileencoding' - char_u *fenc_tofree = NULL; // allocated "fenc" + int converted = false; + int notconverted = false; + char *fenc; // effective 'fileencoding' + char *fenc_tofree = NULL; // allocated "fenc" #ifdef HAS_BW_FLAGS int wb_flags = 0; #endif @@ -2307,7 +2304,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ && !filtering && (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL) && vim_strchr(p_cpo, CPO_FNAMEW) != NULL) { - if (set_rw_fname(fname, sfname) == FAIL) { + if (set_rw_fname((char_u *)fname, (char_u *)sfname) == FAIL) { return FAIL; } buf = curbuf; // just in case autocmds made "buf" invalid @@ -2358,17 +2355,17 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ * Set curbuf to the buffer to be written. * Careful: The autocommands may call buf_write() recursively! */ - if (ffname == buf->b_ffname) { - buf_ffname = TRUE; + if ((char_u *)ffname == buf->b_ffname) { + buf_ffname = true; } - if (sfname == buf->b_sfname) { - buf_sfname = TRUE; + if ((char_u *)sfname == buf->b_sfname) { + buf_sfname = true; } - if (fname == buf->b_ffname) { - buf_fname_f = TRUE; + if ((char_u *)fname == buf->b_ffname) { + buf_fname_f = true; } - if (fname == buf->b_sfname) { - buf_fname_s = TRUE; + if ((char_u *)fname == buf->b_sfname) { + buf_fname_s = true; } // Set curwin/curbuf to buf and save a few things. @@ -2508,16 +2505,16 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ * be kept in fname, ffname and sfname. */ if (buf_ffname) { - ffname = buf->b_ffname; + ffname = (char *)buf->b_ffname; } if (buf_sfname) { - sfname = buf->b_sfname; + sfname = (char *)buf->b_sfname; } if (buf_fname_f) { - fname = buf->b_ffname; + fname = (char *)buf->b_ffname; } if (buf_fname_s) { - fname = buf->b_sfname; + fname = (char *)buf->b_sfname; } } @@ -2535,9 +2532,9 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ if (!filtering) { filemess(buf, #ifndef UNIX - sfname, + (char_u *)sfname, #else - fname, + (char_u *)fname, #endif (char_u *)"", 0); // show that we are busy } @@ -2559,8 +2556,8 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ FileInfo file_info_old; #if defined(UNIX) perm = -1; - if (!os_fileinfo((char *)fname, &file_info_old)) { - newfile = TRUE; + if (!os_fileinfo(fname, &file_info_old)) { + newfile = true; } else { perm = file_info_old.stat.st_mode; if (!S_ISREG(file_info_old.stat.st_mode)) { // not a file @@ -2568,7 +2565,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ SET_ERRMSG_NUM("E502", _("is a directory")); goto fail; } - if (os_nodetype((char *)fname) != NODE_WRITABLE) { + if (os_nodetype(fname) != NODE_WRITABLE) { SET_ERRMSG_NUM("E503", _("is not a file or writable device")); goto fail; } @@ -2609,7 +2606,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ * Check if the file is really writable (when renaming the file to * make a backup we won't discover it later). */ - file_readonly = !os_file_is_writable((char *)fname); + file_readonly = !os_file_is_writable(fname); if (!forceit && file_readonly) { if (vim_strchr(p_cpo, CPO_FWRITE) != NULL) { @@ -2636,7 +2633,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ * For systems that support ACL: get the ACL from the original file. */ if (!newfile) { - acl = mch_get_acl(fname); + acl = mch_get_acl((char_u *)fname); } #endif @@ -2644,8 +2641,8 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ * If 'backupskip' is not empty, don't make a backup for some files. */ dobackup = (p_wb || p_bk || *p_pm != NUL); - if (dobackup && *p_bsk != NUL && match_file_list(p_bsk, sfname, ffname)) { - dobackup = FALSE; + if (dobackup && *p_bsk != NUL && match_file_list(p_bsk, (char_u *)sfname, (char_u *)ffname)) { + dobackup = false; } /* @@ -2683,7 +2680,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ * - we don't have write permission in the directory */ if (os_fileinfo_hardlinks(&file_info_old) > 1 - || !os_fileinfo_link((char *)fname, &file_info) + || !os_fileinfo_link(fname, &file_info) || !os_fileinfo_id_equal(&file_info, &file_info_old)) { backup_copy = TRUE; } else { @@ -2695,7 +2692,9 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ */ STRCPY(IObuff, fname); for (i = 4913;; i += 123) { - sprintf((char *)path_tail(IObuff), "%d", i); + char *tail = path_tail((char *)IObuff); + size_t size = (char_u *)tail - IObuff; + snprintf(tail, IOSIZE - size, "%d", i); if (!os_fileinfo_link((char *)IObuff, &file_info)) { break; } @@ -2727,7 +2726,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ */ if ((bkc & BKC_BREAKSYMLINK) || (bkc & BKC_BREAKHARDLINK)) { #ifdef UNIX - bool file_info_link_ok = os_fileinfo_link((char *)fname, &file_info); + bool file_info_link_ok = os_fileinfo_link(fname, &file_info); // Symlinks. if ((bkc & BKC_BREAKSYMLINK) @@ -2748,17 +2747,17 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ // make sure we have a valid backup extension to use if (*p_bex == NUL) { - backup_ext = (char_u *)".bak"; + backup_ext = ".bak"; } else { - backup_ext = p_bex; + backup_ext = (char *)p_bex; } if (backup_copy) { - char_u *wp; + char *wp; int some_error = false; - char_u *dirp; - char_u *rootname; - char_u *p; + char *dirp; + char *rootname; + char *p; /* * Try to make the backup in each directory in the 'bdir' option. @@ -2772,14 +2771,14 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ * For these reasons, the existing writable file must be truncated * and reused. Creation of a backup COPY will be attempted. */ - dirp = p_bdir; + dirp = (char *)p_bdir; while (*dirp) { /* * Isolate one directory name, using an entry in 'bdir'. */ - size_t dir_len = copy_option_part(&dirp, IObuff, IOSIZE, ","); - p = IObuff + dir_len; - bool trailing_pathseps = after_pathsep((char *)IObuff, (char *)p) && p[-1] == p[-2]; + size_t dir_len = copy_option_part((char_u **)&dirp, IObuff, IOSIZE, ","); + p = (char *)IObuff + dir_len; + bool trailing_pathseps = after_pathsep((char *)IObuff, p) && p[-1] == p[-2]; if (trailing_pathseps) { IObuff[dir_len - 2] = NUL; } @@ -2794,15 +2793,14 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ } if (trailing_pathseps) { // Ends with '//', Use Full path - if ((p = (char_u *)make_percent_swname((char *)IObuff, (char *)fname)) + if ((p = make_percent_swname((char *)IObuff, fname)) != NULL) { - backup = (char_u *)modname((char *)p, (char *)backup_ext, - no_prepend_dot); + backup = modname(p, backup_ext, no_prepend_dot); xfree(p); } } - rootname = get_file_in_dir(fname, IObuff); + rootname = (char *)get_file_in_dir((char_u *)fname, IObuff); if (rootname == NULL) { some_error = TRUE; // out of memory goto nobackup; @@ -2814,8 +2812,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ // Make the backup file name. // if (backup == NULL) { - backup = (char_u *)modname((char *)rootname, (char *)backup_ext, - no_prepend_dot); + backup = modname(rootname, backup_ext, no_prepend_dot); } if (backup == NULL) { @@ -2827,7 +2824,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ /* * Check if backup file already exists. */ - if (os_fileinfo((char *)backup, &file_info_new)) { + if (os_fileinfo(backup, &file_info_new)) { if (os_fileinfo_id_equal(&file_info_new, &file_info_old)) { // // Backup file is same as original file. @@ -2846,9 +2843,8 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ wp = backup; } *wp = 'z'; - while (*wp > 'a' - && os_fileinfo((char *)backup, &file_info_new)) { - --*wp; + while (*wp > 'a' && os_fileinfo(backup, &file_info_new)) { + (*wp)--; } // They all exist??? Must be something wrong. if (*wp == 'a') { @@ -2864,7 +2860,7 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ */ if (backup != NULL) { // remove old backup, if present - os_remove((char *)backup); + os_remove(backup); // set file protection same as original file, but // strip s-bit. @@ -2877,26 +2873,26 @@ int buf_write(buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_ // protection bits for others. // if (file_info_new.stat.st_gid != file_info_old.stat.st_gid - && os_chown((char *)backup, -1, file_info_old.stat.st_gid) != 0) { + && os_chown(backup, -1, file_info_old.stat.st_gid) != 0) { os_setperm((const char *)backup, (perm & 0707) | ((perm & 07) << 3)); } #endif // copy the file - if (os_copy((char *)fname, (char *)backup, UV_FS_COPYFILE_FICLONE) + if (os_copy(fname, backup, UV_FS_COPYFILE_FICLONE) != 0) { SET_ERRMSG(_("E506: Can't write to backup file " "(add ! to override)")); } #ifdef UNIX - os_file_settime((char *)backup, + os_file_settime(backup, file_info_old.stat.st_atim.tv_sec, file_info_old.stat.st_mtim.tv_sec); #endif #ifdef HAVE_ACL - mch_set_acl(backup, acl); + mch_set_acl((char_u *)backup, acl); #endif break; } @@ -2913,9 +2909,9 @@ nobackup: } SET_ERRMSG(NULL); } else { - char_u *dirp; - char_u *p; - char_u *rootname; + char *dirp; + char *p; + char *rootname; /* * Make a backup by renaming the original file. @@ -2936,14 +2932,14 @@ nobackup: * path/fo.o.h.bak Try all directories in 'backupdir', first one * that works is used. */ - dirp = p_bdir; + dirp = (char *)p_bdir; while (*dirp) { /* * Isolate one directory name and make the backup file name. */ - size_t dir_len = copy_option_part(&dirp, IObuff, IOSIZE, ","); - p = IObuff + dir_len; - bool trailing_pathseps = after_pathsep((char *)IObuff, (char *)p) && p[-1] == p[-2]; + size_t dir_len = copy_option_part((char_u **)&dirp, IObuff, IOSIZE, ","); + p = (char *)IObuff + dir_len; + bool trailing_pathseps = after_pathsep((char *)IObuff, p) && p[-1] == p[-2]; if (trailing_pathseps) { IObuff[dir_len - 2] = NUL; } @@ -2958,21 +2954,19 @@ nobackup: } if (trailing_pathseps) { // path ends with '//', use full path - if ((p = (char_u *)make_percent_swname((char *)IObuff, (char *)fname)) + if ((p = make_percent_swname((char *)IObuff, fname)) != NULL) { - backup = (char_u *)modname((char *)p, (char *)backup_ext, - no_prepend_dot); + backup = modname(p, backup_ext, no_prepend_dot); xfree(p); } } if (backup == NULL) { - rootname = get_file_in_dir(fname, IObuff); + rootname = (char *)get_file_in_dir((char_u *)fname, IObuff); if (rootname == NULL) { backup = NULL; } else { - backup = (char_u *)modname((char *)rootname, (char *)backup_ext, - no_prepend_dot); + backup = modname(rootname, backup_ext, no_prepend_dot); xfree(rootname); } } @@ -2983,13 +2977,13 @@ nobackup: * delete an existing one, try to use another name. * Change one character, just before the extension. */ - if (!p_bk && os_path_exists(backup)) { + if (!p_bk && os_path_exists((char_u *)backup)) { p = backup + STRLEN(backup) - 1 - STRLEN(backup_ext); if (p < backup) { // empty file name ??? p = backup; } *p = 'z'; - while (*p > 'a' && os_path_exists(backup)) { + while (*p > 'a' && os_path_exists((char_u *)backup)) { (*p)--; } // They all exist??? Must be something wrong! @@ -3007,7 +3001,7 @@ nobackup: // If the renaming of the original file to the backup file // works, quit here. /// - if (vim_rename(fname, backup) == 0) { + if (vim_rename((char_u *)fname, (char_u *)backup) == 0) { break; } @@ -3068,21 +3062,21 @@ nobackup: // Check for forced 'fileencoding' from "++opt=val" argument. if (eap != NULL && eap->force_enc != 0) { - fenc = (char_u *)eap->cmd + eap->force_enc; - fenc = enc_canonize(fenc); + fenc = eap->cmd + eap->force_enc; + fenc = (char *)enc_canonize((char_u *)fenc); fenc_tofree = fenc; } else { - fenc = buf->b_p_fenc; + fenc = (char *)buf->b_p_fenc; } // Check if the file needs to be converted. - converted = need_conversion(fenc); + converted = need_conversion((char_u *)fenc); // Check if UTF-8 to UCS-2/4 or Latin1 conversion needs to be done. Or // Latin1 to Unicode conversion. This is handled in buf_write_bytes(). // Prepare the flags for it and allocate bw_conv_buf when needed. if (converted) { - wb_flags = get_fio_flags(fenc); + wb_flags = get_fio_flags((char_u *)fenc); if (wb_flags & (FIO_UCS2 | FIO_UCS4 | FIO_UTF16 | FIO_UTF8)) { // Need to allocate a buffer to translate into. if (wb_flags & (FIO_UCS2 | FIO_UTF16 | FIO_UTF8)) { @@ -3102,7 +3096,7 @@ nobackup: #ifdef HAVE_ICONV // Use iconv() conversion when conversion is needed and it's not done // internally. - write_info.bw_iconv_fd = (iconv_t)my_iconv_open(fenc, (char_u *)"utf-8"); + write_info.bw_iconv_fd = (iconv_t)my_iconv_open((char_u *)fenc, (char_u *)"utf-8"); if (write_info.bw_iconv_fd != (iconv_t)-1) { // We're going to use iconv(), allocate a buffer to convert in. write_info.bw_conv_buflen = bufsize * ICONV_MULT; @@ -3120,7 +3114,7 @@ nobackup: * overwrite the original file. */ if (*p_ccv != NUL) { - wfname = vim_tempname(); + wfname = (char *)vim_tempname(); if (wfname == NULL) { // Can't write without a tempfile! SET_ERRMSG(_("E214: Can't find temp file for writing")); goto restore_backup; @@ -3164,7 +3158,7 @@ nobackup: // quotum for number of files). // Appending will fail if the file does not exist and forceit is // FALSE. - while ((fd = os_open((char *)wfname, + while ((fd = os_open(wfname, O_WRONLY | (append ? (forceit ? (O_APPEND | O_CREAT) : O_APPEND) @@ -3179,7 +3173,7 @@ nobackup: // Don't delete the file when it's a hard or symbolic link. if ((!newfile && os_fileinfo_hardlinks(&file_info_old) > 1) - || (os_fileinfo_link((char *)fname, &file_info) + || (os_fileinfo_link(fname, &file_info) && !os_fileinfo_id_equal(&file_info, &file_info_old))) { SET_ERRMSG(_("E166: Can't open linked file for writing")); } else { @@ -3200,7 +3194,7 @@ nobackup: } #endif if (!append) { // don't remove when appending - os_remove((char *)wfname); + os_remove(wfname); } continue; } @@ -3221,21 +3215,21 @@ restore_backup: // This may not work if the vim_rename() fails. // In that case we leave the copy around. // If file does not exist, put the copy in its place - if (!os_path_exists(fname)) { - vim_rename(backup, fname); + if (!os_path_exists((char_u *)fname)) { + vim_rename((char_u *)backup, (char_u *)fname); } // if original file does exist throw away the copy - if (os_path_exists(fname)) { - os_remove((char *)backup); + if (os_path_exists((char_u *)fname)) { + os_remove(backup); } } else { // try to put the original file back - vim_rename(backup, fname); + vim_rename((char_u *)backup, (char_u *)fname); } } // if original file no longer exists give an extra warning - if (!newfile && !os_path_exists(fname)) { + if (!newfile && !os_path_exists((char_u *)fname)) { end = 0; } } @@ -3249,7 +3243,7 @@ restore_backup: } SET_ERRMSG(NULL); - write_info.bw_buf = buffer; + write_info.bw_buf = (char_u *)buffer; nchars = 0; // use "++bin", "++nobin" or 'binary' @@ -3262,7 +3256,7 @@ restore_backup: // Skip the BOM when appending and the file already existed, the BOM // only makes sense at the start of the file. if (buf->b_p_bomb && !write_bin && (!append || perm < 0)) { - write_info.bw_len = make_bom(buffer, fenc); + write_info.bw_len = make_bom((char_u *)buffer, (char_u *)fenc); if (write_info.bw_len > 0) { // don't convert write_info.bw_flags = FIO_NOCONVERT | wb_flags; @@ -3292,9 +3286,9 @@ restore_backup: for (lnum = start; lnum <= end; lnum++) { // The next while loop is done once for each character written. // Keep it fast! - ptr = ml_get_buf(buf, lnum, false) - 1; + ptr = (char *)ml_get_buf(buf, lnum, false) - 1; if (write_undo_file) { - sha256_update(&sha_ctx, ptr + 1, (uint32_t)(STRLEN(ptr + 1) + 1)); + sha256_update(&sha_ctx, (char_u *)ptr + 1, (uint32_t)(STRLEN(ptr + 1) + 1)); } while ((c = *++ptr) != NUL) { if (c == NL) { @@ -3403,7 +3397,7 @@ restore_backup: // don't change the owner when it's already OK, some systems remove // permission or ACL stuff FileInfo file_info; - if (!os_fileinfo((char *)wfname, &file_info) + if (!os_fileinfo(wfname, &file_info) || file_info.stat.st_uid != file_info_old.stat.st_uid || file_info.stat.st_gid != file_info_old.stat.st_gid) { os_fchown(fd, file_info_old.stat.st_uid, file_info_old.stat.st_gid); @@ -3435,7 +3429,7 @@ restore_backup: // Probably need to set the ACL before changing the user (can't set the // ACL on a file the user doesn't own). if (!backup_copy) { - mch_set_acl(wfname, acl); + mch_set_acl((char_u *)wfname, acl); } #endif @@ -3443,13 +3437,12 @@ restore_backup: // The file was written to a temp file, now it needs to be converted // with 'charconvert' to (overwrite) the output file. if (end != 0) { - if (eval_charconvert("utf-8", (char *)fenc, - (char *)wfname, (char *)fname) == FAIL) { + if (eval_charconvert("utf-8", fenc, wfname, fname) == FAIL) { write_info.bw_conv_error = true; end = 0; } } - os_remove((char *)wfname); + os_remove(wfname); xfree(wfname); } } @@ -3493,12 +3486,12 @@ restore_backup: } // copy the file. - if (os_copy((char *)backup, (char *)fname, UV_FS_COPYFILE_FICLONE) + if (os_copy(backup, fname, UV_FS_COPYFILE_FICLONE) == 0) { end = 1; // success } } else { - if (vim_rename(backup, fname) == 0) { + if (vim_rename((char_u *)backup, (char_u *)fname) == 0) { end = 1; } } @@ -3590,7 +3583,7 @@ restore_backup: * the backup file our 'original' file. */ if (*p_pm && dobackup) { - char *const org = modname((char *)fname, (char *)p_pm, false); + char *const org = modname(fname, (char *)p_pm, false); if (backup != NULL) { /* @@ -3600,7 +3593,7 @@ restore_backup: if (org == NULL) { emsg(_("E205: Patchmode: can't save original file")); } else if (!os_path_exists((char_u *)org)) { - vim_rename(backup, (char_u *)org); + vim_rename((char_u *)backup, (char_u *)org); XFREE_CLEAR(backup); // don't delete the file #ifdef UNIX os_file_settime(org, @@ -3636,7 +3629,7 @@ restore_backup: */ if (!p_bk && backup != NULL && !write_info.bw_conv_error - && os_remove((char *)backup) != 0) { + && os_remove(backup) != 0) { emsg(_("E207: Can't delete backup file")); } @@ -3700,7 +3693,7 @@ nofail: // Update the timestamp to avoid an "overwrite changed file" // prompt when writing again. - if (os_fileinfo((char *)fname, &file_info_old)) { + if (os_fileinfo(fname, &file_info_old)) { buf_store_file_info(buf, &file_info_old); buf->b_mtime_read = buf->b_mtime; buf->b_mtime_read_ns = buf->b_mtime_ns; @@ -3714,10 +3707,10 @@ nofail: * file. */ if (retval == OK && write_undo_file) { - char_u hash[UNDO_HASH_SIZE]; + char hash[UNDO_HASH_SIZE]; - sha256_finish(&sha_ctx, hash); - u_write_undo(NULL, FALSE, buf, hash); + sha256_finish(&sha_ctx, (char_u *)hash); + u_write_undo(NULL, false, buf, (char_u *)hash); } if (!should_abort(retval)) { @@ -4442,7 +4435,7 @@ char *modname(const char *fname, const char *ext, bool prepend_dot) char *e; // Prepend the dot if needed. - if (prepend_dot && *(e = (char *)path_tail((char_u *)retval)) != '.') { + if (prepend_dot && *(e = path_tail(retval)) != '.') { STRMOVE(e + 1, e); *e = '.'; } @@ -4653,7 +4646,7 @@ int vim_rename(const char_u *from, const char_u *to) * the file name differs we need to go through a temp file. */ if (FNAMECMP(from, to) == 0) { - if (p_fic && (STRCMP(path_tail((char_u *)from), path_tail((char_u *)to)) + if (p_fic && (STRCMP(path_tail((char *)from), path_tail((char *)to)) != 0)) { use_tmp_file = true; } else { @@ -4688,7 +4681,7 @@ int vim_rename(const char_u *from, const char_u *to) } STRCPY(tempname, from); for (n = 123; n < 99999; n++) { - char *tail = (char *)path_tail(tempname); + char *tail = path_tail((char *)tempname); snprintf(tail, (MAXPATHL + 1) - (tail - (char *)tempname - 1), "%d", n); if (!os_path_exists(tempname)) { @@ -5000,7 +4993,7 @@ int buf_check_timestamp(buf_T *buf) if (!bufref_valid(&bufref)) { emsg(_("E246: FileChangedShell autocommand deleted buffer")); } - s = get_vim_var_str(VV_FCS_CHOICE); + s = (char_u *)get_vim_var_str(VV_FCS_CHOICE); if (STRCMP(s, "reload") == 0 && *reason != 'd') { reload = RELOAD_NORMAL; } else if (STRCMP(s, "edit") == 0) { @@ -5199,7 +5192,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(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0, + if (readfile((char *)buf->b_ffname, (char *)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); @@ -5443,7 +5436,7 @@ void vim_deltempdir(void) { if (vim_tempdir != NULL) { // remove the trailing path separator - path_tail(vim_tempdir)[-1] = NUL; + path_tail((char *)vim_tempdir)[-1] = NUL; delete_recursive((const char *)vim_tempdir); XFREE_CLEAR(vim_tempdir); } @@ -5519,7 +5512,7 @@ char_u *vim_tempname(void) /// @param allow_dirs Allow matching with dir /// /// @return true if there is a match, false otherwise -bool match_file_pat(char_u *pattern, regprog_T **prog, char_u *fname, char_u *sfname, char_u *tail, +bool match_file_pat(char *pattern, regprog_T **prog, char *fname, char *sfname, char *tail, int allow_dirs) { regmatch_T regmatch; @@ -5530,7 +5523,7 @@ bool match_file_pat(char_u *pattern, regprog_T **prog, char_u *fname, char_u *sf if (prog != NULL) { regmatch.regprog = *prog; } else { - regmatch.regprog = vim_regcomp(pattern, RE_MAGIC); + regmatch.regprog = vim_regcomp((char_u *)pattern, RE_MAGIC); } } @@ -5542,10 +5535,10 @@ bool match_file_pat(char_u *pattern, regprog_T **prog, char_u *fname, char_u *sf */ if (regmatch.regprog != NULL && ((allow_dirs - && (vim_regexec(®match, fname, (colnr_T)0) + && (vim_regexec(®match, (char_u *)fname, (colnr_T)0) || (sfname != NULL - && vim_regexec(®match, sfname, (colnr_T)0)))) - || (!allow_dirs && vim_regexec(®match, tail, (colnr_T)0)))) { + && vim_regexec(®match, (char_u *)sfname, (colnr_T)0)))) + || (!allow_dirs && vim_regexec(®match, (char_u *)tail, (colnr_T)0)))) { result = true; } @@ -5576,7 +5569,7 @@ bool match_file_list(char_u *list, char_u *sfname, char_u *ffname) bool match; char_u *p; - tail = path_tail(sfname); + tail = (char_u *)path_tail((char *)sfname); // try all patterns in 'wildignore' p = list; @@ -5586,7 +5579,8 @@ bool match_file_list(char_u *list, char_u *sfname, char_u *ffname) if (regpat == NULL) { break; } - match = match_file_pat(regpat, NULL, ffname, sfname, tail, (int)allow_dirs); + match = match_file_pat((char *)regpat, NULL, (char *)ffname, (char *)sfname, (char *)tail, + (int)allow_dirs); xfree(regpat); if (match) { return true; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index c50d258b83..c0a5a14f7b 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -3009,7 +3009,7 @@ int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs) // // With :unmap, literal white space is included in the {lhs}; there is no // separate {rhs}. - const char_u *lhs_end = to_parse; + const char *lhs_end = (char *)to_parse; bool do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); while (*lhs_end && (is_unmap || !ascii_iswhite(*lhs_end))) { if ((lhs_end[0] == Ctrl_V || (do_backslash && lhs_end[0] == '\\')) @@ -3025,7 +3025,7 @@ int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs) // Given {lhs} might be larger than MAXMAPLEN before replace_termcodes // (e.g. "<Space>" is longer than ' '), so first copy into a buffer. - size_t orig_lhs_len = (size_t)(lhs_end - to_parse); + size_t orig_lhs_len = (size_t)((char_u *)lhs_end - to_parse); char_u *lhs_to_replace = xcalloc(orig_lhs_len + 1, sizeof(char_u)); STRLCPY(lhs_to_replace, to_parse, orig_lhs_len + 1); @@ -3820,7 +3820,7 @@ bool map_to_exists(const char *const str, const char *const modechars, const boo MAPMODE(mode, modechars, 'c', MODE_CMDLINE); #undef MAPMODE - retval = map_to_exists_mode((const char *)rhs, mode, abbr); + retval = map_to_exists_mode((char *)rhs, mode, abbr); xfree(buf); return retval; @@ -4828,7 +4828,7 @@ mapblock_T *get_maphash(int index, buf_T *buf) } /// Get command argument for <Cmd> key -char_u *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) +char *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) { garray_T line_ga; int c1 = -1, c2; @@ -4901,7 +4901,7 @@ char_u *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) ga_clear(&line_ga); } - return (char_u *)line_ga.ga_data; + return line_ga.ga_data; } bool map_execute_lua(void) diff --git a/src/nvim/globals.h b/src/nvim/globals.h index ff70687fae..ef8ff11bf8 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -253,7 +253,7 @@ EXTERN int lines_left INIT(= -1); // lines left for listing EXTERN int msg_no_more INIT(= false); // don't use more prompt, truncate // messages -EXTERN char_u *sourcing_name INIT(= NULL); // name of error message source +EXTERN char *sourcing_name INIT(= NULL); // name of error message source EXTERN linenr_T sourcing_lnum INIT(= 0); // line number of the source file EXTERN int ex_nesting_level INIT(= 0); // nesting level @@ -354,7 +354,7 @@ EXTERN bool did_source_packages INIT(= false); // provider function call EXTERN struct caller_scope { sctx_T script_ctx; - uint8_t *sourcing_name, *autocmd_fname, *autocmd_match; + char *sourcing_name, *autocmd_fname, *autocmd_match; linenr_T sourcing_lnum; int autocmd_bufnr; void *funccalp; @@ -755,9 +755,9 @@ EXTERN char last_mode[MODE_MAX_LENGTH] INIT(= "n"); EXTERN char_u *last_cmdline INIT(= NULL); // last command line (for ":) EXTERN char_u *repeat_cmdline INIT(= NULL); // command line for "." EXTERN char_u *new_last_cmdline INIT(= NULL); // new value for last_cmdline -EXTERN char_u *autocmd_fname INIT(= NULL); // fname for <afile> on cmdline +EXTERN char *autocmd_fname INIT(= NULL); // fname for <afile> on cmdline EXTERN int autocmd_bufnr INIT(= 0); // fnum for <abuf> on cmdline -EXTERN char_u *autocmd_match INIT(= NULL); // name for <amatch> on cmdline +EXTERN char *autocmd_match INIT(= NULL); // name for <amatch> on cmdline EXTERN bool did_cursorhold INIT(= false); // set when CursorHold t'gerd EXTERN int postponed_split INIT(= 0); // for CTRL-W CTRL-] command diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index f75f304bc1..aec15234b9 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -1576,7 +1576,7 @@ static void prt_resource_name(char *filename, void *cookie) static int prt_find_resource(char *name, struct prt_ps_resource_S *resource) { - char_u *buffer; + char *buffer; int retval; buffer = xmallocz(MAXPATHL); @@ -1584,7 +1584,7 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource) STRLCPY(resource->name, name, 64); // Look for named resource file in runtimepath STRCPY(buffer, "print"); - add_pathsep((char *)buffer); + add_pathsep(buffer); STRLCAT(buffer, name, MAXPATHL); STRLCAT(buffer, ".ps", MAXPATHL); resource->filename[0] = NUL; diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index d9cc643e53..77154e8fce 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -80,7 +80,7 @@ static enum { * Function given to ExpandGeneric() to obtain the cscope command * expansion. */ -char_u *get_cscope_name(expand_T *xp, int idx) +char *get_cscope_name(expand_T *xp, int idx) { int current_idx; @@ -88,7 +88,7 @@ char_u *get_cscope_name(expand_T *xp, int idx) case EXP_CSCOPE_SUBCMD: // Complete with sub-commands of ":cscope": // add, find, help, kill, reset, show - return (char_u *)cs_cmds[idx].name; + return cs_cmds[idx].name; case EXP_SCSCOPE_SUBCMD: { // Complete with sub-commands of ":scscope": same sub-commands as // ":cscope" but skip commands which don't support split windows @@ -100,7 +100,7 @@ char_u *get_cscope_name(expand_T *xp, int idx) } } } - return (char_u *)cs_cmds[i].name; + return cs_cmds[i].name; } case EXP_CSCOPE_FIND: { const char *query_type[] = @@ -112,7 +112,7 @@ char_u *get_cscope_name(expand_T *xp, int idx) // {query_type} can be letters (c, d, ... a) or numbers (0, 1, // ..., 9) but only complete with letters, since numbers are // redundant. - return (char_u *)query_type[idx]; + return (char *)query_type[idx]; } case EXP_CSCOPE_KILL: { static char connection[5]; @@ -128,10 +128,10 @@ char_u *get_cscope_name(expand_T *xp, int idx) } if (current_idx++ == idx) { vim_snprintf(connection, sizeof(connection), "%zu", i); - return (char_u *)connection; + return connection; } } - return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL; + return (current_idx == idx && idx > 0) ? "-1" : NULL; } default: return NULL; @@ -2008,8 +2008,8 @@ static char *cs_resolve_file(size_t i, char *name) // path in path resolution. csdir = xmalloc(MAXPATHL); STRLCPY(csdir, csinfo[i].fname, - path_tail((char_u *)csinfo[i].fname) - - (char_u *)csinfo[i].fname + 1); + path_tail(csinfo[i].fname) + - csinfo[i].fname + 1); len += STRLEN(csdir); } diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 1da868c137..29ed40af03 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -920,7 +920,7 @@ int nlua_call(lua_State *lstate) { Error err = ERROR_INIT; size_t name_len; - const char_u *name = (const char_u *)luaL_checklstring(lstate, 1, &name_len); + const char *name = luaL_checklstring(lstate, 1, &name_len); if (!nlua_is_deferred_safe()) { return luaL_error(lstate, e_luv_api_disabled, "vimL function"); } @@ -1249,7 +1249,7 @@ int nlua_source_using_linegetter(LineGetter fgetline, void *cookie, char *name) char_u *line = NULL; ga_init(&ga, (int)sizeof(char_u *), 10); - while ((line = fgetline(0, cookie, 0, false)) != NULL) { + while ((line = (char_u *)fgetline(0, cookie, 0, false)) != NULL) { GA_APPEND(char_u *, &ga, line); } char *code = ga_concat_strings_sep(&ga, "\n"); diff --git a/src/nvim/main.c b/src/nvim/main.c index 9beaa0686f..1cf3cdd872 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -807,7 +807,7 @@ static void init_locale(void) snprintf(localepath, sizeof(localepath), "%s", get_vim_var_str(VV_PROGPATH)); char *tail = (char *)path_tail_with_sep((char_u *)localepath); *tail = NUL; - tail = (char *)path_tail((char_u *)localepath); + tail = path_tail(localepath); xstrlcpy(tail, "share/locale", sizeof(localepath) - (size_t)(tail - localepath)); bindtextdomain(PROJECT_NAME, localepath); @@ -1364,7 +1364,7 @@ scripterror: if (parmp->diff_mode && os_isdir(p) && GARGCOUNT > 0 && !os_isdir(alist_name(&GARGLIST[0]))) { char_u *r = (char_u *)concat_fnames((char *)p, - (char *)path_tail(alist_name(&GARGLIST[0])), true); + path_tail((char *)alist_name(&GARGLIST[0])), true); xfree(p); p = r; } @@ -1470,7 +1470,7 @@ static void init_path(const char *exename) path_guess_exepath(exename, exepath, sizeof(exepath)); } set_vim_var_string(VV_PROGPATH, exepath, -1); - set_vim_var_string(VV_PROGNAME, (char *)path_tail((char_u *)exename), -1); + set_vim_var_string(VV_PROGNAME, path_tail(exename), -1); #ifdef WIN32 // Append the process start directory to $PATH, so that ":!foo" finds tools @@ -1813,7 +1813,7 @@ static void exe_pre_commands(mparm_T *parmp) if (cnt > 0) { curwin->w_cursor.lnum = 0; // just in case.. - sourcing_name = (char_u *)_("pre-vimrc command line"); + sourcing_name = _("pre-vimrc command line"); current_sctx.sc_sid = SID_CMDARG; for (i = 0; i < cnt; i++) { do_cmdline_cmd(cmds[i]); @@ -1840,7 +1840,7 @@ static void exe_commands(mparm_T *parmp) if (parmp->tagname == NULL && curwin->w_cursor.lnum <= 1) { curwin->w_cursor.lnum = 0; } - sourcing_name = (char_u *)"command line"; + sourcing_name = "command line"; current_sctx.sc_sid = SID_CARG; current_sctx.sc_seq = 0; for (i = 0; i < parmp->n_commands; i++) { @@ -2061,16 +2061,16 @@ static int execute_env(char *env) { const char *initstr = os_getenv(env); if (initstr != NULL) { - char_u *save_sourcing_name = sourcing_name; + char_u *save_sourcing_name = (char_u *)sourcing_name; linenr_T save_sourcing_lnum = sourcing_lnum; - sourcing_name = (char_u *)env; + sourcing_name = env; sourcing_lnum = 0; const sctx_T save_current_sctx = current_sctx; current_sctx.sc_sid = SID_ENV; current_sctx.sc_seq = 0; current_sctx.sc_lnum = 0; do_cmdline_cmd((char *)initstr); - sourcing_name = save_sourcing_name; + sourcing_name = (char *)save_sourcing_name; sourcing_lnum = save_sourcing_lnum; current_sctx = save_current_sctx; return OK; @@ -2104,7 +2104,7 @@ static bool file_owned(const char *fname) static void mainerr(const char *errstr, const char *str) FUNC_ATTR_NORETURN { - char *prgname = (char *)path_tail((char_u *)argv0); + char *prgname = path_tail(argv0); signal_stop(); // kill us with CTRL-C here, if you like diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 1d65529b75..4ea9329a71 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1332,7 +1332,7 @@ bool mb_isalpha(int a) static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2) { int c1, c2, cdiff; - char_u buffer[6]; + char buffer[6]; for (;;) { c1 = utf_safe_read_char_adv(&s1, &n1); @@ -1371,10 +1371,10 @@ static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2 if (c1 != -1 && c2 == -1) { n1 = utf_char2bytes(utf_fold(c1), (char *)buffer); - s1 = buffer; + s1 = (char_u *)buffer; } else if (c2 != -1 && c1 == -1) { n2 = utf_char2bytes(utf_fold(c2), (char *)buffer); - s2 = buffer; + s2 = (char_u *)buffer; } while (n1 > 0 && n2 > 0 && *s1 != NUL && *s2 != NUL) { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 081045ab18..5ca33faec3 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -992,7 +992,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(curbuf->b_ffname, NULL, (linenr_T)0, + orig_file_status = readfile((char *)curbuf->b_ffname, NULL, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, NULL, READ_NEW, false); } @@ -1066,7 +1066,7 @@ void ml_recover(bool checkext) */ if (!cannot_open) { line_count = pp->pb_pointer[idx].pe_line_count; - if (readfile(curbuf->b_ffname, NULL, lnum, + if (readfile((char *)curbuf->b_ffname, NULL, lnum, pp->pb_pointer[idx].pe_old_lnum - 1, line_count, NULL, 0, false) != OK) { cannot_open = true; @@ -1338,8 +1338,8 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out) tail = (char_u *)make_percent_swname((char *)dir_name, (char *)fname_res); } else { - tail = path_tail(fname_res); - tail = (char_u *)concat_fnames((char *)dir_name, (char *)tail, TRUE); + tail = (char_u *)path_tail((char *)fname_res); + tail = (char_u *)concat_fnames((char *)dir_name, (char *)tail, true); } num_names = recov_file_names(names, tail, FALSE); xfree(tail); @@ -1418,7 +1418,7 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out) // print the swap file name msg_outnum((long)++file_count); msg_puts(". "); - msg_puts((const char *)path_tail(files[i])); + msg_puts((const char *)path_tail((char *)files[i])); msg_putchar('\n'); (void)swapfile_info(files[i]); } @@ -3204,7 +3204,7 @@ int resolve_symlink(const char_u *fname, char_u *buf) if (path_is_absolute(buf)) { STRCPY(tmp, buf); } else { - char_u *tail = path_tail(tmp); + char_u *tail = (char_u *)path_tail((char *)tmp); if (STRLEN(tail) + STRLEN(buf) >= MAXPATHL) { return FAIL; } @@ -3283,7 +3283,7 @@ char_u *get_file_in_dir(char_u *fname, char_u *dname) char_u *retval; int save_char; - tail = path_tail(fname); + tail = (char_u *)path_tail((char *)fname); if (dname[0] == '.' && dname[1] == NUL) { retval = vim_strsave(fname); @@ -3482,8 +3482,8 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ // buffer don't compare the directory names, they can // have a different mountpoint. if (b0.b0_flags & B0_SAME_DIR) { - if (FNAMECMP(path_tail(buf->b_ffname), - path_tail(b0.b0_fname)) != 0 + if (FNAMECMP(path_tail((char *)buf->b_ffname), + path_tail((char *)b0.b0_fname)) != 0 || !same_directory((char_u *)fname, buf->b_ffname)) { // Symlinks may point to the same file even // when the name differs, need to check the @@ -3528,7 +3528,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ // response, trigger it. It may return 0 to ask the user anyway. if (choice == 0 && swap_exists_action != SEA_NONE - && has_autocmd(EVENT_SWAPEXISTS, (char_u *)buf_fname, buf)) { + && has_autocmd(EVENT_SWAPEXISTS, buf_fname, buf)) { choice = do_swapexists(buf, (char_u *)fname); } diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 887a24d28b..14084df4d4 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -1034,7 +1034,7 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for * Function given to ExpandGeneric() to obtain the list of (sub)menus (not * entries). */ -char_u *get_menu_name(expand_T *xp, int idx) +char *get_menu_name(expand_T *xp, int idx) { static vimmenu_T *menu = NULL; char *str; @@ -1076,14 +1076,14 @@ char_u *get_menu_name(expand_T *xp, int idx) should_advance = !should_advance; - return (char_u *)str; + return str; } /* * Function given to ExpandGeneric() to obtain the list of menus and menu * entries. */ -char_u *get_menu_names(expand_T *xp, int idx) +char *get_menu_names(expand_T *xp, int idx) { static vimmenu_T *menu = NULL; #define TBUFFER_LEN 256 @@ -1143,7 +1143,7 @@ char_u *get_menu_names(expand_T *xp, int idx) should_advance = !should_advance; - return (char_u *)str; + return str; } diff --git a/src/nvim/message.c b/src/nvim/message.c index 8f093a12ed..29473ac2b6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -586,7 +586,7 @@ void msg_source(int attr) if (sourcing_name == NULL) { last_sourcing_name = NULL; } else { - last_sourcing_name = vim_strsave(sourcing_name); + last_sourcing_name = vim_strsave((char_u *)sourcing_name); } } --no_wait_return; @@ -2418,7 +2418,7 @@ void msg_reset_scroll(void) static void inc_msg_scrolled(void) { if (*get_vim_var_str(VV_SCROLLSTART) == NUL) { - char *p = (char *)sourcing_name; + char *p = sourcing_name; char *tofree = NULL; // v:scrollstart is empty, set it to the script/function name and line diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 54db6f6f6f..7b3895333b 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -884,7 +884,7 @@ yankreg_T *copy_register(int name) if (copy->y_size == 0) { copy->y_array = NULL; } else { - copy->y_array = xcalloc(copy->y_size, sizeof(char_u *)); + copy->y_array = xcalloc(copy->y_size, sizeof(char *)); for (size_t i = 0; i < copy->y_size; i++) { copy->y_array[i] = xstrdup(reg->y_array[i]); } @@ -1161,7 +1161,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) * Insert lines into typeahead buffer, from last one to first one. */ put_reedit_in_typebuf(silent); - char_u *escaped; + char *escaped; for (size_t i = reg->y_size; i-- > 0;) { // from y_size - 1 to 0 included // insert NL between lines and after last line if type is kMTLineWise if (reg->y_type == kMTLineWise || i < reg->y_size - 1 || addcr) { @@ -1180,7 +1180,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) free_str = true; } } - escaped = (char_u *)vim_strsave_escape_ks((char *)str); + escaped = vim_strsave_escape_ks((char *)str); if (free_str) { xfree(str); } @@ -1237,12 +1237,12 @@ static int put_in_typebuf(char_u *s, bool esc, bool colon, int silent) retval = ins_typebuf("\n", REMAP_NONE, 0, true, silent); } if (retval == OK) { - char_u *p; + char *p; if (esc) { - p = (char_u *)vim_strsave_escape_ks((char *)s); + p = vim_strsave_escape_ks((char *)s); } else { - p = s; + p = (char *)s; } if (p == NULL) { retval = FAIL; @@ -2679,7 +2679,7 @@ bool op_yank(oparg_T *oap, bool message) static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) { yankreg_T newreg; // new yank register when appending - char_u **new_ptr; + char **new_ptr; linenr_T lnum; // current line number size_t j; MotionType yank_type = oap->motion_type; @@ -2713,7 +2713,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) reg->y_size = yanklines; reg->y_type = yank_type; // set the yank register type reg->y_width = 0; - reg->y_array = xcalloc(yanklines, sizeof(char_u *)); + reg->y_array = xcalloc(yanklines, sizeof(char *)); reg->additional_data = NULL; reg->timestamp = os_time(); @@ -2808,10 +2808,10 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) if (curr != reg) { // append the new block to the old block new_ptr = xmalloc(sizeof(char_u *) * (curr->y_size + reg->y_size)); for (j = 0; j < curr->y_size; j++) { - new_ptr[j] = (char_u *)curr->y_array[j]; + new_ptr[j] = curr->y_array[j]; } xfree(curr->y_array); - curr->y_array = (char **)new_ptr; + curr->y_array = new_ptr; if (yank_type == kMTLineWise) { // kMTLineWise overrides kMTCharWise and kMTBlockWise @@ -5777,7 +5777,7 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char_u *str // When appending, copy the previous line and free it after. size_t extra = append ? STRLEN(pp[--lnum]) : 0; - char_u *s = xmallocz(line_len + extra); + char *s = xmallocz(line_len + extra); if (extra > 0) { memcpy(s, pp[lnum], extra); } @@ -5788,7 +5788,7 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char_u *str xfree(pp[lnum]); append = false; // only first line is appended } - pp[lnum] = s; + pp[lnum] = (char_u *)s; // Convert NULs to '\n' to prevent truncation. memchrsub(pp[lnum], NUL, '\n', s_len); @@ -7120,7 +7120,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) reg->y_type = kMTUnknown; } - reg->y_array = xcalloc((size_t)tv_list_len(lines), sizeof(char_u *)); + reg->y_array = xcalloc((size_t)tv_list_len(lines), sizeof(char *)); reg->y_size = (size_t)tv_list_len(lines); reg->additional_data = NULL; reg->timestamp = 0; diff --git a/src/nvim/option.c b/src/nvim/option.c index 81b1ab5b2b..66d9d2843c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -8161,13 +8161,13 @@ size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_c /// Return true when 'shell' has "csh" in the tail. int csh_like_shell(void) { - return strstr((char *)path_tail(p_sh), "csh") != NULL; + return strstr(path_tail((char *)p_sh), "csh") != NULL; } /// Return true when 'shell' has "fish" in the tail. bool fish_like_shell(void) { - return strstr((char *)path_tail(p_sh), "fish") != NULL; + return strstr(path_tail((char *)p_sh), "fish") != NULL; } /// Return the number of requested sign columns, based on current diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 4e6a52a78e..d0435cd968 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -888,7 +888,7 @@ void vim_get_prefix_from_exepath(char *exe_name) MAXPATHL * sizeof(*exe_name)); char *path_end = (char *)path_tail_with_sep((char_u *)exe_name); *path_end = '\0'; // remove the trailing "nvim.exe" - path_end = (char *)path_tail((char_u *)exe_name); + path_end = path_tail(exe_name); *path_end = '\0'; // remove the trailing "bin/" } @@ -957,7 +957,7 @@ char *vim_getenv(const char *name) if (vim_path != NULL) { // remove the file name - char *vim_path_end = (char *)path_tail((char_u *)vim_path); + char *vim_path_end = path_tail(vim_path); // remove "doc/" from 'helpfile', if present if (vim_path == (char *)p_hf) { @@ -1048,7 +1048,7 @@ size_t home_replace(const buf_T *const buf, const char_u *src, char_u *const dst } if (buf != NULL && buf->b_help) { - const size_t dlen = STRLCPY(dst, path_tail(src), dstlen); + const size_t dlen = STRLCPY(dst, path_tail((char *)src), dstlen); return MIN(dlen, dstlen - 1); } @@ -1158,7 +1158,7 @@ char_u *home_replace_save(buf_T *buf, char_u *src) FUNC_ATTR_NONNULL_RET /// Function given to ExpandGeneric() to obtain an environment variable name. -char_u *get_env_name(expand_T *xp, int idx) +char *get_env_name(expand_T *xp, int idx) { #define ENVNAMELEN 100 // this static buffer is needed to avoid a memory leak in ExpandGeneric @@ -1168,7 +1168,7 @@ char_u *get_env_name(expand_T *xp, int idx) if (envname) { STRLCPY(name, envname, ENVNAMELEN); xfree(envname); - return name; + return (char *)name; } return NULL; } @@ -1226,10 +1226,10 @@ bool os_shell_is_cmdexe(const char *sh) } if (striequal(sh, "$COMSPEC")) { const char *comspec = os_getenv("COMSPEC"); - return striequal("cmd.exe", (char *)path_tail((char_u *)comspec)); + return striequal("cmd.exe", path_tail(comspec)); } if (striequal(sh, "cmd.exe") || striequal(sh, "cmd")) { return true; } - return striequal("cmd.exe", (char *)path_tail((char_u *)sh)); + return striequal("cmd.exe", path_tail(sh)); } diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 79d24e41b0..34d9015071 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -188,7 +188,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file } } if (shell_style == STYLE_ECHO - && strstr((char *)path_tail(p_sh), "sh") != NULL) { + && strstr(path_tail((char *)p_sh), "sh") != NULL) { shell_style = STYLE_VIMGLOB; } diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index e0ce3fec31..4803be20c3 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -187,11 +187,11 @@ static void init_users(void) } /// Given to ExpandGeneric() to obtain an user names. -char_u *get_users(expand_T *xp, int idx) +char *get_users(expand_T *xp, int idx) { init_users(); if (idx < ga_users.ga_len) { - return ((char_u **)ga_users.ga_data)[idx]; + return ((char **)ga_users.ga_data)[idx]; } return NULL; } diff --git a/src/nvim/path.c b/src/nvim/path.c index 0bb364184a..fd6cca63f4 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -92,15 +92,15 @@ FileComparison path_full_compare(char_u *const s1, char_u *const s2, const bool /// /// @return pointer just past the last path separator (empty string, if fname /// ends in a slash), or empty string if fname is NULL. -char_u *path_tail(const char_u *fname) +char *path_tail(const char *fname) FUNC_ATTR_NONNULL_RET { if (fname == NULL) { - return (char_u *)""; + return ""; } - const char_u *tail = get_past_head(fname); - const char_u *p = tail; + const char *tail = (char *)get_past_head((char_u *)fname); + const char *p = tail; // Find last part of path. while (*p != NUL) { if (vim_ispathsep_nocolon(*p)) { @@ -108,7 +108,7 @@ char_u *path_tail(const char_u *fname) } MB_PTR_ADV(p); } - return (char_u *)tail; + return (char *)tail; } /// Get pointer to tail of "fname", including path separators. @@ -126,7 +126,7 @@ char_u *path_tail_with_sep(char_u *fname) // Don't remove the '/' from "c:/file". char_u *past_head = get_past_head(fname); - char_u *tail = path_tail(fname); + char_u *tail = (char_u *)path_tail((char *)fname); while (tail > past_head && after_pathsep((char *)fname, (char *)tail)) { tail--; } @@ -275,7 +275,7 @@ int vim_ispathlistsep(int c) /// It's done in-place. void shorten_dir_len(char_u *str, int trim_len) { - char_u *tail = path_tail(str); + char_u *tail = (char_u *)path_tail((char *)str); char_u *d = str; bool skip = false; int dirchunk_len = 0; @@ -849,7 +849,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap) if (curbuf->b_ffname == NULL) { continue; } - char_u *p = path_tail(curbuf->b_ffname); + char_u *p = (char_u *)path_tail((char *)curbuf->b_ffname); size_t len = (size_t)(p - curbuf->b_ffname); if (len + STRLEN(buf) >= MAXPATHL) { continue; @@ -1375,17 +1375,18 @@ static int vim_backtick(char_u *p) /// @param flags EW_* flags static int expand_backtick(garray_T *gap, char_u *pat, int flags) { - char_u *p; - char_u *buffer; + char *p; + char *buffer; int cnt = 0; // Create the command: lop off the backticks. - char_u *cmd = vim_strnsave(pat + 1, STRLEN(pat) - 2); + char *cmd = (char *)vim_strnsave(pat + 1, STRLEN(pat) - 2); if (*cmd == '=') { // `={expr}`: Expand expression - buffer = (char_u *)eval_to_string((char *)cmd + 1, (char **)&p, true); + buffer = eval_to_string(cmd + 1, &p, true); } else { - buffer = get_cmd_output(cmd, NULL, (flags & EW_SILENT) ? kShellOptSilent : 0, NULL); + buffer = (char *)get_cmd_output((char_u *)cmd, NULL, (flags & EW_SILENT) ? kShellOptSilent : 0, + NULL); } xfree(cmd); if (buffer == NULL) { @@ -1394,16 +1395,16 @@ static int expand_backtick(garray_T *gap, char_u *pat, int flags) cmd = buffer; while (*cmd != NUL) { - cmd = (char_u *)skipwhite((char *)cmd); // skip over white space + cmd = skipwhite(cmd); // skip over white space p = cmd; while (*p != NUL && *p != '\r' && *p != '\n') { // skip over entry ++p; } // add an entry if it is not empty if (p > cmd) { - char_u i = *p; + char i = *p; *p = NUL; - addfile(gap, cmd, flags); + addfile(gap, (char_u *)cmd, flags); *p = i; ++cnt; } @@ -2244,7 +2245,7 @@ int match_suffix(char_u *fname) for (char_u *setsuf = p_su; *setsuf;) { setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,"); if (setsuflen == 0) { - char_u *tail = path_tail(fname); + char_u *tail = (char_u *)path_tail((char *)fname); // empty entry: match name without a '.' if (vim_strchr(tail, '.') == NULL) { diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 394f819f13..c9e6f9c210 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3104,7 +3104,7 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel) && (buf = buflist_findnr(qfp->qf_fnum)) != NULL) { fname = (char *)buf->b_fname; if (qfp->qf_type == 1) { // :helpgrep - fname = (char *)path_tail((char_u *)fname); + fname = path_tail(fname); } } if (fname == NULL) { @@ -4038,7 +4038,7 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfli && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL && errbuf->b_fname != NULL) { if (qfp->qf_type == 1) { // :helpgrep - STRLCPY(IObuff, path_tail(errbuf->b_fname), IOSIZE); + STRLCPY(IObuff, path_tail((char *)errbuf->b_fname), IOSIZE); } else { // Shorten the file name if not done already. // For optimization, do this only for the first entry in a @@ -5740,7 +5740,7 @@ static buf_T *load_dummy_buffer(char *fname, char *dirname_start, char *resultin curbuf->b_flags &= ~BF_DUMMY; newbuf_to_wipe.br_buf = NULL; - readfile_result = readfile((char_u *)fname, NULL, (linenr_T)0, (linenr_T)0, + readfile_result = readfile(fname, NULL, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, NULL, READ_NEW | READ_DUMMY, false); newbuf->b_locked--; @@ -6887,7 +6887,7 @@ static int cbuffer_process_args(exarg_T *eap, buf_T **bufp, linenr_T *line1, lin if (*eap->arg == NUL) { buf = curbuf; - } else if (*skipwhite((char *)skipdigits((char_u *)eap->arg)) == NUL) { + } else if (*skipwhite(skipdigits(eap->arg)) == NUL) { buf = buflist_findnr(atoi(eap->arg)); } diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 6a690f9af8..99a00aefa9 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -1742,33 +1742,33 @@ static char_u *get_nth_sign_group_name(int idx) /// Function given to ExpandGeneric() to obtain the sign command /// expansion. -char_u *get_sign_name(expand_T *xp, int idx) +char *get_sign_name(expand_T *xp, int idx) { switch (expand_what) { case EXP_SUBCMD: - return (char_u *)cmds[idx]; + return cmds[idx]; case EXP_DEFINE: { char *define_arg[] = { "culhl=", "icon=", "linehl=", "numhl=", "text=", "texthl=", NULL }; - return (char_u *)define_arg[idx]; + return define_arg[idx]; } case EXP_PLACE: { char *place_arg[] = { "line=", "name=", "group=", "priority=", "file=", "buffer=", NULL }; - return (char_u *)place_arg[idx]; + return place_arg[idx]; } case EXP_LIST: { char *list_arg[] = { "group=", "file=", "buffer=", NULL }; - return (char_u *)list_arg[idx]; + return list_arg[idx]; } case EXP_UNPLACE: { char *unplace_arg[] = { "group=", "file=", "buffer=", NULL }; - return (char_u *)unplace_arg[idx]; + return unplace_arg[idx]; } case EXP_SIGN_NAMES: - return get_nth_sign_name(idx); + return (char *)get_nth_sign_name(idx); case EXP_SIGN_GROUPS: - return get_nth_sign_group_name(idx); + return (char *)get_nth_sign_group_name(idx); default: return NULL; } diff --git a/src/nvim/spell.c b/src/nvim/spell.c index fc3bcef666..b2969c5332 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -385,7 +385,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou } else if (*ptr == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) { mi.mi_end = skiphex(ptr + 2); } else { - mi.mi_end = skipdigits(ptr); + mi.mi_end = (char_u *)skipdigits((char *)ptr); } nrlen = (size_t)(mi.mi_end - ptr); } @@ -1656,7 +1656,7 @@ void spell_cat_line(char_u *buf, char_u *line, int maxlen) // "lang" must be the language without the region: e.g., "en". static void spell_load_lang(char_u *lang) { - char_u fname_enc[85]; + char fname_enc[85]; int r; spelload_T sl; int round; @@ -2105,7 +2105,7 @@ char *did_set_spelllang(win_T *wp) filename = true; // Locate a region and remove it from the file name. - p = vim_strchr(path_tail(lang), '_'); + p = vim_strchr((char_u *)path_tail((char *)lang), '_'); if (p != NULL && ASCII_ISALPHA(p[1]) && ASCII_ISALPHA(p[2]) && !ASCII_ISALPHA(p[3])) { STRLCPY(region_cp, p + 1, 3); @@ -2247,7 +2247,7 @@ char *did_set_spelllang(win_T *wp) if (round == 0) { STRCPY(lang, "internal wordlist"); } else { - STRLCPY(lang, path_tail(spf_name), MAXWLEN + 1); + STRLCPY(lang, path_tail((char *)spf_name), MAXWLEN + 1); p = vim_strchr(lang, '.'); if (p != NULL) { *p = NUL; // truncate at ".encoding.add" @@ -5652,12 +5652,12 @@ static void make_case_word(char_u *fword, char_u *cword, int flags) static bool similar_chars(slang_T *slang, int c1, int c2) { int m1, m2; - char_u buf[MB_MAXBYTES + 1]; + char buf[MB_MAXBYTES + 1]; hashitem_T *hi; if (c1 >= 256) { buf[utf_char2bytes(c1, (char *)buf)] = 0; - hi = hash_find(&slang->sl_map_hash, buf); + hi = hash_find(&slang->sl_map_hash, (char_u *)buf); if (HASHITEM_EMPTY(hi)) { m1 = 0; } else { @@ -5672,7 +5672,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, buf); + hi = hash_find(&slang->sl_map_hash, (char_u *)buf); if (HASHITEM_EMPTY(hi)) { m2 = 0; } else { @@ -6871,20 +6871,20 @@ void ex_spellinfo(exarg_T *eap) // ":spelldump" void ex_spelldump(exarg_T *eap) { - char_u *spl; + char *spl; long dummy; if (no_spell_checking(curwin)) { return; } - get_option_value("spl", &dummy, (char **)&spl, OPT_LOCAL); + get_option_value("spl", &dummy, &spl, OPT_LOCAL); // Create a new empty buffer in a new window. do_cmdline_cmd("new"); // enable spelling locally in the new window set_option_value("spell", true, "", OPT_LOCAL); - set_option_value("spl", dummy, (char *)spl, OPT_LOCAL); + set_option_value("spl", dummy, spl, OPT_LOCAL); xfree(spl); if (!buf_is_empty(curbuf)) { diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index b7ee3e7374..f099d1b34e 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -575,7 +575,7 @@ slang_T *spell_load_file(char_u *fname, char_u *lang, slang_T *old_lp, bool sile char_u *p; int n; int len; - char_u *save_sourcing_name = sourcing_name; + char_u *save_sourcing_name = (char_u *)sourcing_name; linenr_T save_sourcing_lnum = sourcing_lnum; slang_T *lp = NULL; int c = 0; @@ -605,13 +605,13 @@ slang_T *spell_load_file(char_u *fname, char_u *lang, slang_T *old_lp, bool sile lp->sl_fname = vim_strsave(fname); // Check for .add.spl. - lp->sl_add = strstr((char *)path_tail(fname), SPL_FNAME_ADD) != NULL; + lp->sl_add = strstr(path_tail((char *)fname), SPL_FNAME_ADD) != NULL; } else { lp = old_lp; } // Set sourcing_name, so that error messages mention the file name. - sourcing_name = fname; + sourcing_name = (char *)fname; sourcing_lnum = 0; // <HEADER>: <fileID> @@ -809,7 +809,7 @@ endOK: if (fd != NULL) { fclose(fd); } - sourcing_name = save_sourcing_name; + sourcing_name = (char *)save_sourcing_name; sourcing_lnum = save_sourcing_lnum; return lp; @@ -2251,7 +2251,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) } } else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2)) { // Don't use the first rule if it is a number. - if (compflags != NULL || *skipdigits(items[1]) != NUL) { + if (compflags != NULL || *skipdigits((char *)items[1]) != NUL) { // Concatenate this string to previously defined ones, // using a slash to separate them. l = (int)STRLEN(items[1]) + 1; @@ -4401,7 +4401,7 @@ static int write_vim_spell(spellinfo_T *spin, char_u *fname) // Also skip this for an .add.spl file, the main spell file must contain // the table (avoids that it conflicts). File is shorter too. if (!spin->si_ascii && !spin->si_add) { - char_u folchars[128 * 8]; + char folchars[128 * 8]; int flags; putc(SN_CHARFLAGS, fd); // <sectionID> @@ -5320,19 +5320,19 @@ static void mkspell(int fcount, char_u **fnames, bool ascii, bool over_write, bo } // Check for .ascii.spl. - if (strstr((char *)path_tail(wfname), SPL_FNAME_ASCII) != NULL) { + if (strstr(path_tail((char *)wfname), SPL_FNAME_ASCII) != NULL) { spin.si_ascii = true; } // Check for .add.spl. - if (strstr((char *)path_tail(wfname), SPL_FNAME_ADD) != NULL) { + if (strstr(path_tail((char *)wfname), SPL_FNAME_ADD) != NULL) { spin.si_add = true; } } if (incount <= 0) { emsg(_(e_invarg)); // need at least output and input names - } else if (vim_strchr(path_tail(wfname), '_') != NULL) { + } else if (vim_strchr((char_u *)path_tail((char *)wfname), '_') != NULL) { emsg(_("E751: Output file name must not have region name")); } else if (incount > MAXREGIONS) { semsg(_("E754: Only up to %d regions supported"), MAXREGIONS); @@ -5357,7 +5357,7 @@ static void mkspell(int fcount, char_u **fnames, bool ascii, bool over_write, bo if (incount > 1) { len = (int)STRLEN(innames[i]); - if (STRLEN(path_tail(innames[i])) < 5 + if (STRLEN(path_tail((char *)innames[i])) < 5 || innames[i][len - 3] != '_') { semsg(_("E755: Invalid region in %s"), innames[i]); goto theend; @@ -5725,7 +5725,7 @@ static void init_spellfile(void) ->lp_slang->sl_fname; vim_snprintf((char *)buf + l, MAXPATHL - l, ".%s.add", ((fname != NULL - && strstr((char *)path_tail(fname), ".ascii.") != NULL) + && strstr(path_tail((char *)fname), ".ascii.") != NULL) ? "ascii" : (const char *)spell_enc())); set_option_value("spellfile", 0L, (const char *)buf, OPT_LOCAL); @@ -5862,7 +5862,7 @@ static void set_map_str(slang_T *lp, char_u *map) if (c >= 256) { int cl = utf_char2len(c); int headcl = utf_char2len(headc); - char_u *b; + char *b; hash_T hash; hashitem_T *hi; @@ -5871,10 +5871,10 @@ static void set_map_str(slang_T *lp, char_u *map) b[cl] = NUL; utf_char2bytes(headc, (char *)b + cl + 1); b[cl + 1 + headcl] = NUL; - hash = hash_hash(b); + hash = hash_hash((char_u *)b); hi = hash_lookup(&lp->sl_map_hash, (const char *)b, STRLEN(b), hash); if (HASHITEM_EMPTY(hi)) { - hash_add_item(&lp->sl_map_hash, hi, b, hash); + hash_add_item(&lp->sl_map_hash, hi, (char_u *)b, hash); } else { // This should have been checked when generating the .spl // file. diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index d8d1b736d2..db0e6c8762 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5303,8 +5303,8 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) /// @return FAIL for some error, OK for success. static int get_id_list(char_u **const arg, const int keylen, int16_t **const list, const bool skip) { - char_u *p = NULL; - char_u *end; + char *p = NULL; + char *end; int total_count = 0; int16_t *retval = NULL; regmatch_T regmatch; @@ -5318,12 +5318,12 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis // grow when a regexp is used. In that case round 1 is done once again. for (int round = 1; round <= 2; round++) { // skip "contains" - p = (char_u *)skipwhite((char *)(*arg) + keylen); + p = skipwhite((char *)(*arg) + keylen); if (*p != '=') { semsg(_("E405: Missing equal sign: %s"), *arg); break; } - p = (char_u *)skipwhite((char *)p + 1); + p = skipwhite(p + 1); if (ends_excmd(*p)) { semsg(_("E406: Empty argument: %s"), *arg); break; @@ -5427,11 +5427,11 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis } ++count; } - p = (char_u *)skipwhite((char *)end); + p = skipwhite(end); if (*p != ',') { break; } - p = (char_u *)skipwhite((char *)p + 1); // skip comma in between arguments + p = skipwhite(p + 1); // skip comma in between arguments } while (!ends_excmd(*p)); if (failed) { break; @@ -5443,7 +5443,7 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis } } - *arg = p; + *arg = (char_u *)p; if (failed || retval == NULL) { xfree(retval); return FAIL; @@ -5763,26 +5763,26 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg) * Function given to ExpandGeneric() to obtain the list syntax names for * expansion. */ -char_u *get_syntax_name(expand_T *xp, int idx) +char *get_syntax_name(expand_T *xp, int idx) { switch (expand_what) { case EXP_SUBCMD: - return (char_u *)subcommands[idx].name; + return subcommands[idx].name; case EXP_CASE: { static char *case_args[] = { "match", "ignore", NULL }; - return (char_u *)case_args[idx]; + return case_args[idx]; } case EXP_SPELL: { static char *spell_args[] = { "toplevel", "notoplevel", "default", NULL }; - return (char_u *)spell_args[idx]; + return spell_args[idx]; } case EXP_SYNC: { static char *sync_args[] = { "ccomment", "clear", "fromstart", "linebreaks=", "linecont", "lines=", "match", "maxlines=", "minlines=", "region", NULL }; - return (char_u *)sync_args[idx]; + return sync_args[idx]; } } return NULL; @@ -5965,17 +5965,17 @@ static void syntime_clear(void) * Function given to ExpandGeneric() to obtain the possible arguments of the * ":syntime {on,off,clear,report}" command. */ -char_u *get_syntime_arg(expand_T *xp, int idx) +char *get_syntime_arg(expand_T *xp, int idx) { switch (idx) { case 0: - return (char_u *)"on"; + return "on"; case 1: - return (char_u *)"off"; + return "off"; case 2: - return (char_u *)"clear"; + return "clear"; case 3: - return (char_u *)"report"; + return "report"; } return NULL; } diff --git a/src/nvim/tag.c b/src/nvim/tag.c index ec4b97963c..1f0d027321 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2369,7 +2369,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf) } ++tnp->tn_hf_idx; STRCPY(buf, p_hf); - STRCPY(path_tail(buf), "tags"); + STRCPY(path_tail((char *)buf), "tags"); #ifdef BACKSLASH_IN_FILENAME slash_adjust(buf); #endif @@ -2428,7 +2428,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf) r_ptr = vim_findfile_stopdir(buf); // move the filename one char forward and truncate the // filepath with a NUL - filename = path_tail(buf); + filename = (char_u *)path_tail((char *)buf); STRMOVE(filename + 1, filename); *filename++ = NUL; @@ -2715,7 +2715,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) * autocommand event (e.g., http://sys/file). */ if (!os_path_exists(fname) - && !has_autocmd(EVENT_BUFREADCMD, fname, + && !has_autocmd(EVENT_BUFREADCMD, (char *)fname, NULL)) { retval = NOTAGFILE; xfree(nofile_fname); @@ -2997,7 +2997,7 @@ static char_u *expand_tag_fname(char_u *fname, char_u *const tag_fname, const bo char_u *retval; if ((p_tr || curbuf->b_help) && !vim_isAbsName(fname) - && (p = path_tail(tag_fname)) != tag_fname) { + && (p = (char_u *)path_tail((char *)tag_fname)) != tag_fname) { retval = xmalloc(MAXPATHL); STRCPY(retval, tag_fname); STRLCPY(retval + (p - tag_fname), fname, @@ -3054,7 +3054,7 @@ static int find_extra(char_u **pp) // Repeat for addresses separated with ';' for (;;) { if (ascii_isdigit(*str)) { - str = skipdigits(str + 1); + str = (char_u *)skipdigits((char *)str + 1); } else if (*str == '/' || *str == '?') { str = skip_regexp(str + 1, *str, false, NULL); if (*str != first_char) { diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 937e86b161..d2dc333855 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -702,7 +702,7 @@ char *u_get_undo_file_name(const char *const buf_ffname, const bool reading) const size_t ffname_len = strlen(ffname); undo_file_name = xmalloc(ffname_len + 6); memmove(undo_file_name, ffname, ffname_len + 1); - char *const tail = (char *)path_tail((char_u *)undo_file_name); + char *const tail = path_tail(undo_file_name); const size_t tail_len = strlen(tail); memmove(tail + 1, tail, tail_len + 1); *tail = '.'; diff --git a/src/nvim/window.c b/src/nvim/window.c index 3420e5a10d..9f7e2f8341 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6477,7 +6477,7 @@ char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum) char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u *rel_fname, linenr_T *file_lnum) { - char_u *ptr; + char *ptr; size_t len; bool in_type = true; bool is_url = false; @@ -6485,7 +6485,7 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u /* * search forward for what could be the start of a file name */ - ptr = line + col; + ptr = (char *)line + col; while (*ptr != NUL && !vim_isfilec(*ptr)) { MB_PTR_ADV(ptr); } @@ -6500,11 +6500,10 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u * Search backward for first char of the file name. * Go one char back to ":" before "//" even when ':' is not in 'isfname'. */ - while (ptr > line) { - if ((len = (size_t)(utf_head_off(line, ptr - 1))) > 0) { + while ((char_u *)ptr > line) { + if ((len = (size_t)(utf_head_off(line, (char_u *)ptr - 1))) > 0) { ptr -= len + 1; - } else if (vim_isfilec(ptr[-1]) - || ((options & FNAME_HYP) && path_is_url((char *)ptr - 1))) { + } else if (vim_isfilec(ptr[-1]) || ((options & FNAME_HYP) && path_is_url(ptr - 1))) { ptr--; } else { break; @@ -6517,13 +6516,13 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u */ len = 0; while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ') - || ((options & FNAME_HYP) && path_is_url((char *)ptr + len)) + || ((options & FNAME_HYP) && path_is_url(ptr + len)) || (is_url && vim_strchr((char_u *)":?&=", ptr[len]) != NULL)) { // After type:// we also include :, ?, & and = as valid characters, so that // http://google.com:8080?q=this&that=ok works. if ((ptr[len] >= 'A' && ptr[len] <= 'Z') || (ptr[len] >= 'a' && ptr[len] <= 'z')) { - if (in_type && path_is_url((char *)ptr + len + 1)) { + if (in_type && path_is_url(ptr + len + 1)) { is_url = true; } } else { @@ -6534,7 +6533,7 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u // Skip over the "\" in "\ ". ++len; } - len += (size_t)(utfc_ptr2len((char *)ptr + len)); + len += (size_t)(utfc_ptr2len(ptr + len)); } /* @@ -6547,7 +6546,7 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u } if (file_lnum != NULL) { - char_u *p; + char *p; const char *line_english = " line "; const char *line_transl = _(line_msg); @@ -6560,20 +6559,20 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u } else if (STRNCMP(p, line_transl, STRLEN(line_transl)) == 0) { p += STRLEN(line_transl); } else { - p = (char_u *)skipwhite((char *)p); + p = skipwhite(p); } if (*p != NUL) { if (!isdigit(*p)) { p++; // skip the separator } - p = (char_u *)skipwhite((char *)p); + p = skipwhite(p); if (isdigit(*p)) { - *file_lnum = getdigits_long(&p, false, 0); + *file_lnum = getdigits_long((char_u **)&p, false, 0); } } } - return find_file_name_in_path(ptr, len, options, count, rel_fname); + return find_file_name_in_path((char_u *)ptr, len, options, count, rel_fname); } /// Add or remove a status line from window(s), according to the |