aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-01-14 08:58:28 +0100
committerGitHub <noreply@github.com>2023-01-14 15:58:28 +0800
commite89c39d6f016a4140293755250e968e839009617 (patch)
treef5dc79208bd54132ea364511c559f83bc9cd1e95
parent9220755302317e8030c5bbf334357c0d64df9fa4 (diff)
downloadrneovim-e89c39d6f016a4140293755250e968e839009617.tar.gz
rneovim-e89c39d6f016a4140293755250e968e839009617.tar.bz2
rneovim-e89c39d6f016a4140293755250e968e839009617.zip
refactor: replace char_u with char 21 (#21779)
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
-rw-r--r--src/nvim/cmdexpand.c52
-rw-r--r--src/nvim/cursor.c12
-rw-r--r--src/nvim/diff.c4
-rw-r--r--src/nvim/digraph.c4
-rw-r--r--src/nvim/drawline.c12
-rw-r--r--src/nvim/edit.c12
-rw-r--r--src/nvim/eval.c8
-rw-r--r--src/nvim/eval/funcs.c6
-rw-r--r--src/nvim/eval/userfunc.c12
-rw-r--r--src/nvim/eval/vars.c2
-rw-r--r--src/nvim/ex_cmds.c12
-rw-r--r--src/nvim/ex_docmd.c28
-rw-r--r--src/nvim/ex_getln.c30
-rw-r--r--src/nvim/ex_session.c2
-rw-r--r--src/nvim/file_search.c22
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/grid.c4
-rw-r--r--src/nvim/indent.c10
-rw-r--r--src/nvim/insexpand.c260
-rw-r--r--src/nvim/locale.c3
-rw-r--r--src/nvim/lua/stdlib.c2
-rw-r--r--src/nvim/mapping.c12
-rw-r--r--src/nvim/mark.c10
-rw-r--r--src/nvim/mbyte.c18
-rw-r--r--src/nvim/memline.c22
-rw-r--r--src/nvim/menu.c4
-rw-r--r--src/nvim/mouse.c14
-rw-r--r--src/nvim/normal.c26
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/option.c18
-rw-r--r--src/nvim/os/env.c6
-rw-r--r--src/nvim/os/fs.c2
-rw-r--r--src/nvim/os/shell.c60
-rw-r--r--src/nvim/path.c103
-rw-r--r--src/nvim/plines.c40
-rw-r--r--src/nvim/popupmenu.c24
-rw-r--r--src/nvim/popupmenu.h8
-rw-r--r--src/nvim/profile.c8
-rw-r--r--src/nvim/quickfix.c6
-rw-r--r--src/nvim/regexp.c2
-rw-r--r--src/nvim/regexp_bt.c2
-rw-r--r--src/nvim/regexp_nfa.c2
-rw-r--r--src/nvim/screen.c30
-rw-r--r--src/nvim/search.c24
-rw-r--r--src/nvim/shada.c2
-rw-r--r--src/nvim/spell.c10
-rw-r--r--src/nvim/spellfile.c10
-rw-r--r--src/nvim/spellsuggest.c4
-rw-r--r--src/nvim/tag.c20
-rw-r--r--src/nvim/undo.c12
-rw-r--r--src/nvim/usercmd.c6
51 files changed, 499 insertions, 507 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index bd0fbe7359..be2db2a2e5 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -73,7 +73,7 @@
typedef char *(*CompleteListItemGetter)(expand_T *, int);
/// Type used by call_user_expand_func
-typedef void *(*user_expand_func_T)(const char_u *, int, typval_T *);
+typedef void *(*user_expand_func_T)(const char *, int, typval_T *);
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "cmdexpand.c.generated.h"
@@ -104,7 +104,7 @@ static int sort_func_compare(const void *s1, const void *s2)
}
/// Escape special characters in the cmdline completion matches.
-static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files, int options)
+static void ExpandEscape(expand_T *xp, char *str, int numfiles, char **files, int options)
{
int i;
char *p;
@@ -306,9 +306,9 @@ void cmdline_pum_cleanup(CmdlineInfo *cclp)
/// Return the number of characters that should be skipped in the wildmenu
/// These are backslashes used for escaping. Do show backslashes in help tags.
-static int skip_wildmenu_char(expand_T *xp, char_u *s)
+static int skip_wildmenu_char(expand_T *xp, char *s)
{
- if ((rem_backslash((char *)s) && xp->xp_context != EXPAND_HELP)
+ if ((rem_backslash(s) && xp->xp_context != EXPAND_HELP)
|| ((xp->xp_context == EXPAND_MENUS || xp->xp_context == EXPAND_MENUNAMES)
&& (s[0] == '\t' || (s[0] == '\\' && s[1] != NUL)))) {
#ifndef BACKSLASH_IN_FILENAME
@@ -326,7 +326,7 @@ static int skip_wildmenu_char(expand_T *xp, char_u *s)
}
/// Get the length of an item as it will be shown in the status line.
-static int wildmenu_match_len(expand_T *xp, char_u *s)
+static int wildmenu_match_len(expand_T *xp, char *s)
{
int len = 0;
@@ -334,13 +334,13 @@ static int wildmenu_match_len(expand_T *xp, char_u *s)
|| xp->xp_context == EXPAND_MENUNAMES);
// Check for menu separators - replace with '|'.
- if (emenu && menu_is_separator((char *)s)) {
+ if (emenu && menu_is_separator(s)) {
return 1;
}
while (*s != NUL) {
s += skip_wildmenu_char(xp, s);
- len += ptr2cells((char *)s);
+ len += ptr2cells(s);
MB_PTR_ADV(s);
}
@@ -385,7 +385,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
highlight = false;
}
// count 1 for the ending ">"
- clen = wildmenu_match_len(xp, (char_u *)L_MATCH(match)) + 3;
+ clen = wildmenu_match_len(xp, L_MATCH(match)) + 3;
if (match == 0) {
first_match = 0;
} else if (match < first_match) {
@@ -395,7 +395,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
} else {
// check if match fits on the screen
for (i = first_match; i < match; i++) {
- clen += wildmenu_match_len(xp, (char_u *)L_MATCH(i)) + 2;
+ clen += wildmenu_match_len(xp, L_MATCH(i)) + 2;
}
if (first_match > 0) {
clen += 2;
@@ -406,7 +406,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
// if showing the last match, we can add some on the left
clen = 2;
for (i = match; i < num_matches; i++) {
- clen += wildmenu_match_len(xp, (char_u *)L_MATCH(i)) + 2;
+ clen += wildmenu_match_len(xp, L_MATCH(i)) + 2;
if ((long)clen >= Columns) {
break;
}
@@ -418,7 +418,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
}
if (add_left) {
while (first_match > 0) {
- clen += wildmenu_match_len(xp, (char_u *)L_MATCH(first_match - 1)) + 2;
+ clen += wildmenu_match_len(xp, L_MATCH(first_match - 1)) + 2;
if ((long)clen >= Columns) {
break;
}
@@ -438,7 +438,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
clen = len;
i = first_match;
- while (clen + wildmenu_match_len(xp, (char_u *)L_MATCH(i)) + 2 < Columns) {
+ while (clen + wildmenu_match_len(xp, L_MATCH(i)) + 2 < Columns) {
if (i == match) {
selstart = buf + len;
selstart_col = clen;
@@ -455,7 +455,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
clen += l;
} else {
for (; *s != NUL; s++) {
- s += skip_wildmenu_char(xp, (char_u *)s);
+ s += skip_wildmenu_char(xp, s);
clen += ptr2cells(s);
if ((l = utfc_ptr2len(s)) > 1) {
strncpy(buf + len, s, (size_t)l); // NOLINT(runtime/printf)
@@ -604,7 +604,7 @@ static char *ExpandOne_start(int mode, expand_T *xp, char *str, int options)
}
} else {
// Escape the matches for use on the command line.
- ExpandEscape(xp, (char_u *)str, xp->xp_numfiles, xp->xp_files, options);
+ ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options);
// Check for matching suffixes in file names.
if (mode != WILD_ALL && mode != WILD_ALL_KEEP
@@ -865,7 +865,7 @@ int showmatches(expand_T *xp, int wildmenu)
compl_match_array = xmalloc(sizeof(pumitem_T) * (size_t)compl_match_arraysize);
for (i = 0; i < num_files; i++) {
compl_match_array[i] = (pumitem_T){
- .pum_text = (char_u *)L_SHOWFILE(i),
+ .pum_text = L_SHOWFILE(i),
.pum_info = NULL,
.pum_extra = NULL,
.pum_kind = NULL,
@@ -958,7 +958,7 @@ int showmatches(expand_T *xp, int wildmenu)
// Expansion was done before and special characters
// were escaped, need to halve backslashes. Also
// $HOME has been replaced with ~/.
- char *exp_path = (char *)expand_env_save_opt((char_u *)files_found[k], true);
+ char *exp_path = (char *)expand_env_save_opt(files_found[k], true);
char *path = exp_path != NULL ? exp_path : files_found[k];
char *halved_slash = backslash_halve_save(path);
j = os_isdir(halved_slash);
@@ -1245,7 +1245,7 @@ void set_expand_context(expand_T *xp)
xp->xp_context = EXPAND_NOTHING;
return;
}
- set_cmd_context(xp, (char_u *)ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, true);
+ set_cmd_context(xp, ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, true);
}
/// Sets the index of a built-in or user defined command "cmd" in eap->cmdidx.
@@ -2104,10 +2104,10 @@ static const char *set_one_cmd_context(expand_T *xp, const char *buff)
/// @param len length of command line (excl. NUL)
/// @param col position of cursor
/// @param use_ccline use ccline for info
-void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline)
+void set_cmd_context(expand_T *xp, char *str, int len, int col, int use_ccline)
{
CmdlineInfo *const ccline = get_cmdline_info();
- char_u old_char = NUL;
+ char old_char = NUL;
// Avoid a UMR warning from Purify, only save the character if it has been
// written before.
@@ -2119,7 +2119,7 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline
if (use_ccline && ccline->cmdfirstc == '=') {
// pass CMD_SIZE because there is no real command
- set_context_for_expression(xp, (char *)str, CMD_SIZE);
+ set_context_for_expression(xp, str, CMD_SIZE);
} else if (use_ccline && ccline->input_fn) {
xp->xp_context = ccline->xp_context;
xp->xp_pattern = ccline->cmdbuff;
@@ -2132,7 +2132,7 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline
// Store the string here so that call_user_expand_func() can get to them
// easily.
- xp->xp_line = (char *)str;
+ xp->xp_line = str;
xp->xp_col = col;
str[col] = old_char;
@@ -2477,7 +2477,7 @@ static int ExpandFromContext(expand_T *xp, char *pat, int *num_file, char ***fil
}
// set ignore-case according to p_ic, p_scs and pat
- regmatch.rm_ic = ignorecase((char_u *)pat);
+ regmatch.rm_ic = ignorecase(pat);
if (xp->xp_context == EXPAND_SETTINGS
|| xp->xp_context == EXPAND_BOOL_SETTINGS) {
@@ -2528,7 +2528,7 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha
}
assert(count < INT_MAX);
*num_file = (int)count;
- *file = xmalloc(count * sizeof(char_u *));
+ *file = xmalloc(count * sizeof(char *));
// copy the matching names into allocated memory
count = 0;
@@ -2734,7 +2734,7 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
current_sctx = xp->xp_script_ctx;
- void *const ret = user_expand_func((char_u *)xp->xp_arg, 3, args);
+ void *const ret = user_expand_func(xp->xp_arg, 3, args);
current_sctx = save_current_sctx;
if (ccline->cmdbuff != NULL) {
@@ -2862,7 +2862,7 @@ void globpath(char *path, char *file, garray_T *ga, int expand_options)
(void)ExpandFromContext(&xpc, buf, &num_p, &p,
WILD_SILENT | expand_options);
if (num_p > 0) {
- ExpandEscape(&xpc, (char_u *)buf, num_p, p, WILD_SILENT | expand_options);
+ ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT | expand_options);
// Concatenate new results to previous ones.
ga_grow(ga, num_p);
@@ -3040,7 +3040,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
// TODO(tarruda): this is only for DOS/Unix systems - need to put in
// machine-specific stuff here and in upseg init
cmdline_del(cclp, j);
- put_on_cmdline((char_u *)upseg + 1, 3, false);
+ put_on_cmdline(upseg + 1, 3, false);
} else if (cclp->cmdpos > i) {
cmdline_del(cclp, i);
}
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index 0d56319891..b1dbc68ea3 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -115,7 +115,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
col = wcol;
if ((addspaces || finetune) && !VIsual_active) {
- curwin->w_curswant = linetabsize((char_u *)line) + one_more;
+ curwin->w_curswant = linetabsize(line) + one_more;
if (curwin->w_curswant > 0) {
curwin->w_curswant--;
}
@@ -129,7 +129,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
&& curwin->w_width_inner != 0
&& wcol >= (colnr_T)width
&& width > 0) {
- csize = linetabsize((char_u *)line);
+ csize = linetabsize(line);
if (csize > 0) {
csize--;
}
@@ -178,11 +178,11 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
int correct = wcol - col;
size_t newline_size;
STRICT_ADD(idx, correct, &newline_size, size_t);
- char_u *newline = xmallocz(newline_size);
+ char *newline = xmallocz(newline_size);
memcpy(newline, line, (size_t)idx);
memset(newline + idx, ' ', (size_t)correct);
- ml_replace(pos->lnum, (char *)newline, false);
+ ml_replace(pos->lnum, newline, false);
inserted_bytes(pos->lnum, (colnr_T)idx, 0, correct);
idx += correct;
col = wcol;
@@ -190,7 +190,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
// Break a tab
int linelen = (int)strlen(line);
int correct = wcol - col - csize + 1; // negative!!
- char_u *newline;
+ char *newline;
if (-correct > csize) {
return FAIL;
@@ -208,7 +208,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
STRICT_SUB(n, 1, &n, size_t);
memcpy(newline + idx + csize, line + idx + 1, n);
- ml_replace(pos->lnum, (char *)newline, false);
+ ml_replace(pos->lnum, newline, false);
inserted_bytes(pos->lnum, idx, 1, csize);
idx += (csize - 1 + correct);
col += correct;
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 601d4f0f29..45f00cb41e 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1171,7 +1171,7 @@ static int diff_file(diffio_T *dio)
tmp_orig, tmp_new);
append_redir(cmd, len, p_srr, tmp_diff);
block_autocmds(); // Avoid ShellCmdPost stuff
- (void)call_shell((char_u *)cmd,
+ (void)call_shell(cmd,
kShellOptFilter | kShellOptSilent | kShellOptDoOut,
NULL);
unblock_autocmds();
@@ -1255,7 +1255,7 @@ void ex_diffpatch(exarg_T *eap)
vim_snprintf(buf, buflen, "patch -o %s %s < %s",
tmp_new, tmp_orig, esc_name);
block_autocmds(); // Avoid ShellCmdPost stuff
- (void)call_shell((char_u *)buf, kShellOptFilter, NULL);
+ (void)call_shell(buf, kShellOptFilter, NULL);
unblock_autocmds();
}
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index 1195d6a3f4..33038dfb9f 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -2133,7 +2133,7 @@ void ex_loadkeymap(exarg_T *eap)
vim_snprintf(buf, sizeof(buf), "<buffer> %s %s",
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from,
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to);
- (void)do_map(MAPTYPE_MAP, (char_u *)buf, MODE_LANGMAP, false);
+ (void)do_map(MAPTYPE_MAP, buf, MODE_LANGMAP, false);
}
p_cpo = save_cpo;
@@ -2170,7 +2170,7 @@ static void keymap_unload(void)
for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) {
vim_snprintf(buf, sizeof(buf), "<buffer> %s", kp[i].from);
- (void)do_map(MAPTYPE_UNMAP, (char_u *)buf, MODE_LANGMAP, false);
+ (void)do_map(MAPTYPE_UNMAP, buf, MODE_LANGMAP, false);
}
keymap_ga_clear(&curbuf->b_kmap_ga);
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index bbe78ab556..8fc1a4b029 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -417,7 +417,7 @@ static void get_statuscol_str(win_T *wp, linenr_T lnum, int row, int startrow, i
: get_line_number_attr(wp, lnum, row, startrow, filler_lines);
if (compute_foldcolumn(wp, 0)) {
- size_t n = fill_foldcolumn((char_u *)stcp->fold_text, wp, foldinfo, lnum);
+ size_t n = fill_foldcolumn(stcp->fold_text, wp, foldinfo, lnum);
stcp->fold_text[n] = NUL;
stcp->fold_attr = win_hl_attr(wp, use_cul ? HLF_CLF : HLF_FC);
}
@@ -1239,7 +1239,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
// already be in use.
xfree(p_extra_free);
p_extra_free = xmalloc(MAX_MCO * (size_t)fdc + 1);
- n_extra = (int)fill_foldcolumn((char_u *)p_extra_free, wp, foldinfo, lnum);
+ n_extra = (int)fill_foldcolumn(p_extra_free, wp, foldinfo, lnum);
p_extra_free[n_extra] = NUL;
p_extra = p_extra_free;
c_extra = NUL;
@@ -1366,7 +1366,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
c_extra = ' ';
c_final = NUL;
n_extra =
- get_breakindent_win(wp, (char_u *)ml_get_buf(wp->w_buffer, lnum, false));
+ get_breakindent_win(wp, ml_get_buf(wp->w_buffer, lnum, false));
if (row == startrow) {
n_extra -= win_col_off2(wp);
if (n_extra < 0) {
@@ -1424,7 +1424,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
if (wp->w_skipcol == 0 || !wp->w_p_wrap) {
need_showbreak = false;
}
- vcol_sbr = vcol + mb_charlen((char_u *)sbr);
+ vcol_sbr = vcol + mb_charlen(sbr);
// Correct end of highlighted area for 'showbreak',
// required when 'linebreak' is also set.
if (tocol == vcol) {
@@ -1960,7 +1960,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
// We have just drawn the showbreak value, no need to add
// space for it again.
if (vcol == vcol_sbr) {
- n_extra -= mb_charlen(get_showbreak_value(wp));
+ n_extra -= mb_charlen((char *)get_showbreak_value(wp));
if (n_extra < 0) {
n_extra = 0;
}
@@ -2061,7 +2061,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
// Only adjust the tab_len, when at the first column after the
// showbreak value was drawn.
if (*sbr != NUL && vcol == vcol_sbr && wp->w_p_wrap) {
- vcol_adjusted = vcol - mb_charlen(sbr);
+ vcol_adjusted = vcol - mb_charlen((char *)sbr);
}
// tab amount depends on current column
tab_len = tabstop_padding((colnr_T)vcol_adjusted,
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index f3dea5f612..36a8674730 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -195,7 +195,7 @@ static void insert_enter(InsertState *s)
}
}
- Insstart_textlen = (colnr_T)linetabsize((char_u *)get_cursor_line_ptr());
+ Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
Insstart_blank_vcol = MAXCOL;
if (!did_ai) {
@@ -1442,7 +1442,7 @@ void edit_putchar(int c, bool highlight)
// save the character to be able to put it back
if (pc_status == PC_STATUS_UNSET) {
- grid_getbytes(&curwin->w_grid, pc_row, pc_col, pc_bytes, &pc_attr);
+ grid_getbytes(&curwin->w_grid, pc_row, pc_col, (char *)pc_bytes, &pc_attr);
pc_status = PC_STATUS_SET;
}
grid_putchar(&curwin->w_grid, c, pc_row, pc_col, attr);
@@ -2261,7 +2261,7 @@ int stop_arrow(void)
// right, except when nothing was inserted yet.
update_Insstart_orig = false;
}
- Insstart_textlen = (colnr_T)linetabsize((char_u *)get_cursor_line_ptr());
+ Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
if (u_save_cursor() == OK) {
arrow_used = false;
@@ -3166,7 +3166,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
// search back for the start of a word.
line = get_cursor_line_ptr();
for (s = line + curwin->w_cursor.col; s > line; s = n) {
- n = (char *)mb_prevptr((char_u *)line, (char_u *)s);
+ n = mb_prevptr(line, s);
if (!vim_iswordp(n)) {
break;
}
@@ -4003,7 +4003,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
// Delete up to starting point, start of line or previous word.
int prev_cclass = 0;
- int cclass = mb_get_class((char_u *)get_cursor_pos_ptr());
+ int cclass = mb_get_class(get_cursor_pos_ptr());
do {
if (!revins_on) { // put cursor on char to be deleted
dec_cursor();
@@ -4011,7 +4011,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
cc = gchar_cursor();
// look multi-byte character class
prev_cclass = cclass;
- cclass = mb_get_class((char_u *)get_cursor_pos_ptr());
+ cclass = mb_get_class(get_cursor_pos_ptr());
if (mode == BACKSPACE_WORD && !ascii_isspace(cc)) { // start of word?
mode = BACKSPACE_WORD_NOT_SPACE;
temp = vim_iswordc(cc);
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 74fd6f7e86..f9825496a5 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -6098,7 +6098,7 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret
}
int len;
if (charcol) {
- len = mb_charlen((char_u *)ml_get(pos.lnum));
+ len = mb_charlen(ml_get(pos.lnum));
} else {
len = (int)strlen(ml_get(pos.lnum));
}
@@ -6184,7 +6184,7 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret
} else {
pos.lnum = curwin->w_cursor.lnum;
if (charcol) {
- pos.col = (colnr_T)mb_charlen((char_u *)get_cursor_line_ptr());
+ pos.col = (colnr_T)mb_charlen(get_cursor_line_ptr());
} else {
pos.col = (colnr_T)strlen(get_cursor_line_ptr());
}
@@ -7816,8 +7816,8 @@ repeat:
}
// FullName_save() is slow, don't use it when not needed.
- if (*p != NUL || !vim_isAbsName((char_u *)(*fnamep))) {
- *fnamep = FullName_save((*fnamep), *p != NUL);
+ if (*p != NUL || !vim_isAbsName(*fnamep)) {
+ *fnamep = FullName_save(*fnamep, *p != NUL);
xfree(*bufp); // free any allocated file name
*bufp = *fnamep;
if (*fnamep == NULL) {
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 7820b837da..d6b9ca20fc 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -4962,7 +4962,7 @@ static void f_pathshorten(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
rettv->vval.v_string = NULL;
} else {
rettv->vval.v_string = xstrdup(p);
- shorten_dir_len((char_u *)rettv->vval.v_string, trim_len);
+ shorten_dir_len(rettv->vval.v_string, trim_len);
}
}
@@ -5965,7 +5965,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
# endif
#endif
- simplify_filename((char_u *)rettv->vval.v_string);
+ simplify_filename(rettv->vval.v_string);
}
/// "reverse({list})" function
@@ -7409,7 +7409,7 @@ static void f_simplify(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
const char *const p = tv_get_string(&argvars[0]);
rettv->vval.v_string = xstrdup(p);
- simplify_filename((char_u *)rettv->vval.v_string); // Simplify in place.
+ simplify_filename(rettv->vval.v_string); // Simplify in place.
rettv->v_type = VAR_STRING;
}
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 1c0fe20248..c70d56cd25 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -845,7 +845,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
int fixvar_idx = 0; // index in fixvar[]
int ai;
bool islambda = false;
- char_u numbuf[NUMBUFLEN];
+ char numbuf[NUMBUFLEN];
char *name;
typval_T *tv_to_free[MAX_FUNC_ARGS];
int tv_to_free_len = 0;
@@ -984,8 +984,8 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
break;
}
// "..." argument a:1, a:2, etc.
- snprintf((char *)numbuf, sizeof(numbuf), "%d", ai + 1);
- name = (char *)numbuf;
+ snprintf(numbuf, sizeof(numbuf), "%d", ai + 1);
+ name = numbuf;
}
if (fixvar_idx < FIXVAR_CNT && strlen(name) <= VAR_SHORT_LEN) {
v = (dictitem_T *)&fc->fixvar[fixvar_idx++];
@@ -1524,7 +1524,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
// Make a copy of the name, if it comes from a funcref variable it could
// be changed or deleted in the called function.
name = xstrnsave(funcname, (size_t)len);
- fname = fname_trans_sid(name, (char *)fname_buf, &tofree, &error);
+ fname = fname_trans_sid(name, fname_buf, &tofree, &error);
}
if (funcexe->fe_doesrange != NULL) {
@@ -3303,7 +3303,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv)
? rettv->vval.v_string
: rettv->vval.v_partial->pt_name;
// Translate "s:func" to the stored function name.
- fname = fname_trans_sid(fname, (char *)fname_buf, &tofree, &error);
+ fname = fname_trans_sid(fname, fname_buf, &tofree, &error);
fp = find_func((char_u *)fname);
xfree(tofree);
}
@@ -3649,7 +3649,7 @@ bool set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID)
}
if (fp_in == NULL) {
- fname = fname_trans_sid((char *)name, (char *)fname_buf, &tofree, &error);
+ fname = fname_trans_sid((char *)name, fname_buf, &tofree, &error);
fp = find_func((char_u *)fname);
}
if (fp != NULL) {
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index 463313efd8..206df03381 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -864,7 +864,7 @@ static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_
int cc;
if (lp->ll_tv == NULL) {
- cc = (char_u)(*name_end);
+ cc = (uint8_t)(*name_end);
*name_end = NUL;
// Environment variable, normal name or expanded name.
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 413a488283..c2af0e6986 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -347,7 +347,7 @@ static int linelen(int *has_tab)
char save = *last;
*last = NUL;
// Get line length.
- len = linetabsize((char_u *)line);
+ len = linetabsize(line);
// Check for embedded TAB.
if (has_tab != NULL) {
*has_tab = vim_strchr(first, TAB) != NULL;
@@ -1179,7 +1179,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b
read_linecount = curbuf->b_ml.ml_line_count;
// Pass on the kShellOptDoOut flag when the output is being redirected.
- call_shell((char_u *)cmd_buf, (ShellOpts)(kShellOptFilter | shell_flags), NULL);
+ call_shell(cmd_buf, (ShellOpts)(kShellOptFilter | shell_flags), NULL);
xfree(cmd_buf);
did_check_timestamps = false;
@@ -1324,7 +1324,7 @@ void do_shell(char *cmd, int flags)
// This ui_cursor_goto is required for when the '\n' resulted in a "delete line
// 1" command to the terminal.
ui_cursor_goto(msg_row, msg_col);
- (void)call_shell((char_u *)cmd, (ShellOpts)flags, NULL);
+ (void)call_shell(cmd, (ShellOpts)flags, NULL);
msg_didout = true;
did_check_timestamps = false;
need_check_timestamps = true;
@@ -1367,12 +1367,12 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp)
{
bool is_fish_shell =
#if defined(UNIX)
- strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
+ strncmp((char *)invocation_path_tail(p_sh, NULL), "fish", 4) == 0;
#else
false;
#endif
- bool is_pwsh = strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0
- || strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "powershell",
+ bool is_pwsh = strncmp((char *)invocation_path_tail(p_sh, NULL), "pwsh", 4) == 0
+ || strncmp((char *)invocation_path_tail(p_sh, NULL), "powershell",
10) == 0;
size_t len = strlen(cmd) + 1; // At least enough space for cmd + NULL.
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 8d70dcce9a..e11dd0a2f6 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4965,8 +4965,8 @@ void ex_splitview(exarg_T *eap)
}
if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) {
- fname = (char *)find_file_in_path((char_u *)eap->arg, strlen(eap->arg),
- FNAME_MESS, true, (char_u *)curbuf->b_ffname);
+ fname = (char *)find_file_in_path(eap->arg, strlen(eap->arg),
+ FNAME_MESS, true, curbuf->b_ffname);
if (fname == NULL) {
goto theend;
}
@@ -5158,15 +5158,15 @@ static void ex_resize(exarg_T *eap)
/// ":find [+command] <file>" command.
static void ex_find(exarg_T *eap)
{
- char *fname = (char *)find_file_in_path((char_u *)eap->arg, strlen(eap->arg),
- FNAME_MESS, true, (char_u *)curbuf->b_ffname);
+ char *fname = (char *)find_file_in_path(eap->arg, strlen(eap->arg),
+ FNAME_MESS, true, curbuf->b_ffname);
if (eap->addr_count > 0) {
// Repeat finding the file "count" times. This matters when it
// appears several times in the path.
linenr_T count = eap->line2;
while (fname != NULL && --count > 0) {
xfree(fname);
- fname = (char *)find_file_in_path(NULL, 0, FNAME_MESS, false, (char_u *)curbuf->b_ffname);
+ fname = (char *)find_file_in_path(NULL, 0, FNAME_MESS, false, curbuf->b_ffname);
}
}
@@ -6042,7 +6042,7 @@ static void ex_redir(exarg_T *eap)
return;
}
- redir_fd = open_exfile((char_u *)fname, eap->forceit, mode);
+ redir_fd = open_exfile(fname, eap->forceit, mode);
xfree(fname);
} else if (*arg == '@') {
// redirect to a register a-z (resp. A-Z for appending)
@@ -6215,22 +6215,22 @@ int vim_mkdir_emsg(const char *const name, const int prot)
/// @param mode "w" for create new file or "a" for append
///
/// @return file descriptor, or NULL on failure.
-FILE *open_exfile(char_u *fname, int forceit, char *mode)
+FILE *open_exfile(char *fname, int forceit, char *mode)
{
#ifdef UNIX
// with Unix it is possible to open a directory
- if (os_isdir((char *)fname)) {
+ if (os_isdir(fname)) {
semsg(_(e_isadir2), fname);
return NULL;
}
#endif
- if (!forceit && *mode != 'a' && os_path_exists((char *)fname)) {
+ if (!forceit && *mode != 'a' && os_path_exists(fname)) {
semsg(_("E189: \"%s\" exists (add ! to override)"), fname);
return NULL;
}
FILE *fd;
- if ((fd = os_fopen((char *)fname, mode)) == NULL) {
+ if ((fd = os_fopen(fname, mode)) == NULL) {
semsg(_("E190: Cannot open \"%s\" for writing"), fname);
}
@@ -6387,7 +6387,7 @@ static void ex_normal(exarg_T *eap)
check_cursor_moved(curwin);
}
- exec_normal_cmd((char_u *)(arg != NULL ? arg : eap->arg),
+ exec_normal_cmd((arg != NULL ? arg : eap->arg),
eap->forceit ? REMAP_NONE : REMAP_YES, false);
} while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int);
}
@@ -6451,10 +6451,10 @@ static void ex_stopinsert(exarg_T *eap)
/// Execute normal mode command "cmd".
/// "remap" can be REMAP_NONE or REMAP_YES.
-void exec_normal_cmd(char_u *cmd, int remap, bool silent)
+void exec_normal_cmd(char *cmd, int remap, bool silent)
{
// Stuff the argument into the typeahead buffer.
- ins_typebuf((char *)cmd, remap, 0, true, silent);
+ ins_typebuf(cmd, remap, 0, true, silent);
exec_normal(false);
}
@@ -6859,7 +6859,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T
*errormsg = _("E495: no autocommand file name to substitute for \"<afile>\"");
return NULL;
}
- result = (char *)path_try_shorten_fname((char_u *)result);
+ result = path_try_shorten_fname(result);
break;
case SPEC_ABUF: // buffer number for autocommand
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index eeb983fc21..b73ed98443 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1466,27 +1466,27 @@ static int command_line_erase_chars(CommandLineState *s)
}
if (ccline.cmdpos > 0) {
- char_u *p;
+ char *p;
int j = ccline.cmdpos;
- p = mb_prevptr((char_u *)ccline.cmdbuff, (char_u *)ccline.cmdbuff + j);
+ p = mb_prevptr(ccline.cmdbuff, ccline.cmdbuff + j);
if (s->c == Ctrl_W) {
- while (p > (char_u *)ccline.cmdbuff && ascii_isspace(*p)) {
- p = mb_prevptr((char_u *)ccline.cmdbuff, p);
+ while (p > ccline.cmdbuff && ascii_isspace(*p)) {
+ p = mb_prevptr(ccline.cmdbuff, p);
}
int i = mb_get_class(p);
- while (p > (char_u *)ccline.cmdbuff && mb_get_class(p) == i) {
- p = mb_prevptr((char_u *)ccline.cmdbuff, p);
+ while (p > ccline.cmdbuff && mb_get_class(p) == i) {
+ p = mb_prevptr(ccline.cmdbuff, p);
}
if (mb_get_class(p) != i) {
- p += utfc_ptr2len((char *)p);
+ p += utfc_ptr2len(p);
}
}
- ccline.cmdpos = (int)(p - (char_u *)ccline.cmdbuff);
+ ccline.cmdpos = (int)(p - ccline.cmdbuff);
ccline.cmdlen -= j - ccline.cmdpos;
int i = ccline.cmdpos;
@@ -2097,11 +2097,11 @@ static int command_line_handle_key(CommandLineState *s)
// put the character in the command line
if (IS_SPECIAL(s->c) || mod_mask != 0) {
- put_on_cmdline(get_special_key_name(s->c, mod_mask), -1, true);
+ put_on_cmdline((char *)get_special_key_name(s->c, mod_mask), -1, true);
} else {
int j = utf_char2bytes(s->c, IObuff);
IObuff[j] = NUL; // exclude composing chars
- put_on_cmdline((char_u *)IObuff, j, true);
+ put_on_cmdline(IObuff, j, true);
}
return command_line_changed(s);
}
@@ -3509,14 +3509,14 @@ void unputcmdline(void)
// part will be redrawn, otherwise it will not. If this function is called
// twice in a row, then 'redraw' should be false and redrawcmd() should be
// called afterwards.
-void put_on_cmdline(char_u *str, int len, int redraw)
+void put_on_cmdline(char *str, int len, int redraw)
{
int i;
int m;
int c;
if (len < 0) {
- len = (int)strlen((char *)str);
+ len = (int)strlen(str);
}
realloc_cmdbuff(ccline.cmdlen + len + 1);
@@ -3529,7 +3529,7 @@ void put_on_cmdline(char_u *str, int len, int redraw)
} else {
// Count nr of characters in the new string.
m = 0;
- for (i = 0; i < len; i += utfc_ptr2len((char *)str + i)) {
+ for (i = 0; i < len; i += utfc_ptr2len(str + i)) {
m++;
}
// Count nr of bytes in cmdline that are overwritten by these
@@ -3725,7 +3725,7 @@ void cmdline_paste_str(char_u *s, int literally)
int c, cv;
if (literally) {
- put_on_cmdline(s, -1, true);
+ put_on_cmdline((char *)s, -1, true);
} else {
while (*s != NUL) {
cv = *s;
@@ -4000,7 +4000,7 @@ void escape_fname(char **pp)
/// For each file name in files[num_files]:
/// If 'orig_pat' starts with "~/", replace the home directory with "~".
-void tilde_replace(char_u *orig_pat, int num_files, char **files)
+void tilde_replace(char *orig_pat, int num_files, char **files)
{
char *p;
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index 48d52fa5f9..cae9c18309 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -964,7 +964,7 @@ void ex_mkrc(exarg_T *eap)
vim_mkdir_emsg((const char *)p_vdir, 0755);
}
- fd = open_exfile((char_u *)fname, eap->forceit, WRITEBIN);
+ fd = open_exfile(fname, eap->forceit, WRITEBIN);
if (fd != NULL) {
if (eap->cmdidx == CMD_mkview) {
flagp = &vop_flags;
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index fe46e457d5..d0280b3571 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -288,7 +288,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
&& rel_fname != NULL) {
size_t len = (size_t)(path_tail(rel_fname) - rel_fname);
- if (!vim_isAbsName((char_u *)rel_fname) && len + 1 < MAXPATHL) {
+ if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) {
// Make the start dir an absolute path name.
xstrlcpy(ff_expand_buffer, rel_fname, len + 1);
search_ctx->ffsc_start_dir = FullName_save(ff_expand_buffer, false);
@@ -298,7 +298,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
if (*++path != NUL) {
path++;
}
- } else if (*path == NUL || !vim_isAbsName((char_u *)path)) {
+ } else if (*path == NUL || !vim_isAbsName(path)) {
#ifdef BACKSLASH_IN_FILENAME
// "c:dir" needs "c:" to be expanded, otherwise use current dir
if (*path != NUL && path[1] == ':') {
@@ -504,9 +504,9 @@ error_return:
}
/// @return the stopdir string. Check that ';' is not escaped.
-char_u *vim_findfile_stopdir(char_u *buf)
+char_u *vim_findfile_stopdir(char *buf)
{
- char_u *r_ptr = buf;
+ char_u *r_ptr = (char_u *)buf;
while (*r_ptr != NUL && *r_ptr != ';') {
if (r_ptr[0] == '\\' && r_ptr[1] == ';') {
@@ -654,7 +654,7 @@ char_u *vim_findfile(void *search_ctx_arg)
dirptrs[1] = NULL;
// if we have a start dir copy it in
- if (!vim_isAbsName((char_u *)stackp->ffs_fix_path)
+ if (!vim_isAbsName(stackp->ffs_fix_path)
&& search_ctx->ffsc_start_dir) {
if (strlen(search_ctx->ffsc_start_dir) + 1 >= MAXPATHL) {
ff_free_stack_element(stackp);
@@ -813,7 +813,7 @@ char_u *vim_findfile(void *search_ctx_arg)
ff_push(search_ctx, stackp);
if (!path_with_url(file_path)) {
- simplify_filename((char_u *)file_path);
+ simplify_filename(file_path);
}
if (os_dirname(ff_expand_buffer, MAXPATHL) == OK) {
p = path_shorten_fname(file_path, ff_expand_buffer);
@@ -1287,13 +1287,13 @@ static int ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v)
/// @param rel_fname file name searching relative to
///
/// @return an allocated string for the file name. NULL for error.
-char_u *find_file_in_path(char_u *ptr, size_t len, int options, int first, char_u *rel_fname)
+char_u *find_file_in_path(char *ptr, size_t len, int options, int first, char *rel_fname)
{
- return (char_u *)find_file_in_path_option((char *)ptr, len, options, first,
+ return (char_u *)find_file_in_path_option(ptr, len, options, first,
(*curbuf->b_p_path == NUL
? (char *)p_path
: curbuf->b_p_path),
- FINDFILE_BOTH, (char *)rel_fname, curbuf->b_p_sua);
+ FINDFILE_BOTH, rel_fname, curbuf->b_p_sua);
}
static char *ff_file_to_find = NULL;
@@ -1379,7 +1379,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch
|| (ff_file_to_find[1] == '.'
&& (ff_file_to_find[2] == NUL
|| vim_ispathsep(ff_file_to_find[2])))));
- if (vim_isAbsName((char_u *)ff_file_to_find)
+ if (vim_isAbsName(ff_file_to_find)
// "..", "../path", "." and "./path": don't use the path_option
|| rel_to_curdir
#if defined(MSWIN)
@@ -1469,7 +1469,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch
copy_option_part(&dir, buf, MAXPATHL, " ,");
// get the stopdir string
- r_ptr = (char *)vim_findfile_stopdir((char_u *)buf);
+ r_ptr = (char *)vim_findfile_stopdir(buf);
fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find,
r_ptr, 100, false, find_what,
fdip_search_ctx, false, rel_fname);
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index fb45157d9c..0ee547d124 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -488,7 +488,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
}
}
if (!silent) {
- if (dir_of_file_exists((char_u *)fname)) {
+ if (dir_of_file_exists(fname)) {
filemess(curbuf, sfname, new_file_message(), 0);
} else {
filemess(curbuf, sfname, _("[New DIRECTORY]"), 0);
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index 87b232eec3..4702e224c6 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -140,7 +140,7 @@ void grid_putchar(ScreenGrid *grid, int c, int row, int col, int attr)
/// get a single character directly from grid.chars into "bytes[]".
/// Also return its attribute in *attrp;
-void grid_getbytes(ScreenGrid *grid, int row, int col, char_u *bytes, int *attrp)
+void grid_getbytes(ScreenGrid *grid, int row, int col, char *bytes, int *attrp)
{
size_t off;
@@ -150,7 +150,7 @@ void grid_getbytes(ScreenGrid *grid, int row, int col, char_u *bytes, int *attrp
if (grid->chars != NULL && row < grid->rows && col < grid->cols) {
off = grid->line_offset[row] + (size_t)col;
*attrp = grid->attrs[off];
- schar_copy((char *)bytes, grid->chars[off]);
+ schar_copy(bytes, grid->chars[off]);
}
}
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 27d6f60011..be1dfb77cf 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -798,7 +798,7 @@ bool briopt_check(win_T *wp)
// Return appropriate space number for breakindent, taking influencing
// parameters into account. Window must be specified, since it is not
// necessarily always the current one.
-int get_breakindent_win(win_T *wp, char_u *line)
+int get_breakindent_win(win_T *wp, char *line)
FUNC_ATTR_NONNULL_ALL
{
static int prev_indent = 0; // Cached indent value.
@@ -820,17 +820,17 @@ int get_breakindent_win(win_T *wp, char_u *line)
// - 'tabstop' changed
// - 'briopt_list changed' changed or
// - 'formatlistpattern' changed
- if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts
+ if (prev_line != (char_u *)line || prev_ts != wp->w_buffer->b_p_ts
|| prev_tick != buf_get_changedtick(wp->w_buffer)
|| prev_listopt != wp->w_briopt_list
|| (prev_flp == NULL || (strcmp(prev_flp, get_flp_value(wp->w_buffer)) != 0))
|| prev_vts != wp->w_buffer->b_p_vts_array) {
- prev_line = line;
+ prev_line = (char_u *)line;
prev_ts = wp->w_buffer->b_p_ts;
prev_tick = buf_get_changedtick(wp->w_buffer);
prev_vts = wp->w_buffer->b_p_vts_array;
if (wp->w_briopt_vcol == 0) {
- prev_indent = get_indent_str_vtab((char *)line,
+ prev_indent = get_indent_str_vtab(line,
wp->w_buffer->b_p_ts,
wp->w_buffer->b_p_vts_array,
wp->w_p_list);
@@ -846,7 +846,7 @@ int get_breakindent_win(win_T *wp, char_u *line)
};
if (regmatch.regprog != NULL) {
regmatch.rm_ic = false;
- if (vim_regexec(&regmatch, (char *)line, 0)) {
+ if (vim_regexec(&regmatch, line, 0)) {
if (wp->w_briopt_list > 0) {
prev_list += wp->w_briopt_list;
} else {
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index fcf64d6ae7..fa8e78f624 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -169,7 +169,7 @@ typedef struct {
pos_T first_match_pos; ///< first match position
pos_T last_match_pos; ///< last match position
bool found_all; ///< found all matches of a certain type.
- char_u *dict; ///< dictionary file to search
+ char *dict; ///< dictionary file to search
int dict_f; ///< "dict" is an exact file name or not
} ins_compl_next_state_T;
@@ -588,8 +588,8 @@ bool ins_compl_accept_char(int c)
/// Get the completed text by inferring the case of the originally typed text.
/// If the result is in allocated memory "tofree" is set to it.
-static char_u *ins_compl_infercase_gettext(const char_u *str, int char_len, int compl_char_len,
- int min_len, char **tofree)
+static char *ins_compl_infercase_gettext(const char *str, int char_len, int compl_char_len,
+ int min_len, char **tofree)
{
bool has_lower = false;
bool was_letter = false;
@@ -597,7 +597,7 @@ static char_u *ins_compl_infercase_gettext(const char_u *str, int char_len, int
// Allocate wide character array for the completion and fill it.
int *const wca = xmalloc((size_t)char_len * sizeof(*wca));
{
- const char_u *p = str;
+ const char_u *p = (char_u *)str;
for (int i = 0; i < char_len; i++) {
wca[i] = mb_ptr2char_adv(&p);
}
@@ -683,7 +683,7 @@ static char_u *ins_compl_infercase_gettext(const char_u *str, int char_len, int
}
*p = NUL;
- return (char_u *)IObuff;
+ return IObuff;
}
/// This is like ins_compl_add(), but if 'ic' and 'inf' are set, then the
@@ -692,11 +692,11 @@ static char_u *ins_compl_infercase_gettext(const char_u *str, int char_len, int
/// the rest of the word to be in -- webb
///
/// @param[in] cont_s_ipos next ^X<> will set initial_pos
-int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname, Direction dir,
+int ins_compl_add_infercase(char *str_arg, int len, bool icase, char *fname, Direction dir,
bool cont_s_ipos)
FUNC_ATTR_NONNULL_ARG(1)
{
- char_u *str = str_arg;
+ char *str = str_arg;
int char_len; // count multi-byte characters
int compl_char_len;
int flags = 0;
@@ -707,7 +707,7 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname,
// Find actual length of completion.
{
- const char_u *p = str;
+ const char *p = str;
char_len = 0;
while (*p != NUL) {
MB_PTR_ADV(p);
@@ -717,7 +717,7 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname,
// Find actual length of original text.
{
- const char_u *p = (char_u *)compl_orig_text;
+ const char *p = compl_orig_text;
compl_char_len = 0;
while (*p != NUL) {
MB_PTR_ADV(p);
@@ -738,7 +738,7 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname,
flags |= CP_ICASE;
}
- int res = ins_compl_add((char *)str, len, (char *)fname, NULL, false, NULL, dir, flags, false);
+ int res = ins_compl_add(str, len, fname, NULL, false, NULL, dir, flags, false);
xfree(tofree);
return res;
}
@@ -908,7 +908,7 @@ static bool ins_compl_equal(compl_T *match, char *str, size_t len)
/// Reduce the longest common string for match "match".
static void ins_compl_longest_match(compl_T *match)
{
- char_u *p, *s;
+ char *p, *s;
int c1, c2;
int had_match;
@@ -932,11 +932,11 @@ static void ins_compl_longest_match(compl_T *match)
}
// Reduce the text if this match differs from compl_leader.
- p = (char_u *)compl_leader;
- s = (char_u *)match->cp_str;
+ p = compl_leader;
+ s = match->cp_str;
while (*p != NUL) {
- c1 = utf_ptr2char((char *)p);
- c2 = utf_ptr2char((char *)s);
+ c1 = utf_ptr2char(p);
+ c2 = utf_ptr2char(s);
if ((match->cp_flags & CP_ICASE)
? (mb_tolower(c1) != mb_tolower(c2))
@@ -1193,16 +1193,16 @@ static int ins_compl_build_pum(void)
}
if (compl->cp_text[CPT_ABBR] != NULL) {
- compl_match_array[i].pum_text = (char_u *)compl->cp_text[CPT_ABBR];
+ compl_match_array[i].pum_text = compl->cp_text[CPT_ABBR];
} else {
- compl_match_array[i].pum_text = (char_u *)compl->cp_str;
+ compl_match_array[i].pum_text = compl->cp_str;
}
- compl_match_array[i].pum_kind = (char_u *)compl->cp_text[CPT_KIND];
- compl_match_array[i].pum_info = (char_u *)compl->cp_text[CPT_INFO];
+ compl_match_array[i].pum_kind = compl->cp_text[CPT_KIND];
+ compl_match_array[i].pum_info = compl->cp_text[CPT_INFO];
if (compl->cp_text[CPT_MENU] != NULL) {
- compl_match_array[i++].pum_extra = (char_u *)compl->cp_text[CPT_MENU];
+ compl_match_array[i++].pum_extra = compl->cp_text[CPT_MENU];
} else {
- compl_match_array[i++].pum_extra = (char_u *)compl->cp_fname;
+ compl_match_array[i++].pum_extra = compl->cp_fname;
}
}
@@ -1256,8 +1256,8 @@ void ins_compl_show_pum(void)
} else {
// popup menu already exists, only need to find the current item.
for (int i = 0; i < compl_match_arraysize; i++) {
- if (compl_match_array[i].pum_text == (char_u *)compl_shown_match->cp_str
- || compl_match_array[i].pum_text == (char_u *)compl_shown_match->cp_text[CPT_ABBR]) {
+ if (compl_match_array[i].pum_text == compl_shown_match->cp_str
+ || compl_match_array[i].pum_text == compl_shown_match->cp_text[CPT_ABBR]) {
cur = i;
break;
}
@@ -1293,10 +1293,10 @@ void ins_compl_show_pum(void)
///
/// @param flags DICT_FIRST and/or DICT_EXACT
/// @param thesaurus Thesaurus completion
-static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, int thesaurus)
+static void ins_compl_dictionaries(char *dict_start, char *pat, int flags, int thesaurus)
{
- char *dict = (char *)dict_start;
- char_u *ptr;
+ char *dict = dict_start;
+ char *ptr;
char *buf;
regmatch_T regmatch;
char **files;
@@ -1327,16 +1327,16 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i
// to only match at the start of a line. Otherwise just match the
// pattern. Also need to double backslashes.
if (ctrl_x_mode_line_or_eval()) {
- char *pat_esc = vim_strsave_escaped((char *)pat, "\\");
+ char *pat_esc = vim_strsave_escaped(pat, "\\");
size_t len = strlen(pat_esc) + 10;
ptr = xmalloc(len);
- vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc);
- regmatch.regprog = vim_regcomp((char *)ptr, RE_MAGIC);
+ vim_snprintf(ptr, len, "^\\s*\\zs\\V%s", pat_esc);
+ regmatch.regprog = vim_regcomp(ptr, RE_MAGIC);
xfree(pat_esc);
xfree(ptr);
} else {
- regmatch.regprog = vim_regcomp((char *)pat, magic_isset() ? RE_MAGIC : 0);
+ regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0);
if (regmatch.regprog == NULL) {
goto theend;
}
@@ -1371,10 +1371,10 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i
} else {
ptr = pat;
}
- spell_dump_compl((char *)ptr, regmatch.rm_ic, &dir, 0);
+ spell_dump_compl(ptr, regmatch.rm_ic, &dir, 0);
} else if (count > 0) { // avoid warning for using "files" uninit
ins_compl_files(count, files, thesaurus, flags,
- &regmatch, (char_u *)buf, &dir);
+ &regmatch, buf, &dir);
if (flags != DICT_EXACT) {
FreeWild(count, files);
}
@@ -1394,21 +1394,20 @@ theend:
/// skipping the word at 'skip_word'.
///
/// @return OK on success.
-static int thesaurus_add_words_in_line(char *fname, char_u **buf_arg, int dir,
- const char_u *skip_word)
+static int thesaurus_add_words_in_line(char *fname, char **buf_arg, int dir, const char *skip_word)
{
int status = OK;
// Add the other matches on the line
- char *ptr = (char *)(*buf_arg);
+ char *ptr = *buf_arg;
while (!got_int) {
// Find start of the next word. Skip white
// space and punctuation.
- ptr = (char *)find_word_start((char_u *)ptr);
+ ptr = find_word_start(ptr);
if (*ptr == NUL || *ptr == NL) {
break;
}
- char_u *wstart = (char_u *)ptr;
+ char *wstart = ptr;
// Find end of the word.
// Japanese words may have characters in
@@ -1425,25 +1424,25 @@ static int thesaurus_add_words_in_line(char *fname, char_u **buf_arg, int dir,
// Add the word. Skip the regexp match.
if (wstart != skip_word) {
- status = ins_compl_add_infercase(wstart, (int)(ptr - (char *)wstart), p_ic,
- (char_u *)fname, dir, false);
+ status = ins_compl_add_infercase(wstart, (int)(ptr - wstart), p_ic,
+ fname, dir, false);
if (status == FAIL) {
break;
}
}
}
- *buf_arg = (char_u *)ptr;
+ *buf_arg = ptr;
return status;
}
/// Process "count" dictionary/thesaurus "files" and add the text matching
/// "regmatch".
static void ins_compl_files(int count, char **files, int thesaurus, int flags, regmatch_T *regmatch,
- char_u *buf, Direction *dir)
+ char *buf, Direction *dir)
FUNC_ATTR_NONNULL_ARG(2, 7)
{
- char_u *ptr;
+ char *ptr;
int i;
FILE *fp;
int add_r;
@@ -1463,23 +1462,22 @@ static void ins_compl_files(int count, char **files, int thesaurus, int flags, r
// Read dictionary file line by line.
// Check each line for a match.
- while (!got_int && !compl_interrupted && !vim_fgets((char *)buf, LSIZE, fp)) {
+ while (!got_int && !compl_interrupted && !vim_fgets(buf, LSIZE, fp)) {
ptr = buf;
- while (vim_regexec(regmatch, (char *)buf, (colnr_T)(ptr - buf))) {
- ptr = (char_u *)regmatch->startp[0];
+ while (vim_regexec(regmatch, buf, (colnr_T)(ptr - buf))) {
+ ptr = regmatch->startp[0];
if (ctrl_x_mode_line_or_eval()) {
- ptr = (char_u *)find_line_end((char *)ptr);
+ ptr = find_line_end(ptr);
} else {
ptr = find_word_end(ptr);
}
- add_r = ins_compl_add_infercase((char_u *)regmatch->startp[0],
- (int)(ptr - (char_u *)regmatch->startp[0]),
- p_ic, (char_u *)files[i], *dir, false);
+ add_r = ins_compl_add_infercase(regmatch->startp[0],
+ (int)(ptr - regmatch->startp[0]),
+ p_ic, files[i], *dir, false);
if (thesaurus) {
// For a thesaurus, add all the words in the line
ptr = buf;
- add_r = thesaurus_add_words_in_line(files[i], &ptr, *dir,
- (char_u *)regmatch->startp[0]);
+ add_r = thesaurus_add_words_in_line(files[i], &ptr, *dir, regmatch->startp[0]);
}
if (add_r == OK) {
// if dir was BACKWARD then honor it just once
@@ -1502,24 +1500,24 @@ static void ins_compl_files(int count, char **files, int thesaurus, int flags, r
/// Find the start of the next word.
/// Returns a pointer to the first char of the word. Also stops at a NUL.
-char_u *find_word_start(char_u *ptr)
+char *find_word_start(char *ptr)
FUNC_ATTR_PURE
{
while (*ptr != NUL && *ptr != '\n' && mb_get_class(ptr) <= 1) {
- ptr += utfc_ptr2len((char *)ptr);
+ ptr += utfc_ptr2len(ptr);
}
return ptr;
}
/// Find the end of the word. Assumes it starts inside a word.
/// Returns a pointer to just after the word.
-char_u *find_word_end(char_u *ptr)
+char *find_word_end(char *ptr)
FUNC_ATTR_PURE
{
const int start_class = mb_get_class(ptr);
if (start_class > 1) {
while (*ptr != NUL) {
- ptr += utfc_ptr2len((char *)ptr);
+ ptr += utfc_ptr2len(ptr);
if (mb_get_class(ptr) != start_class) {
break;
}
@@ -1975,9 +1973,9 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
// of the original text that has changed.
// When using the longest match, edited the match or used
// CTRL-E then don't use the current match.
- char_u *ptr;
+ char *ptr;
if (compl_curr_match != NULL && compl_used_match && c != Ctrl_E) {
- ptr = (char_u *)compl_curr_match->cp_str;
+ ptr = compl_curr_match->cp_str;
} else {
ptr = NULL;
}
@@ -2182,24 +2180,24 @@ bool ins_compl_prep(int c)
/// Fix the redo buffer for the completion leader replacing some of the typed
/// text. This inserts backspaces and appends the changed text.
/// "ptr" is the known leader text or NUL.
-static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg)
+static void ins_compl_fixRedoBufForLeader(char *ptr_arg)
{
int len;
- char_u *p;
- char_u *ptr = ptr_arg;
+ char *p;
+ char *ptr = ptr_arg;
if (ptr == NULL) {
if (compl_leader != NULL) {
- ptr = (char_u *)compl_leader;
+ ptr = compl_leader;
} else {
return; // nothing to do
}
}
if (compl_orig_text != NULL) {
- p = (char_u *)compl_orig_text;
+ p = compl_orig_text;
for (len = 0; p[len] != NUL && p[len] == ptr[len]; len++) {}
if (len > 0) {
- len -= utf_head_off((char *)p, (char *)p + len);
+ len -= utf_head_off(p, p + len);
}
for (p += len; *p != NUL; MB_PTR_ADV(p)) {
AppendCharToRedobuff(K_BS);
@@ -2207,7 +2205,7 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg)
} else {
len = 0;
}
- AppendToRedobuffLit((char *)ptr + len, -1);
+ AppendToRedobuffLit(ptr + len, -1);
}
/// Loops through the list of windows, loaded-buffers or non-loaded-buffers
@@ -2328,17 +2326,17 @@ bool set_ref_in_insexpand_funcs(int copyID)
}
/// Get the user-defined completion function name for completion "type"
-static char_u *get_complete_funcname(int type)
+static char *get_complete_funcname(int type)
{
switch (type) {
case CTRL_X_FUNCTION:
- return (char_u *)curbuf->b_p_cfu;
+ return curbuf->b_p_cfu;
case CTRL_X_OMNI:
- return (char_u *)curbuf->b_p_ofu;
+ return curbuf->b_p_ofu;
case CTRL_X_THESAURUS:
- return *curbuf->b_p_tsrfu == NUL ? (char_u *)p_tsrfu : (char_u *)curbuf->b_p_tsrfu;
+ return *curbuf->b_p_tsrfu == NUL ? p_tsrfu : curbuf->b_p_tsrfu;
default:
- return (char_u *)"";
+ return "";
}
}
@@ -2359,11 +2357,11 @@ static Callback *get_insert_callback(int type)
/// 'thesaurusfunc', and get matches in "matches".
///
/// @param type either CTRL_X_OMNI or CTRL_X_FUNCTION or CTRL_X_THESAURUS
-static void expand_by_function(int type, char_u *base)
+static void expand_by_function(int type, char *base)
{
list_T *matchlist = NULL;
dict_T *matchdict = NULL;
- char_u *funcname;
+ char *funcname;
pos_T pos;
typval_T rettv;
const int save_State = State;
@@ -2380,7 +2378,7 @@ static void expand_by_function(int type, char_u *base)
args[1].v_type = VAR_STRING;
args[2].v_type = VAR_UNKNOWN;
args[0].vval.v_number = 0;
- args[1].vval.v_string = base != NULL ? (char *)base : "";
+ args[1].vval.v_string = base != NULL ? base : "";
pos = curwin->w_cursor;
// Lock the text to avoid weird things from happening. Also disallow
@@ -2636,12 +2634,12 @@ void f_complete_check(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
/// Return Insert completion mode name string
-static char_u *ins_compl_mode(void)
+static char *ins_compl_mode(void)
{
if (ctrl_x_mode_not_defined_yet() || ctrl_x_mode_scroll() || compl_started) {
- return (char_u *)ctrl_x_mode_names[ctrl_x_mode & ~CTRL_X_WANT_IDENT];
+ return ctrl_x_mode_names[ctrl_x_mode & ~CTRL_X_WANT_IDENT];
}
- return (char_u *)"";
+ return "";
}
/// Assign the sequence number to all the completion matches which don't have
@@ -2730,8 +2728,7 @@ static void get_complete_info(list_T *what_list, dict_T *retdict)
int ret = OK;
if (what_flag & CI_WHAT_MODE) {
- ret = tv_dict_add_str(retdict, S_LEN("mode"),
- (char *)ins_compl_mode());
+ ret = tv_dict_add_str(retdict, S_LEN("mode"), ins_compl_mode());
}
if (ret == OK && (what_flag & CI_WHAT_PUM_VISIBLE)) {
@@ -2875,7 +2872,7 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar
goto done;
}
compl_type = CTRL_X_DICTIONARY;
- st->dict = (char_u *)st->ins_buf->b_fname;
+ st->dict = st->ins_buf->b_fname;
st->dict_f = DICT_EXACT;
}
if (!shortmess(SHM_COMPLETIONSCAN)) {
@@ -2900,7 +2897,7 @@ static int process_next_cpt_value(ins_compl_next_state_T *st, int *compl_type_ar
compl_type = CTRL_X_THESAURUS;
}
if (*++st->e_cpt != ',' && *st->e_cpt != NUL) {
- st->dict = (char_u *)st->e_cpt;
+ st->dict = st->e_cpt;
st->dict_f = DICT_FIRST;
}
} else if (*st->e_cpt == 'i') {
@@ -2946,17 +2943,17 @@ static void get_next_include_file_completion(int compl_type)
/// Get the next set of words matching "compl_pattern" in dictionary or
/// thesaurus files.
-static void get_next_dict_tsr_completion(int compl_type, char_u *dict, int dict_f)
+static void get_next_dict_tsr_completion(int compl_type, char *dict, int dict_f)
{
if (thesaurus_func_complete(compl_type)) {
- expand_by_function(compl_type, (char_u *)compl_pattern);
+ expand_by_function(compl_type, compl_pattern);
} else {
ins_compl_dictionaries(dict != NULL ? dict
: (compl_type == CTRL_X_THESAURUS
- ? (*curbuf->b_p_tsr == NUL ? p_tsr : (char_u *)curbuf->b_p_tsr)
+ ? (*curbuf->b_p_tsr == NUL ? (char *)p_tsr : curbuf->b_p_tsr)
: (*curbuf->b_p_dict ==
- NUL ? (char_u *)p_dict : (char_u *)curbuf->b_p_dict)),
- (char_u *)compl_pattern,
+ NUL ? p_dict : curbuf->b_p_dict)),
+ compl_pattern,
dict != NULL ? dict_f : 0,
compl_type == CTRL_X_THESAURUS);
}
@@ -2967,7 +2964,7 @@ static void get_next_tag_completion(void)
{
// set p_ic according to p_ic, p_scs and pat for find_tags().
const int save_p_ic = p_ic;
- p_ic = ignorecase((char_u *)compl_pattern);
+ p_ic = ignorecase(compl_pattern);
// Find up to TAG_MANY matches. Avoids that an enormous number
// of matches is found when compl_pattern is empty
@@ -2995,7 +2992,7 @@ static void get_next_filename_completion(void)
}
// May change home directory back to "~".
- tilde_replace((char_u *)compl_pattern, num_matches, matches);
+ tilde_replace(compl_pattern, num_matches, matches);
#ifdef BACKSLASH_IN_FILENAME
if (curbuf->b_p_csl[0] != NUL) {
for (int i = 0; i < num_matches; i++) {
@@ -3030,7 +3027,7 @@ static void get_next_cmdline_completion(void)
static void get_next_spell_completion(linenr_T lnum)
{
char **matches;
- int num_matches = expand_spelling(lnum, (char_u *)compl_pattern, &matches);
+ int num_matches = expand_spelling(lnum, compl_pattern, &matches);
if (num_matches > 0) {
ins_compl_add_matches(num_matches, matches, p_ic);
} else {
@@ -3044,8 +3041,8 @@ static void get_next_spell_completion(linenr_T lnum)
/// @param cur_match_pos current match position
/// @param match_len
/// @param cont_s_ipos next ^X<> will set initial_pos
-static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_pos, int *match_len,
- bool *cont_s_ipos)
+static char *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_pos, int *match_len,
+ bool *cont_s_ipos)
{
*match_len = 0;
char *ptr = ml_get_buf(ins_buf, cur_match_pos->lnum, false) + cur_match_pos->col;
@@ -3071,10 +3068,10 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p
return NULL;
}
// Find start of next word.
- tmp_ptr = (char *)find_word_start((char_u *)tmp_ptr);
+ tmp_ptr = find_word_start(tmp_ptr);
}
// Find end of this word.
- tmp_ptr = (char *)find_word_end((char_u *)tmp_ptr);
+ tmp_ptr = find_word_end(tmp_ptr);
len = (int)(tmp_ptr - ptr);
if (compl_status_adding() && len == compl_length) {
@@ -3086,9 +3083,9 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p
ptr = ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false);
tmp_ptr = ptr = skipwhite(ptr);
// Find start of next word.
- tmp_ptr = (char *)find_word_start((char_u *)tmp_ptr);
+ tmp_ptr = find_word_start(tmp_ptr);
// Find end of next word.
- tmp_ptr = (char *)find_word_end((char_u *)tmp_ptr);
+ tmp_ptr = find_word_end(tmp_ptr);
if (tmp_ptr > ptr) {
if (*ptr != ')' && IObuff[len - 1] != TAB) {
if (IObuff[len - 1] != ' ') {
@@ -3120,7 +3117,7 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p
}
*match_len = len;
- return (char_u *)ptr;
+ return ptr;
}
/// Get the next set of words matching "compl_pattern" for default completion(s)
@@ -3207,13 +3204,13 @@ static int get_next_default_completion(ins_compl_next_state_T *st, pos_T *start_
continue;
}
int len;
- char_u *ptr = ins_comp_get_next_word_or_line(st->ins_buf, st->cur_match_pos,
- &len, &cont_s_ipos);
+ char *ptr = ins_comp_get_next_word_or_line(st->ins_buf, st->cur_match_pos,
+ &len, &cont_s_ipos);
if (ptr == NULL) {
continue;
}
if (ins_compl_add_infercase(ptr, len, p_ic,
- st->ins_buf == curbuf ? NULL : (char_u *)st->ins_buf->b_sfname,
+ st->ins_buf == curbuf ? NULL : st->ins_buf->b_sfname,
0, cont_s_ipos) != NOTDONE) {
found_new_match = OK;
break;
@@ -3260,7 +3257,7 @@ static bool get_next_completion_match(int type, ins_compl_next_state_T *st, pos_
case CTRL_X_FUNCTION:
case CTRL_X_OMNI:
- expand_by_function(type, (char_u *)compl_pattern);
+ expand_by_function(type, compl_pattern);
break;
case CTRL_X_SPELL:
@@ -3832,17 +3829,17 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col)
char *prefix = "\\<";
// we need up to 2 extra chars for the prefix
- compl_pattern = xmalloc(quote_meta(NULL, (char_u *)line + compl_col, compl_length) + 2);
+ compl_pattern = xmalloc(quote_meta(NULL, line + compl_col, compl_length) + 2);
if (!vim_iswordp(line + compl_col)
|| (compl_col > 0
- && (vim_iswordp((char *)mb_prevptr((char_u *)line, (char_u *)line + compl_col))))) {
+ && (vim_iswordp(mb_prevptr(line, line + compl_col))))) {
prefix = "";
}
STRCPY(compl_pattern, prefix);
- (void)quote_meta((char_u *)compl_pattern + strlen(prefix),
- (char_u *)line + compl_col, compl_length);
+ (void)quote_meta(compl_pattern + strlen(prefix),
+ line + compl_col, compl_length);
} else if (--startcol < 0
- || !vim_iswordp((char *)mb_prevptr((char_u *)line, (char_u *)line + startcol + 1))) {
+ || !vim_iswordp(mb_prevptr(line, line + startcol + 1))) {
// Match any word of at least two chars
compl_pattern = xstrdup("\\<\\k\\k");
compl_col += curs_col;
@@ -3851,10 +3848,10 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col)
// Search the point of change class of multibyte character
// or not a word single byte character backward.
startcol -= utf_head_off(line, line + startcol);
- int base_class = mb_get_class((char_u *)line + startcol);
+ int base_class = mb_get_class(line + startcol);
while (--startcol >= 0) {
int head_off = utf_head_off(line, line + startcol);
- if (base_class != mb_get_class((char_u *)line + startcol - head_off)) {
+ if (base_class != mb_get_class(line + startcol - head_off)) {
break;
}
startcol -= head_off;
@@ -3867,13 +3864,12 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col)
// xmalloc(7) is enough -- Acevedo
compl_pattern = xmalloc(7);
STRCPY(compl_pattern, "\\<");
- (void)quote_meta((char_u *)compl_pattern + 2, (char_u *)line + compl_col, 1);
+ (void)quote_meta(compl_pattern + 2, line + compl_col, 1);
STRCAT(compl_pattern, "\\k");
} else {
- compl_pattern = xmalloc(quote_meta(NULL, (char_u *)line + compl_col,
- compl_length) + 2);
+ compl_pattern = xmalloc(quote_meta(NULL, line + compl_col, compl_length) + 2);
STRCPY(compl_pattern, "\\<");
- (void)quote_meta((char_u *)compl_pattern + 2, (char_u *)line + compl_col, compl_length);
+ (void)quote_meta(compl_pattern + 2, line + compl_col, compl_length);
}
}
@@ -3901,17 +3897,17 @@ static int get_wholeline_compl_info(char *line, colnr_T curs_col)
/// Get the pattern, column and length for filename completion.
/// Sets the global variables: compl_col, compl_length and compl_pattern.
-static int get_filename_compl_info(char_u *line, int startcol, colnr_T curs_col)
+static int get_filename_compl_info(char *line, int startcol, colnr_T curs_col)
{
// Go back to just before the first filename character.
if (startcol > 0) {
- char_u *p = line + startcol;
+ char *p = line + startcol;
MB_PTR_BACK(line, p);
- while (p > line && vim_isfilec(utf_ptr2char((char *)p))) {
+ while (p > line && vim_isfilec(utf_ptr2char(p))) {
MB_PTR_BACK(line, p);
}
- if (p == line && vim_isfilec(utf_ptr2char((char *)p))) {
+ if (p == line && vim_isfilec(utf_ptr2char(p))) {
startcol = 0;
} else {
startcol = (int)(p - line) + 1;
@@ -3920,7 +3916,7 @@ static int get_filename_compl_info(char_u *line, int startcol, colnr_T curs_col)
compl_col += startcol;
compl_length = (int)curs_col - startcol;
- compl_pattern = addstar((char *)line + compl_col, (size_t)compl_length, EXPAND_FILES);
+ compl_pattern = addstar(line + compl_col, (size_t)compl_length, EXPAND_FILES);
return OK;
}
@@ -3930,7 +3926,7 @@ static int get_filename_compl_info(char_u *line, int startcol, colnr_T curs_col)
static int get_cmdline_compl_info(char *line, colnr_T curs_col)
{
compl_pattern = xstrnsave(line, (size_t)curs_col);
- set_cmd_context(&compl_xp, (char_u *)compl_pattern, (int)strlen(compl_pattern), curs_col, false);
+ set_cmd_context(&compl_xp, compl_pattern, (int)strlen(compl_pattern), curs_col, false);
if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
|| compl_xp.xp_context == EXPAND_NOTHING) {
// No completion possible, use an empty pattern to get a
@@ -3955,7 +3951,7 @@ static int get_userdefined_compl_info(colnr_T curs_col)
const int save_State = State;
// Call 'completefunc' or 'omnifunc' and get pattern length as a string
- char_u *funcname = get_complete_funcname(ctrl_x_mode);
+ char *funcname = get_complete_funcname(ctrl_x_mode);
if (*funcname == NUL) {
semsg(_(e_notset), ctrl_x_mode_function() ? "completefunc" : "omnifunc");
return FAIL;
@@ -4053,18 +4049,18 @@ static int get_spell_compl_info(int startcol, colnr_T curs_col)
/// become invalid and needs to be fetched again.
///
/// @return OK on success.
-static int compl_get_info(char_u *line, int startcol, colnr_T curs_col, bool *line_invalid)
+static int compl_get_info(char *line, int startcol, colnr_T curs_col, bool *line_invalid)
{
if (ctrl_x_mode_normal()
|| ((ctrl_x_mode & CTRL_X_WANT_IDENT)
&& !thesaurus_func_complete(ctrl_x_mode))) {
- return get_normal_compl_info((char *)line, startcol, curs_col);
+ return get_normal_compl_info(line, startcol, curs_col);
} else if (ctrl_x_mode_line_or_eval()) {
- return get_wholeline_compl_info((char *)line, curs_col);
+ return get_wholeline_compl_info(line, curs_col);
} else if (ctrl_x_mode_files()) {
return get_filename_compl_info(line, startcol, curs_col);
} else if (ctrl_x_mode == CTRL_X_CMDLINE) {
- return get_cmdline_compl_info((char *)line, curs_col);
+ return get_cmdline_compl_info(line, curs_col);
} else if (ctrl_x_mode_function() || ctrl_x_mode_omni()
|| thesaurus_func_complete(ctrl_x_mode)) {
if (get_userdefined_compl_info(curs_col) == FAIL) {
@@ -4092,7 +4088,7 @@ static int compl_get_info(char_u *line, int startcol, colnr_T curs_col, bool *li
/// the same line as the cursor then fix it (the line has been split because it
/// was longer than 'tw'). if SOL is set then skip the previous pattern, a word
/// at the beginning of the line has been inserted, we'll look for that.
-static void ins_compl_continue_search(char_u *line)
+static void ins_compl_continue_search(char *line)
{
// it is a continued search
compl_cont_status &= ~CONT_INTRPT; // remove INTRPT
@@ -4104,7 +4100,7 @@ static void ins_compl_continue_search(char_u *line)
// first non_blank in the line, if it is not a wordchar
// include it to get a better pattern, but then we don't
// want the "\\<" prefix, check it below.
- compl_col = (colnr_T)getwhitecols((char *)line);
+ compl_col = (colnr_T)getwhitecols(line);
compl_startpos.col = compl_col;
compl_startpos.lnum = curwin->w_cursor.lnum;
compl_cont_status &= ~CONT_SOL; // clear SOL if present
@@ -4114,9 +4110,7 @@ static void ins_compl_continue_search(char_u *line)
// mode but first we need to redefine compl_startpos
if (compl_cont_status & CONT_S_IPOS) {
compl_cont_status |= CONT_SOL;
- compl_startpos.col = (colnr_T)((char_u *)skipwhite((char *)line
- + compl_length
- + compl_startpos.col) - line);
+ compl_startpos.col = (colnr_T)(skipwhite(line + compl_length + compl_startpos.col) - line);
}
compl_col = compl_startpos.col;
}
@@ -4163,7 +4157,7 @@ static int ins_compl_start(void)
&& compl_cont_mode == ctrl_x_mode) {
// this same ctrl-x_mode was interrupted previously. Continue the
// completion.
- ins_compl_continue_search((char_u *)line);
+ ins_compl_continue_search(line);
} else {
compl_cont_status &= CONT_LOCAL;
}
@@ -4183,7 +4177,7 @@ static int ins_compl_start(void)
// Work out completion pattern and original text -- webb
bool line_invalid = false;
- if (compl_get_info((char_u *)line, startcol, curs_col, &line_invalid) == FAIL) {
+ if (compl_get_info(line, startcol, curs_col, &line_invalid) == FAIL) {
if (ctrl_x_mode_function() || ctrl_x_mode_omni()
|| thesaurus_func_complete(ctrl_x_mode)) {
// restore did_ai, so that adding comment leader works
@@ -4282,18 +4276,18 @@ static void ins_compl_show_statusmsg(void)
if (compl_curr_match->cp_number != -1) {
// Space for 10 text chars. + 2x10-digit no.s = 31.
// Translations may need more than twice that.
- static char_u match_ref[81];
+ static char match_ref[81];
if (compl_matches > 0) {
- vim_snprintf((char *)match_ref, sizeof(match_ref),
+ vim_snprintf(match_ref, sizeof(match_ref),
_("match %d of %d"),
compl_curr_match->cp_number, compl_matches);
} else {
- vim_snprintf((char *)match_ref, sizeof(match_ref),
+ vim_snprintf(match_ref, sizeof(match_ref),
_("match %d"),
compl_curr_match->cp_number);
}
- edit_submode_extra = (char *)match_ref;
+ edit_submode_extra = match_ref;
edit_submode_highl = HLF_R;
if (dollar_vcol >= 0) {
curs_columns(curwin, false);
@@ -4417,7 +4411,7 @@ static void show_pum(int prev_w_wrow, int prev_w_leftcol)
// If dest is not NULL the chars. are copied there quoting (with
// a backslash) the metachars, and dest would be NUL terminated.
// Returns the length (needed) of dest
-static unsigned quote_meta(char_u *dest, char_u *src, int len)
+static unsigned quote_meta(char *dest, char *src, int len)
{
unsigned m = (unsigned)len + 1; // one extra for the NUL
@@ -4452,7 +4446,7 @@ static unsigned quote_meta(char_u *dest, char_u *src, int len)
*dest++ = *src;
}
// Copy remaining bytes of a multibyte character.
- const int mb_len = utfc_ptr2len((char *)src) - 1;
+ const int mb_len = utfc_ptr2len(src) - 1;
if (mb_len > 0 && len >= mb_len) {
for (int i = 0; i < mb_len; i++) {
len--;
diff --git a/src/nvim/locale.c b/src/nvim/locale.c
index c07420be1d..12d6b47be8 100644
--- a/src/nvim/locale.c
+++ b/src/nvim/locale.c
@@ -290,8 +290,7 @@ static char **find_locales(void)
// Find all available locales by running command "locale -a". If this
// doesn't work we won't have completion.
- char *locale_a = (char *)get_cmd_output((char_u *)"locale -a", NULL,
- kShellOptSilent, NULL);
+ char *locale_a = get_cmd_output("locale -a", NULL, kShellOptSilent, NULL);
if (locale_a == NULL) {
return NULL;
}
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index 813f86eeee..dac96790d7 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -176,7 +176,7 @@ int nlua_str_utfindex(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
}
size_t codepoints = 0, codeunits = 0;
- mb_utflen((const char_u *)s1, (size_t)idx, &codepoints, &codeunits);
+ mb_utflen(s1, (size_t)idx, &codepoints, &codeunits);
lua_pushinteger(lstate, (long)codepoints);
lua_pushinteger(lstate, (long)codeunits);
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index fa8521306f..04a0107fe8 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -912,10 +912,10 @@ theend:
/// - 4 for out of mem (deprecated, WON'T HAPPEN)
/// - 5 for entry not unique
///
-int do_map(int maptype, char_u *arg, int mode, bool is_abbrev)
+int do_map(int maptype, char *arg, int mode, bool is_abbrev)
{
MapArguments parsed_args;
- int result = str_to_mapargs((char *)arg, maptype == MAPTYPE_UNMAP, &parsed_args);
+ int result = str_to_mapargs(arg, maptype == MAPTYPE_UNMAP, &parsed_args);
switch (result) {
case 0:
break;
@@ -1418,18 +1418,18 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
{
bool vim_abbr;
- char *p = (char *)mb_prevptr((char_u *)ptr, (char_u *)ptr + col);
+ char *p = mb_prevptr(ptr, ptr + col);
if (!vim_iswordp(p)) {
vim_abbr = true; // Vim added abbr.
} else {
vim_abbr = false; // vi compatible abbr.
if (p > ptr) {
- is_id = vim_iswordp((char *)mb_prevptr((char_u *)ptr, (char_u *)p));
+ is_id = vim_iswordp(mb_prevptr(ptr, p));
}
}
clen = 1;
while (p > ptr + mincol) {
- p = (char *)mb_prevptr((char_u *)ptr, (char_u *)p);
+ p = mb_prevptr(ptr, p);
if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) {
p += utfc_ptr2len(p);
break;
@@ -2435,7 +2435,7 @@ static void do_exmap(exarg_T *eap, int isabbrev)
switch (do_map((*cmdp == 'n') ? MAPTYPE_NOREMAP
: (*cmdp == 'u') ? MAPTYPE_UNMAP : MAPTYPE_MAP,
- (char_u *)eap->arg, mode, isabbrev)) {
+ eap->arg, mode, isabbrev)) {
case 1:
emsg(_(e_invarg));
break;
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 2ddd66581d..830ad8e729 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -915,7 +915,7 @@ static void show_one_mark(int c, char *arg, pos_T *p, char *name_arg, int curren
// ":delmarks[!] [marks]"
void ex_delmarks(exarg_T *eap)
{
- char_u *p;
+ char *p;
int from, to;
int i;
int lower;
@@ -931,14 +931,14 @@ void ex_delmarks(exarg_T *eap)
emsg(_(e_argreq));
} else {
// clear specified marks only
- for (p = (char_u *)eap->arg; *p != NUL; p++) {
+ for (p = eap->arg; *p != NUL; p++) {
lower = ASCII_ISLOWER(*p);
digit = ascii_isdigit(*p);
if (lower || digit || ASCII_ISUPPER(*p)) {
if (p[1] == '-') {
// clear range of marks
- from = *p;
- to = p[2];
+ from = (uint8_t)(*p);
+ to = (uint8_t)p[2];
if (!(lower ? ASCII_ISLOWER(p[2])
: (digit ? ascii_isdigit(p[2])
: ASCII_ISUPPER(p[2])))
@@ -949,7 +949,7 @@ void ex_delmarks(exarg_T *eap)
p += 2;
} else {
// clear one lower case mark
- from = to = *p;
+ from = to = (uint8_t)(*p);
}
for (i = from; i <= to; i++) {
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index e1a870071c..93ac0fccfa 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -424,10 +424,10 @@ void remove_bom(char_u *s)
// 1 for punctuation
// 2 for an (ASCII) word character
// >2 for other word characters
-int mb_get_class(const char_u *p)
+int mb_get_class(const char *p)
FUNC_ATTR_PURE
{
- return mb_get_class_tab((char *)p, curbuf->b_chartab);
+ return mb_get_class_tab(p, curbuf->b_chartab);
}
int mb_get_class_tab(const char *p, const uint64_t *const chartab)
@@ -1456,16 +1456,16 @@ int utf16_to_utf8(const wchar_t *utf16, int utf16len, char **utf8)
/// @param len maximum length (an earlier NUL terminates)
/// @param[out] codepoints incremented with UTF-32 code point size
/// @param[out] codeunits incremented with UTF-16 code unit size
-void mb_utflen(const char_u *s, size_t len, size_t *codepoints, size_t *codeunits)
+void mb_utflen(const char *s, size_t len, size_t *codepoints, size_t *codeunits)
FUNC_ATTR_NONNULL_ALL
{
size_t count = 0, extra = 0;
size_t clen;
for (size_t i = 0; i < len; i += clen) {
- clen = (size_t)utf_ptr2len_len(s + i, (int)(len - i));
+ clen = (size_t)utf_ptr2len_len((char_u *)s + i, (int)(len - i));
// NB: gets the byte value of invalid sequence bytes.
// we only care whether the char fits in the BMP or not
- int c = (clen > 1) ? utf_ptr2char((char *)s + i) : s[i];
+ int c = (clen > 1) ? utf_ptr2char(s + i) : (uint8_t)s[i];
count++;
if (c > 0xFFFF) {
extra++;
@@ -2012,7 +2012,7 @@ void mb_check_adjust_col(void *win_)
/// @param line start of the string
///
/// @return a pointer to the character before "*p", if there is one.
-char_u *mb_prevptr(char_u *line, char_u *p)
+char *mb_prevptr(char *line, char *p)
{
if (p > line) {
MB_PTR_BACK(line, p);
@@ -2022,9 +2022,9 @@ char_u *mb_prevptr(char_u *line, char_u *p)
/// Return the character length of "str". Each multi-byte character (with
/// following composing characters) counts as one.
-int mb_charlen(const char_u *str)
+int mb_charlen(const char *str)
{
- const char_u *p = str;
+ const char_u *p = (char_u *)str;
int count;
if (p == NULL) {
@@ -2801,5 +2801,5 @@ void f_charclass(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|| argvars[0].vval.v_string == NULL) {
return;
}
- rettv->vval.v_number = mb_get_class((const char_u *)argvars[0].vval.v_string);
+ rettv->vval.v_number = mb_get_class(argvars[0].vval.v_string);
}
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 5c5d403878..b4f1aba0c5 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -675,7 +675,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
/// not set.
static void set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf)
{
- if (same_directory((char_u *)buf->b_ml.ml_mfp->mf_fname, (char_u *)buf->b_ffname)) {
+ if (same_directory(buf->b_ml.ml_mfp->mf_fname, buf->b_ffname)) {
b0p->b0_flags |= B0_SAME_DIR;
} else {
b0p->b0_flags = (char)(b0p->b0_flags & ~B0_SAME_DIR);
@@ -1349,7 +1349,7 @@ int recover_names(char_u *fname, int list, int nr, char **fname_out)
msg_puts(". ");
msg_puts((const char *)path_tail(files[i]));
msg_putchar('\n');
- (void)swapfile_info((char_u *)files[i]);
+ (void)swapfile_info(files[i]);
}
} else {
msg_puts(_(" -- none --\n"));
@@ -1434,7 +1434,7 @@ void get_b0_dict(const char *fname, dict_T *d)
/// Give information about an existing swap file.
///
/// @return timestamp (0 when unknown).
-static time_t swapfile_info(char_u *fname)
+static time_t swapfile_info(char *fname)
{
assert(fname != NULL);
int fd;
@@ -1446,7 +1446,7 @@ static time_t swapfile_info(char_u *fname)
// print the swap file date
FileInfo file_info;
- if (os_fileinfo((char *)fname, &file_info)) {
+ if (os_fileinfo(fname, &file_info)) {
#ifdef UNIX
// print name of owner of the file
if (os_get_uname((uv_uid_t)file_info.stat.st_uid, uname, B0_UNAME_SIZE) == OK) {
@@ -1465,7 +1465,7 @@ static time_t swapfile_info(char_u *fname)
}
// print the original file name
- fd = os_open((char *)fname, O_RDONLY, 0);
+ fd = os_open(fname, O_RDONLY, 0);
if (fd >= 0) {
if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) {
if (strncmp(b0.b0_version, "VIM 3.0", 7) == 0) {
@@ -2317,7 +2317,7 @@ void ml_add_deleted_len_buf(buf_T *buf, char *ptr, ssize_t len)
curbuf->deleted_bytes += (size_t)len + 1;
curbuf->deleted_bytes2 += (size_t)len + 1;
if (curbuf->update_need_codepoints) {
- mb_utflen((char_u *)ptr, (size_t)len, &curbuf->deleted_codepoints,
+ mb_utflen(ptr, (size_t)len, &curbuf->deleted_codepoints,
&curbuf->deleted_codeunits);
curbuf->deleted_codepoints++; // NL char
curbuf->deleted_codeunits++;
@@ -3109,7 +3109,7 @@ static void attention_message(buf_T *buf, char *fname)
msg_puts(_("\nFound a swap file by the name \""));
msg_home_replace(fname);
msg_puts("\"\n");
- const time_t swap_mtime = swapfile_info((char_u *)fname);
+ const time_t swap_mtime = swapfile_info(fname);
msg_puts(_("While opening file \""));
msg_outtrans(buf->b_fname);
msg_puts("\"\n");
@@ -3152,9 +3152,9 @@ static void attention_message(buf_T *buf, char *fname)
/// 4: delete it
/// 5: quit
/// 6: abort
-static int do_swapexists(buf_T *buf, char_u *fname)
+static int do_swapexists(buf_T *buf, char *fname)
{
- set_vim_var_string(VV_SWAPNAME, (char *)fname, -1);
+ set_vim_var_string(VV_SWAPNAME, fname, -1);
set_vim_var_string(VV_SWAPCHOICE, NULL, -1);
// Trigger SwapExists autocommands with <afile> set to the file being
@@ -3266,7 +3266,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
if (b0.b0_flags & B0_SAME_DIR) {
if (path_fnamecmp(path_tail(buf->b_ffname),
path_tail((char *)b0.b0_fname)) != 0
- || !same_directory((char_u *)fname, (char_u *)buf->b_ffname)) {
+ || !same_directory(fname, buf->b_ffname)) {
// Symlinks may point to the same file even
// when the name differs, need to check the
// inode too.
@@ -3311,7 +3311,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
if (choice == 0
&& swap_exists_action != SEA_NONE
&& has_autocmd(EVENT_SWAPEXISTS, buf_fname, buf)) {
- choice = do_swapexists(buf, (char_u *)fname);
+ choice = do_swapexists(buf, fname);
}
if (choice == 0) {
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index ac73510266..000377a997 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -1338,7 +1338,7 @@ static char *menu_text(const char *str, int *mnemonic, char **actext)
break;
}
if (mnemonic != NULL && p[1] != '&') {
- *mnemonic = (char_u)p[1];
+ *mnemonic = (uint8_t)p[1];
}
STRMOVE(p, p + 1);
p = p + 1;
@@ -1531,7 +1531,7 @@ void execute_menu(const exarg_T *eap, vimmenu_T *menu, int mode_idx)
ex_normal_busy++;
if (save_current_state(&save_state)) {
- exec_normal_cmd((char_u *)menu->strings[idx], menu->noremap[idx],
+ exec_normal_cmd(menu->strings[idx], menu->noremap[idx],
menu->silent[idx]);
}
restore_current_state(&save_state);
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index a87143fe12..b7d15fe9af 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -58,13 +58,13 @@ static int orig_topfill = 0;
/// 1: punctuation groups
/// 2: normal word character
/// >2: multi-byte word character.
-static int get_mouse_class(char_u *p)
+static int get_mouse_class(char *p)
{
- if (MB_BYTE2LEN(p[0]) > 1) {
+ if (MB_BYTE2LEN((uint8_t)p[0]) > 1) {
return mb_get_class(p);
}
- const int c = *p;
+ const int c = (uint8_t)(*p);
if (c == ' ' || c == '\t') {
return 0;
}
@@ -90,12 +90,12 @@ static void find_start_of_word(pos_T *pos)
int col;
line = (char_u *)ml_get(pos->lnum);
- cclass = get_mouse_class(line + pos->col);
+ cclass = get_mouse_class((char *)line + pos->col);
while (pos->col > 0) {
col = pos->col - 1;
col -= utf_head_off((char *)line, (char *)line + col);
- if (get_mouse_class(line + col) != cclass) {
+ if (get_mouse_class((char *)line + col) != cclass) {
break;
}
pos->col = col;
@@ -115,10 +115,10 @@ static void find_end_of_word(pos_T *pos)
pos->col--;
pos->col -= utf_head_off((char *)line, (char *)line + pos->col);
}
- cclass = get_mouse_class(line + pos->col);
+ cclass = get_mouse_class((char *)line + pos->col);
while (line[pos->col] != NUL) {
col = pos->col + utfc_ptr2len((char *)line + pos->col);
- if (get_mouse_class(line + col) != cclass) {
+ if (get_mouse_class((char *)line + col) != cclass) {
if (*p_sel == 'e') {
pos->col = col;
}
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index cf5af66ddd..8f4240c062 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1586,7 +1586,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
if ((find_type & FIND_EVAL) && ptr[col] == ']') {
break;
}
- this_class = mb_get_class((char_u *)ptr + col);
+ this_class = mb_get_class(ptr + col);
if (this_class != 0 && (i == 1 || this_class != 1)) {
break;
}
@@ -1601,13 +1601,13 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
//
// Remember class of character under cursor.
if ((find_type & FIND_EVAL) && ptr[col] == ']') {
- this_class = mb_get_class((char_u *)"a");
+ this_class = mb_get_class("a");
} else {
- this_class = mb_get_class((char_u *)ptr + col);
+ this_class = mb_get_class(ptr + col);
}
while (col > 0 && this_class != 0) {
prevcol = col - 1 - utf_head_off(ptr, ptr + col - 1);
- prev_class = mb_get_class((char_u *)ptr + prevcol);
+ prev_class = mb_get_class(ptr + prevcol);
if (this_class != prev_class
&& (i == 0
|| prev_class == 0
@@ -1650,11 +1650,11 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
startcol -= col;
col = 0;
// Search for point of changing multibyte character class.
- this_class = mb_get_class((char_u *)ptr);
+ this_class = mb_get_class(ptr);
while (ptr[col] != NUL // -V781
&& ((i == 0
- ? mb_get_class((char_u *)ptr + col) == this_class
- : mb_get_class((char_u *)ptr + col) != 0)
+ ? mb_get_class(ptr + col) == this_class
+ : mb_get_class(ptr + col) != 0)
|| ((find_type & FIND_EVAL)
&& col <= (int)startcol
&& find_is_eval_item((char_u *)ptr + col, &col, &bn, FORWARD)))) {
@@ -2401,7 +2401,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
/// @return true if able to move cursor, false otherwise.
static bool nv_screengo(oparg_T *oap, int dir, long dist)
{
- int linelen = linetabsize((char_u *)get_cursor_line_ptr());
+ int linelen = linetabsize(get_cursor_line_ptr());
bool retval = true;
bool atend = false;
int n;
@@ -2472,7 +2472,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
}
curwin->w_cursor.lnum--;
- linelen = linetabsize((char_u *)get_cursor_line_ptr());
+ linelen = linetabsize(get_cursor_line_ptr());
if (linelen > width1) {
int w = (((linelen - width1 - 1) / width2) + 1) * width2;
assert(curwin->w_curswant <= INT_MAX - w);
@@ -2508,7 +2508,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
if (curwin->w_curswant >= width1) {
curwin->w_curswant -= width2;
}
- linelen = linetabsize((char_u *)get_cursor_line_ptr());
+ linelen = linetabsize(get_cursor_line_ptr());
}
}
}
@@ -3549,7 +3549,7 @@ static void nv_ident(cmdarg_T *cap)
// Execute the command.
if (cmdchar == '*' || cmdchar == '#') {
if (!g_cmd
- && vim_iswordp((char *)mb_prevptr((char_u *)get_cursor_line_ptr(), (char_u *)ptr))) {
+ && vim_iswordp(mb_prevptr(get_cursor_line_ptr(), ptr))) {
STRCAT(buf, "\\>");
}
@@ -4530,7 +4530,7 @@ static void nv_replace(cmdarg_T *cap)
// Abort if not enough characters to replace.
ptr = get_cursor_pos_ptr();
if (strlen(ptr) < (unsigned)cap->count1
- || (mb_charlen((char_u *)ptr) < cap->count1)) {
+ || (mb_charlen(ptr) < cap->count1)) {
clearopbeep(cap->oap);
return;
}
@@ -5448,7 +5448,7 @@ static void nv_g_cmd(cmdarg_T *cap)
case 'M':
oap->motion_type = kMTCharWise;
oap->inclusive = false;
- i = linetabsize((char_u *)get_cursor_line_ptr());
+ i = linetabsize(get_cursor_line_ptr());
if (cap->count0 > 0 && cap->count0 <= 100) {
coladvance((colnr_T)(i * cap->count0 / 100));
} else {
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 7ec489970d..34432c58db 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5492,7 +5492,7 @@ void cursor_pos_info(dict_T *dict)
validate_virtcol();
col_print((char *)buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
(int)curwin->w_virtcol + 1);
- col_print((char *)buf2, sizeof(buf2), (int)strlen(p), linetabsize((char_u *)p));
+ col_print((char *)buf2, sizeof(buf2), (int)strlen(p), linetabsize(p));
if (char_count_cursor == byte_count_cursor
&& char_count == byte_count) {
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 423787ecfc..02c770e608 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -608,7 +608,7 @@ void set_init_3(void)
: !(options[idx_sp].flags & P_WAS_SET);
size_t len = 0;
- char *p = (char *)invocation_path_tail((char_u *)p_sh, &len);
+ char *p = (char *)invocation_path_tail(p_sh, &len);
p = xstrnsave(p, len);
{
@@ -741,7 +741,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
char *varp = varp_arg;
char *save_arg = NULL;
char *s = NULL;
- char_u *oldval = NULL; // previous value if *varp
+ char *oldval = NULL; // previous value if *varp
char *origval = NULL;
char_u *origval_l = NULL;
char_u *origval_g = NULL;
@@ -760,7 +760,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
}
// The old value is kept until we are sure that the new value is valid.
- oldval = *(char_u **)varp;
+ oldval = *(char **)varp;
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) {
origval_l = *(char_u **)get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
@@ -778,7 +778,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
if (((int)options[opt_idx].indir & PV_BOTH) && (opt_flags & OPT_LOCAL)) {
origval = *(char **)get_varp(&options[opt_idx]);
} else {
- origval = (char *)oldval;
+ origval = oldval;
}
char *newval;
@@ -827,16 +827,16 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
break;
}
xfree(oldval);
- if ((char_u *)origval == oldval) {
+ if (origval == oldval) {
origval = *(char **)varp;
}
- if (origval_l == oldval) {
+ if (origval_l == (char_u *)oldval) {
origval_l = *(char_u **)varp;
}
- if (origval_g == oldval) {
+ if (origval_g == (char_u *)oldval) {
origval_g = *(char_u **)varp;
}
- oldval = *(char_u **)varp;
+ oldval = *(char **)varp;
} else if (varp == (char *)&p_ww && ascii_isdigit(*arg)) {
// Convert 'whichwrap' number to string, for backwards compatibility
// with Vim 3.0.
@@ -1045,7 +1045,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
// Handle side effects, and set the global value for ":set" on local
// options. Note: when setting 'syntax' or 'filetype' autocommands may
// be triggered that can cause havoc.
- *errmsg = did_set_string_option(opt_idx, (char **)varp, (char *)oldval,
+ *errmsg = did_set_string_option(opt_idx, (char **)varp, oldval,
errbuf, errbuflen,
opt_flags, value_checked);
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 263bc32190..e1db7a8ef7 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -543,7 +543,7 @@ void free_homedir(void)
/// @see {expand_env}
char *expand_env_save(char *src)
{
- return (char *)expand_env_save_opt((char_u *)src, false);
+ return (char *)expand_env_save_opt(src, false);
}
/// Similar to expand_env_save() but when "one" is `true` handle the string as
@@ -551,10 +551,10 @@ char *expand_env_save(char *src)
/// @param src String containing environment variables to expand
/// @param one Should treat as only one file name
/// @see {expand_env}
-char_u *expand_env_save_opt(char_u *src, bool one)
+char_u *expand_env_save_opt(char *src, bool one)
{
char_u *p = xmalloc(MAXPATHL);
- expand_env_esc((char *)src, (char *)p, MAXPATHL, false, one, NULL);
+ expand_env_esc(src, (char *)p, MAXPATHL, false, one, NULL);
return p;
}
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index b8ade07038..e0449d468a 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -995,7 +995,7 @@ int os_mkdir_recurse(const char *const dir, int32_t mode, char **const failed_di
int os_file_mkdir(char *fname, int32_t mode)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
- if (!dir_of_file_exists((char_u *)fname)) {
+ if (!dir_of_file_exists(fname)) {
char *tail = path_tail_with_sep(fname);
char *last_char = tail + strlen(tail) - 1;
if (vim_ispathsep(*last_char)) {
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index dce671c9b5..8177f06c64 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -65,7 +65,7 @@ typedef struct {
static void save_patterns(int num_pat, char **pat, int *num_file, char ***file)
{
- *file = xmalloc((size_t)num_pat * sizeof(char_u *));
+ *file = xmalloc((size_t)num_pat * sizeof(char *));
for (int i = 0; i < num_pat; i++) {
char *s = xstrdup(pat[i]);
// Be compatible with expand_filename(): halve the number of
@@ -122,7 +122,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
size_t len;
char *p;
bool dir;
- char_u *extra_shell_arg = NULL;
+ char *extra_shell_arg = NULL;
ShellOpts shellopts = kShellOptExpand | kShellOptSilent;
int j;
char *tempname;
@@ -144,7 +144,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
bool is_fish_shell =
#if defined(UNIX)
- strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
+ strncmp((char *)invocation_path_tail(p_sh, NULL), "fish", 4) == 0;
#else
false;
#endif
@@ -337,17 +337,17 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
// the argument list, otherwise zsh gives an error message and doesn't
// expand any other pattern.
if (shell_style == STYLE_PRINT) {
- extra_shell_arg = (char_u *)"-G"; // Use zsh NULL_GLOB option
+ extra_shell_arg = "-G"; // Use zsh NULL_GLOB option
// If we use -f then shell variables set in .cshrc won't get expanded.
// vi can do it, so we will too, but it is only necessary if there is a "$"
// in one of the patterns, otherwise we can still use the fast option.
} else if (shell_style == STYLE_GLOB && !have_dollars(num_pat, pat)) {
- extra_shell_arg = (char_u *)"-f"; // Use csh fast option
+ extra_shell_arg = "-f"; // Use csh fast option
}
// execute the shell command
- i = call_shell((char_u *)command, shellopts, extra_shell_arg);
+ i = call_shell(command, shellopts, extra_shell_arg);
// When running in the background, give it some time to create the temp
// file, but don't wait for it to finish.
@@ -488,7 +488,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
goto notfound;
}
*num_file = i;
- *file = xmalloc(sizeof(char_u *) * (size_t)i);
+ *file = xmalloc(sizeof(char *) * (size_t)i);
// Isolate the individual file names.
p = buffer;
@@ -570,18 +570,18 @@ notfound:
char **shell_build_argv(const char *cmd, const char *extra_args)
FUNC_ATTR_NONNULL_RET
{
- size_t argc = tokenize((char_u *)p_sh, NULL) + (cmd ? tokenize(p_shcf, NULL) : 0);
+ size_t argc = tokenize(p_sh, NULL) + (cmd ? tokenize((char *)p_shcf, NULL) : 0);
char **rv = xmalloc((argc + 4) * sizeof(*rv));
// Split 'shell'
- size_t i = tokenize((char_u *)p_sh, rv);
+ size_t i = tokenize(p_sh, rv);
if (extra_args) {
rv[i++] = xstrdup(extra_args); // Push a copy of `extra_args`
}
if (cmd) {
- i += tokenize(p_shcf, rv + i); // Split 'shellcmdflag'
+ i += tokenize((char *)p_shcf, rv + i); // Split 'shellcmdflag'
rv[i++] = shell_xescape_xquote(cmd); // Copy (and escape) `cmd`.
}
@@ -653,7 +653,7 @@ char *shell_argv_to_str(char **const argv)
/// @param extra_args Extra arguments to the shell, or NULL.
///
/// @return shell command exit code
-int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_args)
+int os_call_shell(char *cmd, ShellOpts opts, char *extra_args)
{
DynamicBuffer input = DYNAMIC_BUFFER_INIT;
char *output = NULL, **output_ptr = NULL;
@@ -682,7 +682,7 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_args)
}
size_t nread;
- int exitcode = do_os_system(shell_build_argv((char *)cmd, (char *)extra_args),
+ int exitcode = do_os_system(shell_build_argv(cmd, extra_args),
input.data, input.len, output_ptr, &nread,
emsg_silent, forward_output);
xfree(input.data);
@@ -708,14 +708,14 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_args)
/// Invalidates cached tags.
///
/// @return shell command exit code
-int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
+int call_shell(char *cmd, ShellOpts opts, char *extra_shell_arg)
{
int retval;
proftime_T wait_time;
if (p_verbose > 3) {
verbose_enter();
- smsg(_("Executing command: \"%s\""), cmd == NULL ? p_sh : (char *)cmd);
+ smsg(_("Executing command: \"%s\""), cmd == NULL ? p_sh : cmd);
msg_putchar('\n');
verbose_leave();
}
@@ -752,23 +752,23 @@ int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
/// @param ret_len length of the stdout
///
/// @return an allocated string, or NULL for error.
-char_u *get_cmd_output(char_u *cmd, char_u *infile, ShellOpts flags, size_t *ret_len)
+char *get_cmd_output(char *cmd, char *infile, ShellOpts flags, size_t *ret_len)
{
- char_u *buffer = NULL;
+ char *buffer = NULL;
if (check_secure()) {
return NULL;
}
// get a name for the temp file
- char_u *tempname = (char_u *)vim_tempname();
+ char *tempname = vim_tempname();
if (tempname == NULL) {
emsg(_(e_notmp));
return NULL;
}
// Add the redirection stuff
- char_u *command = (char_u *)make_filter_cmd((char *)cmd, (char *)infile, (char *)tempname);
+ char *command = make_filter_cmd(cmd, infile, tempname);
// Call the shell to execute the command (errors are ignored).
// Don't check timestamps here.
@@ -779,7 +779,7 @@ char_u *get_cmd_output(char_u *cmd, char_u *infile, ShellOpts flags, size_t *ret
xfree(command);
// read the names from the file into memory
- FILE *fd = os_fopen((char *)tempname, READBIN);
+ FILE *fd = os_fopen(tempname, READBIN);
if (fd == NULL) {
semsg(_(e_notopen), tempname);
@@ -791,9 +791,9 @@ char_u *get_cmd_output(char_u *cmd, char_u *infile, ShellOpts flags, size_t *ret
fseek(fd, 0L, SEEK_SET);
buffer = xmalloc(len + 1);
- size_t i = fread((char *)buffer, 1, len, fd);
+ size_t i = fread(buffer, 1, len, fd);
fclose(fd);
- os_remove((char *)tempname);
+ os_remove(tempname);
if (i != len) {
semsg(_(e_notread), tempname);
XFREE_CLEAR(buffer);
@@ -1165,14 +1165,14 @@ static void out_data_cb(Stream *stream, RBuffer *buf, size_t count, void *data,
/// @param argv The vector that will be filled with copies of the parsed
/// words. It can be NULL if the caller only needs to count words.
/// @return The number of words parsed.
-static size_t tokenize(const char_u *const str, char **const argv)
+static size_t tokenize(const char *const str, char **const argv)
FUNC_ATTR_NONNULL_ARG(1)
{
size_t argc = 0;
- const char *p = (const char *)str;
+ const char *p = str;
while (*p != NUL) {
- const size_t len = word_length((const char_u *)p);
+ const size_t len = word_length(p);
if (argv != NULL) {
// Fill the slot
@@ -1190,9 +1190,9 @@ static size_t tokenize(const char_u *const str, char **const argv)
///
/// @param str A pointer to the first character of the word
/// @return The offset from `str` at which the word ends.
-static size_t word_length(const char_u *str)
+static size_t word_length(const char *str)
{
- const char_u *p = str;
+ const char *p = str;
bool inquote = false;
size_t length = 0;
@@ -1223,10 +1223,10 @@ static void read_input(DynamicBuffer *buf)
{
size_t written = 0, l = 0, len = 0;
linenr_T lnum = curbuf->b_op_start.lnum;
- char_u *lp = (char_u *)ml_get(lnum);
+ char *lp = ml_get(lnum);
for (;;) {
- l = strlen((char *)lp + written);
+ l = strlen(lp + written);
if (l == 0) {
len = 0;
} else if (lp[written] == NL) {
@@ -1235,7 +1235,7 @@ static void read_input(DynamicBuffer *buf)
dynamic_buffer_ensure(buf, buf->len + len);
buf->data[buf->len++] = NUL;
} else {
- char_u *s = (char_u *)vim_strchr((char *)lp + written, NL);
+ char *s = vim_strchr(lp + written, NL);
len = s == NULL ? l : (size_t)(s - (lp + written));
dynamic_buffer_ensure(buf, buf->len + len);
memcpy(buf->data + buf->len, lp + written, len);
@@ -1255,7 +1255,7 @@ static void read_input(DynamicBuffer *buf)
if (lnum > curbuf->b_op_end.lnum) {
break;
}
- lp = (char_u *)ml_get(lnum);
+ lp = ml_get(lnum);
written = 0;
} else if (len > 0) {
written += len;
diff --git a/src/nvim/path.c b/src/nvim/path.c
index fa73938816..9350335e54 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -154,11 +154,11 @@ char *path_tail_with_sep(char *fname)
/// @post if `len` is not null, stores the length of the executable name.
///
/// @return The position of the last path separator + 1.
-const char_u *invocation_path_tail(const char_u *invocation, size_t *len)
+const char_u *invocation_path_tail(const char *invocation, size_t *len)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1)
{
- const char_u *tail = (char_u *)get_past_head((char *)invocation);
- const char_u *p = tail;
+ const char *tail = get_past_head(invocation);
+ const char *p = tail;
while (*p != NUL && *p != ' ') {
bool was_sep = vim_ispathsep_nocolon(*p);
MB_PTR_ADV(p);
@@ -171,7 +171,7 @@ const char_u *invocation_path_tail(const char_u *invocation, size_t *len)
*len = (size_t)(p - tail);
}
- return tail;
+ return (char_u *)tail;
}
/// Get the next path component of a path name.
@@ -279,13 +279,13 @@ int vim_ispathlistsep(int c)
/// "trim_len" specifies how many characters to keep for each directory.
/// Must be 1 or more.
/// It's done in-place.
-void shorten_dir_len(char_u *str, int trim_len)
+void shorten_dir_len(char *str, int trim_len)
{
- char_u *tail = (char_u *)path_tail((char *)str);
- char_u *d = str;
+ char *tail = path_tail(str);
+ char *d = str;
bool skip = false;
int dirchunk_len = 0;
- for (char_u *s = str;; s++) {
+ for (char *s = str;; s++) {
if (s >= tail) { // copy the whole tail
*d++ = *s;
if (*s == NUL) {
@@ -305,7 +305,7 @@ void shorten_dir_len(char_u *str, int trim_len)
skip = true;
}
}
- int l = utfc_ptr2len((char *)s);
+ int l = utfc_ptr2len(s);
while (--l > 0) {
*d++ = *++s;
}
@@ -317,21 +317,21 @@ void shorten_dir_len(char_u *str, int trim_len)
/// It's done in-place.
void shorten_dir(char *str)
{
- shorten_dir_len((char_u *)str, 1);
+ shorten_dir_len(str, 1);
}
/// Return true if the directory of "fname" exists, false otherwise.
/// Also returns true if there is no directory name.
/// "fname" must be writable!.
-bool dir_of_file_exists(char_u *fname)
+bool dir_of_file_exists(char *fname)
{
- char *p = path_tail_with_sep((char *)fname);
- if ((char_u *)p == fname) {
+ char *p = path_tail_with_sep(fname);
+ if (p == fname) {
return true;
}
char c = *p;
*p = NUL;
- bool retval = os_isdir((char *)fname);
+ bool retval = os_isdir(fname);
*p = c;
return retval;
}
@@ -553,7 +553,7 @@ static int pstrcmp(const void *a, const void *b)
/// @param p The path to expand.
/// @returns Unix: True if it contains one of *?[{.
/// @returns Windows: True if it contains one of *?[.
-bool path_has_exp_wildcard(const char_u *p)
+bool path_has_exp_wildcard(const char *p)
FUNC_ATTR_NONNULL_ALL
{
for (; *p != NUL; MB_PTR_ADV(p)) {
@@ -567,7 +567,7 @@ bool path_has_exp_wildcard(const char_u *p)
#else
const char *wildcards = "*?["; // Windows.
#endif
- if (vim_strchr(wildcards, *p) != NULL) {
+ if (vim_strchr(wildcards, (uint8_t)(*p)) != NULL) {
return true;
}
}
@@ -751,7 +751,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
}
STRCPY(buf + len, path_end);
- if (path_has_exp_wildcard((char_u *)path_end)) { // handle more wildcards
+ if (path_has_exp_wildcard(path_end)) { // handle more wildcards
// need to expand another component of the path
// remove backslashes for the remaining components only
(void)do_path_expand(gap, buf, len + 1, flags, false);
@@ -854,8 +854,8 @@ static void expand_path_option(char *curdir, garray_T *gap)
if (curbuf->b_ffname == NULL) {
continue;
}
- char_u *p = (char_u *)path_tail(curbuf->b_ffname);
- size_t len = (size_t)(p - (char_u *)curbuf->b_ffname);
+ char *p = path_tail(curbuf->b_ffname);
+ size_t len = (size_t)(p - curbuf->b_ffname);
if (len + strlen(buf) >= MAXPATHL) {
continue;
}
@@ -865,7 +865,7 @@ static void expand_path_option(char *curdir, garray_T *gap)
STRMOVE(buf + len, buf + 2);
}
memmove(buf, curbuf->b_ffname, len);
- simplify_filename((char_u *)buf);
+ simplify_filename(buf);
} else if (buf[0] == NUL) {
STRCPY(buf, curdir); // relative to current directory
} else if (path_with_url(buf)) {
@@ -879,7 +879,7 @@ static void expand_path_option(char *curdir, garray_T *gap)
STRMOVE(buf + len + 1, buf);
STRCPY(buf, curdir);
buf[len] = (char_u)PATHSEP;
- simplify_filename((char_u *)buf);
+ simplify_filename(buf);
}
GA_APPEND(char *, gap, xstrdup(buf));
@@ -940,7 +940,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern)
char *short_name;
ga_remove_duplicate_strings(gap);
- ga_init(&path_ga, (int)sizeof(char_u *), 1);
+ ga_init(&path_ga, (int)sizeof(char *), 1);
// We need to prepend a '*' at the beginning of file_pattern so that the
// regex matches anywhere in the path. FIXME: is this valid for all
@@ -967,7 +967,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern)
os_dirname(curdir, MAXPATHL);
expand_path_option(curdir, &path_ga);
- in_curdir = xcalloc((size_t)gap->ga_len, sizeof(char_u *));
+ in_curdir = xcalloc((size_t)gap->ga_len, sizeof(char *));
for (int i = 0; i < gap->ga_len && !got_int; i++) {
char *path = fnames[i];
@@ -1120,7 +1120,7 @@ static int expand_in_path(garray_T *const gap, char *const pattern, const int fl
char *const curdir = xmalloc(MAXPATHL);
os_dirname(curdir, MAXPATHL);
- ga_init(&path_ga, (int)sizeof(char_u *), 1);
+ ga_init(&path_ga, (int)sizeof(char *), 1);
expand_path_option(curdir, &path_ga);
xfree(curdir);
if (GA_EMPTY(&path_ga)) {
@@ -1241,7 +1241,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
recursive = true;
// The matching file names are stored in a growarray. Init it empty.
- ga_init(&ga, (int)sizeof(char_u *), 30);
+ ga_init(&ga, (int)sizeof(char *), 30);
for (int i = 0; i < num_pat && !got_int; i++) {
add_pat = -1;
@@ -1259,7 +1259,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
} else {
// First expand environment variables, "~/" and "~user/".
if ((has_env_var((char_u *)p) && !(flags & EW_NOTENV)) || *p == '~') {
- p = (char *)expand_env_save_opt((char_u *)p, true);
+ p = (char *)expand_env_save_opt(p, true);
if (p == NULL) {
p = pat[i];
} else {
@@ -1284,7 +1284,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
// there is no match, and EW_NOTFOUND is given, add the pattern.
// Otherwise: Add the file name if it exists or when EW_NOTFOUND is
// given.
- if (path_has_exp_wildcard((char_u *)p) || (flags & EW_ICASE)) {
+ if (path_has_exp_wildcard(p) || (flags & EW_ICASE)) {
if ((flags & EW_PATH)
&& !path_is_absolute((char_u *)p)
&& !(p[0] == '.'
@@ -1372,8 +1372,7 @@ static int expand_backtick(garray_T *gap, char *pat, int flags)
if (*cmd == '=') { // `={expr}`: Expand expression
buffer = eval_to_string(cmd + 1, &p, true);
} else {
- buffer = (char *)get_cmd_output((char_u *)cmd, NULL, (flags & EW_SILENT) ? kShellOptSilent : 0,
- NULL);
+ buffer = get_cmd_output(cmd, NULL, (flags & EW_SILENT) ? kShellOptSilent : 0, NULL);
}
xfree(cmd);
if (buffer == NULL) {
@@ -1495,14 +1494,14 @@ void addfile(garray_T *gap, char *f, int flags)
// its simplest form by stripping out unneeded components, if any. The
// resulting file name is simplified in place and will either be the same
// length as that supplied, or shorter.
-void simplify_filename(char_u *filename)
+void simplify_filename(char *filename)
{
int components = 0;
char *p, *tail, *start;
bool stripping_disabled = false;
bool relative = true;
- p = (char *)filename;
+ p = filename;
#ifdef BACKSLASH_IN_FILENAME
if (p[0] != NUL && p[1] == ':') { // skip "x:"
p += 2;
@@ -1561,7 +1560,7 @@ void simplify_filename(char_u *filename)
saved_char = p[-1];
p[-1] = NUL;
FileInfo file_info;
- if (!os_fileinfo_link((char *)filename, &file_info)) {
+ if (!os_fileinfo_link(filename, &file_info)) {
do_strip = true;
}
p[-1] = saved_char;
@@ -1585,7 +1584,7 @@ void simplify_filename(char_u *filename)
// components.
saved_char = *tail;
*tail = NUL;
- if (os_fileinfo((char *)filename, &file_info)) {
+ if (os_fileinfo(filename, &file_info)) {
do_strip = true;
} else {
stripping_disabled = true;
@@ -1605,7 +1604,7 @@ void simplify_filename(char_u *filename)
} else {
saved_char = *p;
*p = NUL;
- os_fileinfo((char *)filename, &new_file_info);
+ os_fileinfo(filename, &new_file_info);
*p = saved_char;
}
@@ -1690,8 +1689,8 @@ char *find_file_name_in_path(char *ptr, size_t len, int options, long count, cha
}
if (options & FNAME_EXP) {
- file_name = (char *)find_file_in_path((char_u *)ptr, len, options & ~FNAME_MESS, true,
- (char_u *)rel_fname);
+ file_name = (char *)find_file_in_path(ptr, len, options & ~FNAME_MESS, true,
+ rel_fname);
// If the file could not be found in a normal way, try applying
// 'includeexpr' (unless done already).
@@ -1701,8 +1700,8 @@ char *find_file_name_in_path(char *ptr, size_t len, int options, long count, cha
if (tofree != NULL) {
ptr = tofree;
len = strlen(ptr);
- file_name = (char *)find_file_in_path((char_u *)ptr, len, options & ~FNAME_MESS,
- true, (char_u *)rel_fname);
+ file_name = (char *)find_file_in_path(ptr, len, options & ~FNAME_MESS,
+ true, rel_fname);
}
}
if (file_name == NULL && (options & FNAME_MESS)) {
@@ -1717,7 +1716,7 @@ char *find_file_name_in_path(char *ptr, size_t len, int options, long count, cha
while (file_name != NULL && --count > 0) {
xfree(file_name);
file_name =
- (char *)find_file_in_path((char_u *)ptr, len, options, false, (char_u *)rel_fname);
+ (char *)find_file_in_path(ptr, len, options, false, rel_fname);
}
} else {
file_name = xstrnsave(ptr, len);
@@ -1798,9 +1797,9 @@ bool path_with_extension(const char *path, const char *extension)
}
/// Return true if "name" is a full (absolute) path name or URL.
-bool vim_isAbsName(char_u *name)
+bool vim_isAbsName(char *name)
{
- return path_with_url((char *)name) != 0 || path_is_absolute(name);
+ return path_with_url(name) != 0 || path_is_absolute((char_u *)name);
}
/// Save absolute file name to "buf[len]".
@@ -1945,7 +1944,7 @@ int after_pathsep(const char *b, const char *p)
/// Return true if file names "f1" and "f2" are in the same directory.
/// "f1" may be a short name, "f2" must be a full path.
-bool same_directory(char_u *f1, char_u *f2)
+bool same_directory(char *f1, char *f2)
{
char ffname[MAXPATHL];
char *t1;
@@ -1956,11 +1955,11 @@ bool same_directory(char_u *f1, char_u *f2)
return false;
}
- (void)vim_FullName((char *)f1, (char *)ffname, MAXPATHL, false);
+ (void)vim_FullName(f1, (char *)ffname, MAXPATHL, false);
t1 = path_tail_with_sep(ffname);
- t2 = path_tail_with_sep((char *)f2);
- return t1 - ffname == (char_u *)t2 - f2
- && pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
+ t2 = path_tail_with_sep(f2);
+ return t1 - ffname == t2 - f2
+ && pathcmp((char *)ffname, f2, (int)(t1 - ffname)) == 0;
}
// Compare path "p[]" to "q[]".
@@ -2044,13 +2043,13 @@ int pathcmp(const char *p, const char *q, int maxlen)
/// - Pointer into `full_path` if shortened.
/// - `full_path` unchanged if no shorter name is possible.
/// - NULL if `full_path` is NULL.
-char_u *path_try_shorten_fname(char_u *full_path)
+char *path_try_shorten_fname(char *full_path)
{
char *dirname = xmalloc(MAXPATHL);
- char_u *p = full_path;
+ char *p = full_path;
if (os_dirname(dirname, MAXPATHL) == OK) {
- p = (char_u *)path_shorten_fname((char *)full_path, dirname);
+ p = path_shorten_fname(full_path, dirname);
if (p == NULL || *p == NUL) {
p = full_path;
}
@@ -2174,7 +2173,7 @@ int expand_wildcards(int num_pat, char **pat, int *num_files, char ***files, int
{
int retval;
int i, j;
- char_u *p;
+ char *p;
int non_suf_match; // number without matching suffix
retval = gen_expand_wildcards(num_pat, pat, num_files, files, flags);
@@ -2215,11 +2214,11 @@ int expand_wildcards(int num_pat, char **pat, int *num_files, char ***files, int
for (i = 0; i < *num_files; i++) {
if (!match_suffix((*files)[i])) {
// Move the name without matching suffix to the front of the list.
- p = (char_u *)(*files)[i];
+ p = (*files)[i];
for (j = i; j > non_suf_match; j--) {
(*files)[j] = (*files)[j - 1];
}
- (*files)[non_suf_match++] = (char *)p;
+ (*files)[non_suf_match++] = p;
}
}
}
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 20a6855a16..e4d1ddf8d8 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -108,7 +108,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum)
if (*s == NUL) { // empty line
return 1;
}
- col = win_linetabsize(wp, lnum, (char_u *)s, MAXCOL);
+ col = win_linetabsize(wp, lnum, s, MAXCOL);
// If list mode is on, then the '$' at the end of the line may take up one
// extra column.
@@ -146,12 +146,12 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
return lines + 1;
}
- char_u *line = (char_u *)ml_get_buf(wp->w_buffer, lnum, false);
+ char *line = ml_get_buf(wp->w_buffer, lnum, false);
colnr_T col = 0;
chartabsize_T cts;
- init_chartabsize_arg(&cts, wp, lnum, 0, (char *)line, (char *)line);
+ init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
while (*cts.cts_ptr != NUL && --column >= 0) {
cts.cts_vcol += win_lbr_chartabsize(&cts, NULL);
MB_PTR_ADV(cts.cts_ptr);
@@ -244,9 +244,9 @@ int win_chartabsize(win_T *wp, char *p, colnr_T col)
/// @param s
///
/// @return Number of characters the string will take on the screen.
-int linetabsize(char_u *s)
+int linetabsize(char *s)
{
- return linetabsize_col(0, (char *)s);
+ return linetabsize_col(0, s);
}
/// Like linetabsize(), but "s" starts at column "startcol".
@@ -273,11 +273,11 @@ int linetabsize_col(int startcol, char *s)
/// @param len
///
/// @return Number of characters the string will take on the screen.
-unsigned int win_linetabsize(win_T *wp, linenr_T lnum, char_u *line, colnr_T len)
+unsigned int win_linetabsize(win_T *wp, linenr_T lnum, char *line, colnr_T len)
{
chartabsize_T cts;
- init_chartabsize_arg(&cts, wp, lnum, 0, (char *)line, (char *)line);
- for (; *cts.cts_ptr != NUL && (len == MAXCOL || cts.cts_ptr < (char *)line + len);
+ init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
+ for (; *cts.cts_ptr != NUL && (len == MAXCOL || cts.cts_ptr < line + len);
MB_PTR_ADV(cts.cts_ptr)) {
cts.cts_vcol += win_lbr_chartabsize(&cts, NULL);
}
@@ -354,7 +354,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
{
win_T *wp = cts->cts_win;
char *line = cts->cts_line; // start of the line
- char_u *s = (char_u *)cts->cts_ptr;
+ char *s = cts->cts_ptr;
colnr_T vcol = cts->cts_vcol;
colnr_T col2;
@@ -363,7 +363,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
int added;
int mb_added = 0;
int numberextra;
- char_u *ps;
+ char *ps;
int n;
cts->cts_cur_text_width = 0;
@@ -374,16 +374,16 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
if (wp->w_p_wrap) {
return win_nolbr_chartabsize(cts, headp);
}
- return win_chartabsize(wp, (char *)s, vcol);
+ return win_chartabsize(wp, s, vcol);
}
// First get normal size, without 'linebreak' or virtual text
- int size = win_chartabsize(wp, (char *)s, vcol);
+ int size = win_chartabsize(wp, s, vcol);
if (cts->cts_has_virt_text) {
// TODO(bfredl): inline virtual text
}
- int c = *s;
+ int c = (uint8_t)(*s);
if (*s == TAB) {
col_adj = size - 1;
}
@@ -392,7 +392,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
// needs a break here
if (wp->w_p_lbr
&& vim_isbreak(c)
- && !vim_isbreak((int)s[1])
+ && !vim_isbreak((uint8_t)s[1])
&& wp->w_p_wrap
&& (wp->w_width_inner != 0)) {
// Count all characters from first non-blank after a blank up to next
@@ -413,14 +413,14 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
for (;;) {
ps = s;
MB_PTR_ADV(s);
- c = *s;
+ c = (uint8_t)(*s);
if (!(c != NUL
- && (vim_isbreak(c) || col2 == vcol || !vim_isbreak((int)(*ps))))) {
+ && (vim_isbreak(c) || col2 == vcol || !vim_isbreak((uint8_t)(*ps))))) {
break;
}
- col2 += win_chartabsize(wp, (char *)s, col2);
+ col2 += win_chartabsize(wp, s, col2);
if (col2 >= colmax) { // doesn't fit
size = colmax - vcol + col_adj;
@@ -428,7 +428,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
}
}
} else if ((size == 2)
- && (MB_BYTE2LEN(*s) > 1)
+ && (MB_BYTE2LEN((uint8_t)(*s)) > 1)
&& wp->w_p_wrap
&& in_win_border(wp, vcol)) {
// Count the ">" in the last column.
@@ -456,7 +456,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
vcol %= numberextra;
}
if (*sbr != NUL) {
- sbrlen = (colnr_T)mb_charlen((char_u *)sbr);
+ sbrlen = (colnr_T)mb_charlen(sbr);
if (vcol >= sbrlen) {
vcol -= sbrlen;
}
@@ -492,7 +492,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
}
if (wp->w_p_bri) {
- added += get_breakindent_win(wp, (char_u *)line);
+ added += get_breakindent_win(wp, line);
}
size += added;
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index ba90983e37..1d55b2ef31 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -78,19 +78,19 @@ static void pum_compute_size(void)
for (int i = 0; i < pum_size; i++) {
int w;
if (pum_array[i].pum_text != NULL) {
- w = vim_strsize((char *)pum_array[i].pum_text);
+ w = vim_strsize(pum_array[i].pum_text);
if (pum_base_width < w) {
pum_base_width = w;
}
}
if (pum_array[i].pum_kind != NULL) {
- w = vim_strsize((char *)pum_array[i].pum_kind) + 1;
+ w = vim_strsize(pum_array[i].pum_kind) + 1;
if (pum_kind_width < w) {
pum_kind_width = w;
}
}
if (pum_array[i].pum_extra != NULL) {
- w = vim_strsize((char *)pum_array[i].pum_extra) + 1;
+ w = vim_strsize(pum_array[i].pum_extra) + 1;
if (pum_extra_width < w) {
pum_extra_width = w;
}
@@ -167,10 +167,10 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
Array arr = arena_array(&arena, (size_t)size);
for (int i = 0; i < size; i++) {
Array item = arena_array(&arena, 4);
- ADD_C(item, STRING_OBJ(cstr_as_string((char *)array[i].pum_text)));
- ADD_C(item, STRING_OBJ(cstr_as_string((char *)array[i].pum_kind)));
- ADD_C(item, STRING_OBJ(cstr_as_string((char *)array[i].pum_extra)));
- ADD_C(item, STRING_OBJ(cstr_as_string((char *)array[i].pum_info)));
+ ADD_C(item, STRING_OBJ(cstr_as_string(array[i].pum_text)));
+ ADD_C(item, STRING_OBJ(cstr_as_string(array[i].pum_kind)));
+ ADD_C(item, STRING_OBJ(cstr_as_string(array[i].pum_extra)));
+ ADD_C(item, STRING_OBJ(cstr_as_string(array[i].pum_info)));
ADD_C(arr, ARRAY_OBJ(item));
}
ui_call_popupmenu_show(arr, selected, pum_win_row, cursor_col,
@@ -501,15 +501,15 @@ void pum_redraw(void)
switch (round) {
case 1:
- p = (char *)pum_array[idx].pum_text;
+ p = pum_array[idx].pum_text;
break;
case 2:
- p = (char *)pum_array[idx].pum_kind;
+ p = pum_array[idx].pum_kind;
break;
case 3:
- p = (char *)pum_array[idx].pum_extra;
+ p = pum_array[idx].pum_extra;
break;
}
@@ -765,7 +765,7 @@ static bool pum_set_selected(int n, int repeat)
char *p, *e;
linenr_T lnum = 0;
- for (p = (char *)pum_array[pum_selected].pum_info; *p != NUL;) {
+ for (p = pum_array[pum_selected].pum_info; *p != NUL;) {
e = vim_strchr(p, '\n');
if (e == NULL) {
ml_append(lnum++, p, 0, false);
@@ -1060,7 +1060,7 @@ void pum_show_popupmenu(vimmenu_T *menu)
}
if (s != NULL) {
s = xstrdup(s);
- array[idx++].pum_text = (char_u *)s;
+ array[idx++].pum_text = s;
}
}
diff --git a/src/nvim/popupmenu.h b/src/nvim/popupmenu.h
index 2190c560b7..08b791c509 100644
--- a/src/nvim/popupmenu.h
+++ b/src/nvim/popupmenu.h
@@ -10,10 +10,10 @@
/// Used for popup menu items.
typedef struct {
- char_u *pum_text; // main menu text
- char_u *pum_kind; // extra kind text (may be truncated)
- char_u *pum_extra; // extra menu text (may be truncated)
- char_u *pum_info; // extra info
+ char *pum_text; // main menu text
+ char *pum_kind; // extra kind text (may be truncated)
+ char *pum_extra; // extra menu text (may be truncated)
+ char *pum_info; // extra info
} pumitem_T;
EXTERN ScreenGrid pum_grid INIT(= SCREEN_GRID_INIT);
diff --git a/src/nvim/profile.c b/src/nvim/profile.c
index 4acd8b3621..866834fc71 100644
--- a/src/nvim/profile.c
+++ b/src/nvim/profile.c
@@ -299,7 +299,7 @@ void ex_profile(exarg_T *eap)
if (len == 5 && strncmp(eap->arg, "start", 5) == 0 && *e != NUL) {
xfree(profile_fname);
- profile_fname = (char *)expand_env_save_opt((char_u *)e, true);
+ profile_fname = (char *)expand_env_save_opt(e, true);
do_profiling = PROF_YES;
profile_set_wait(profile_zero());
set_vim_var_nr(VV_PROFILING, 1L);
@@ -368,14 +368,14 @@ void set_context_in_profile_cmd(expand_T *xp, const char *arg)
pexpand_what = PEXP_SUBCMD;
xp->xp_pattern = (char *)arg;
- char_u *const end_subcmd = (char_u *)skiptowhite(arg);
+ char *const end_subcmd = skiptowhite(arg);
if (*end_subcmd == NUL) {
return;
}
- if ((const char *)end_subcmd - arg == 5 && strncmp(arg, "start", 5) == 0) {
+ if (end_subcmd - arg == 5 && strncmp(arg, "start", 5) == 0) {
xp->xp_context = EXPAND_FILES;
- xp->xp_pattern = skipwhite((char *)end_subcmd);
+ xp->xp_pattern = skipwhite(end_subcmd);
return;
}
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index a82d50e641..c895ac16f1 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -2075,7 +2075,7 @@ static int qf_get_fnum(qf_list_T *qfl, char *directory, char *fname)
}
slash_adjust(fname);
#endif
- if (directory != NULL && !vim_isAbsName((char_u *)fname)) {
+ if (directory != NULL && !vim_isAbsName(fname)) {
ptr = concat_fnames(directory, fname, true);
// Here we check if the file really exists.
// This should normally be true, but if make works without
@@ -2128,7 +2128,7 @@ static char *qf_push_dir(char *dirbuf, struct dir_stack_T **stackptr, bool is_fi
*stackptr = ds_new;
// store directory on the stack
- if (vim_isAbsName((char_u *)dirbuf)
+ if (vim_isAbsName(dirbuf)
|| (*stackptr)->next == NULL
|| is_file_stack) {
(*stackptr)->dirname = xstrdup(dirbuf);
@@ -5374,7 +5374,7 @@ static int vgr_process_files(win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, boo
time_t seconds = (time_t)0;
for (int fi = 0; fi < cmd_args->fcount && !got_int && cmd_args->tomatch > 0; fi++) {
- char *fname = (char *)path_try_shorten_fname((char_u *)cmd_args->fnames[fi]);
+ char *fname = path_try_shorten_fname(cmd_args->fnames[fi]);
if (time(NULL) > seconds) {
// Display the file name every second or so, show the user we are
// working on it.
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 707ae12078..e396e54ced 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -1150,7 +1150,7 @@ static bool reg_match_visual(void)
rex.line = reg_getline(rex.lnum);
rex.input = rex.line + col;
- unsigned int cols_u = win_linetabsize(wp, rex.reg_firstlnum + rex.lnum, rex.line, col);
+ unsigned int cols_u = win_linetabsize(wp, rex.reg_firstlnum + rex.lnum, (char *)rex.line, col);
assert(cols_u <= MAXCOL);
colnr_T cols = (colnr_T)cols_u;
if (cols < start || cols > end - (*p_sel == 'e')) {
diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c
index 810b35a77d..f930d872b6 100644
--- a/src/nvim/regexp_bt.c
+++ b/src/nvim/regexp_bt.c
@@ -3703,7 +3703,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
if (!re_num_cmp(win_linetabsize(rex.reg_win == NULL
? curwin : rex.reg_win,
rex.reg_firstlnum + rex.lnum,
- rex.line,
+ (char *)rex.line,
(colnr_T)(rex.input - rex.line)) + 1,
scan)) {
status = RA_NOMATCH;
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index ea57e8a34c..6e7ff31c03 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -6841,7 +6841,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
result = col > t->state->val * ts;
}
if (!result) {
- uintmax_t lts = win_linetabsize(wp, rex.reg_firstlnum + rex.lnum, rex.line, col);
+ uintmax_t lts = win_linetabsize(wp, rex.reg_firstlnum + rex.lnum, (char *)rex.line, col);
assert(t->state->val >= 0);
result = nfa_re_num_cmp((uintmax_t)t->state->val, op, lts + 1);
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index afdb04ebd8..b18bf7ed6a 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -189,7 +189,7 @@ int compute_foldcolumn(win_T *wp, int col)
///
/// Assume monocell characters
/// @return number of chars added to \param p
-size_t fill_foldcolumn(char_u *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum)
+size_t fill_foldcolumn(char *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum)
{
int i = 0;
int level;
@@ -223,7 +223,7 @@ size_t fill_foldcolumn(char_u *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum)
symbol = '>';
}
- len = utf_char2bytes(symbol, (char *)&p[char_counter]);
+ len = utf_char2bytes(symbol, &p[char_counter]);
char_counter += (size_t)len;
if (first_level + i >= level) {
i++;
@@ -237,7 +237,7 @@ size_t fill_foldcolumn(char_u *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum)
char_counter -= (size_t)len;
memset(&p[char_counter], ' ', (size_t)len);
}
- len = utf_char2bytes(wp->w_p_fcs_chars.foldclosed, (char *)&p[char_counter]);
+ len = utf_char2bytes(wp->w_p_fcs_chars.foldclosed, &p[char_counter]);
char_counter += (size_t)len;
}
@@ -817,7 +817,7 @@ int number_width(win_T *wp)
/// Returns 0 for invalid hex or invalid UTF-8 byte.
static int get_encoded_char_adv(const char_u **p)
{
- const char_u *s = *p;
+ const char *s = (const char *)(*p);
if (s[0] == '\\' && (s[1] == 'x' || s[1] == 'u' || s[1] == 'U')) {
int64_t num = 0;
@@ -834,7 +834,7 @@ static int get_encoded_char_adv(const char_u **p)
}
// TODO(bfredl): use schar_T representation and utfc_ptr2len
- int clen = utf_ptr2len((const char *)s);
+ int clen = utf_ptr2len(s);
int c = mb_cptr2char_adv(p);
if (clen == 1 && c > 127) { // Invalid UTF-8 byte
return 0;
@@ -850,8 +850,8 @@ static int get_encoded_char_adv(const char_u **p)
/// @return error message, NULL if it's OK.
char *set_chars_option(win_T *wp, char **varp, bool apply)
{
- const char_u *last_multispace = NULL; // Last occurrence of "multispace:"
- const char_u *last_lmultispace = NULL; // Last occurrence of "leadmultispace:"
+ const char *last_multispace = NULL; // Last occurrence of "multispace:"
+ const char *last_lmultispace = NULL; // Last occurrence of "leadmultispace:"
int multispace_len = 0; // Length of lcs-multispace string
int lead_multispace_len = 0; // Length of lcs-leadmultispace string
const bool is_listchars = (varp == &p_lcs || varp == &wp->w_p_lcs);
@@ -898,18 +898,18 @@ char *set_chars_option(win_T *wp, char **varp, bool apply)
struct chars_tab *tab;
int entries;
- const char_u *value = (char_u *)(*varp);
+ const char *value = *varp;
if (is_listchars) {
tab = lcs_tab;
entries = ARRAY_SIZE(lcs_tab);
if (varp == &wp->w_p_lcs && wp->w_p_lcs[0] == NUL) {
- value = (char_u *)p_lcs; // local value is empty, use the global value
+ value = p_lcs; // local value is empty, use the global value
}
} else {
tab = fcs_tab;
entries = ARRAY_SIZE(fcs_tab);
if (varp == &wp->w_p_fcs && wp->w_p_fcs[0] == NUL) {
- value = (char_u *)p_fcs; // local value is empty, use the global value
+ value = p_fcs; // local value is empty, use the global value
}
}
@@ -944,7 +944,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply)
}
}
}
- const char *p = (char *)value;
+ const char *p = value;
while (*p) {
int i;
for (i = 0; i < entries; i++) {
@@ -999,7 +999,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply)
const char_u *s = (char_u *)p + len + 1;
if (round == 0) {
// Get length of lcs-multispace string in the first round
- last_multispace = (char_u *)p;
+ last_multispace = p;
multispace_len = 0;
while (*s != NUL && *s != ',') {
int c1 = get_encoded_char_adv(&s);
@@ -1017,7 +1017,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply)
int multispace_pos = 0;
while (*s != NUL && *s != ',') {
int c1 = get_encoded_char_adv(&s);
- if (p == (char *)last_multispace) {
+ if (p == last_multispace) {
wp->w_p_lcs_chars.multispace[multispace_pos++] = c1;
}
}
@@ -1030,7 +1030,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply)
const char_u *s = (char_u *)p + len2 + 1;
if (round == 0) {
// get length of lcs-leadmultispace string in first round
- last_lmultispace = (char_u *)p;
+ last_lmultispace = p;
lead_multispace_len = 0;
while (*s != NUL && *s != ',') {
int c1 = get_encoded_char_adv(&s);
@@ -1048,7 +1048,7 @@ char *set_chars_option(win_T *wp, char **varp, bool apply)
int multispace_pos = 0;
while (*s != NUL && *s != ',') {
int c1 = get_encoded_char_adv(&s);
- if (p == (char *)last_lmultispace) {
+ if (p == last_lmultispace) {
wp->w_p_lcs_chars.leadmultispace[multispace_pos++] = c1;
}
}
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 47b690ab42..871d2f9a0a 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -189,7 +189,7 @@ int search_regcomp(char_u *pat, char_u **used_pat, int pat_save, int pat_use, in
}
}
- regmatch->rmm_ic = ignorecase(pat);
+ regmatch->rmm_ic = ignorecase((char *)pat);
regmatch->rmm_maxcol = 0;
regmatch->regprog = vim_regcomp((char *)pat, magic ? RE_MAGIC : 0);
if (regmatch->regprog == NULL) {
@@ -353,19 +353,19 @@ char_u *last_search_pattern(void)
/// Return true when case should be ignored for search pattern "pat".
/// Uses the 'ignorecase' and 'smartcase' options.
-int ignorecase(char_u *pat)
+int ignorecase(char *pat)
{
return ignorecase_opt(pat, p_ic, p_scs);
}
/// As ignorecase() put pass the "ic" and "scs" flags.
-int ignorecase_opt(char_u *pat, int ic_in, int scs)
+int ignorecase_opt(char *pat, int ic_in, int scs)
{
int ic = ic_in;
if (ic && !no_smartcase && scs
&& !(ctrl_x_mode_not_default()
&& curbuf->b_p_inf)) {
- ic = !pat_has_uppercase(pat);
+ ic = !pat_has_uppercase((char_u *)pat);
}
no_smartcase = false;
@@ -3113,7 +3113,7 @@ bool fuzzy_match(char_u *const str, const char_u *const pat_arg, const bool matc
int *const outScore, uint32_t *const matches, const int maxMatches)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{
- const int len = mb_charlen(str);
+ const int len = mb_charlen((char *)str);
bool complete = false;
int numMatches = 0;
@@ -3482,7 +3482,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
assert(len <= INT_MAX);
snprintf(pat, patlen, whole ? "\\<%.*s\\>" : "%.*s", (int)len, ptr);
// ignore case according to p_ic, p_scs and pat
- regmatch.rm_ic = ignorecase((char_u *)pat);
+ regmatch.rm_ic = ignorecase(pat);
regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0);
xfree(pat);
if (regmatch.regprog == NULL) {
@@ -3778,9 +3778,9 @@ search_line:
if (vim_iswordp(p)) {
goto exit_matched;
}
- p = (char *)find_word_start((char_u *)p);
+ p = find_word_start(p);
}
- p = (char *)find_word_end((char_u *)p);
+ p = find_word_end(p);
i = (int)(p - aux);
if (compl_status_adding() && i == ins_compl_len()) {
@@ -3804,8 +3804,8 @@ search_line:
// if depth >= 0 we'll increase files[depth].lnum far
// below -- Acevedo
already = aux = p = skipwhite(line);
- p = (char *)find_word_start((char_u *)p);
- p = (char *)find_word_end((char_u *)p);
+ p = find_word_start(p);
+ p = find_word_end(p);
if (p > aux) {
if (*aux != ')' && IObuff[i - 1] != TAB) {
if (IObuff[i - 1] != ' ') {
@@ -3835,9 +3835,9 @@ search_line:
}
}
- const int add_r = ins_compl_add_infercase((char_u *)aux, i, p_ic,
+ const int add_r = ins_compl_add_infercase(aux, i, p_ic,
curr_fname == curbuf->b_fname
- ? NULL : (char_u *)curr_fname,
+ ? NULL : curr_fname,
dir, cont_s_ipos);
if (add_r == OK) {
// if dir was BACKWARD then honor it just once
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 8c17d8d8be..754139a147 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -1341,7 +1341,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
case kSDItemBufferList:
for (size_t i = 0; i < cur_entry.data.buffer_list.size; i++) {
char *const sfname =
- (char *)path_try_shorten_fname((char_u *)cur_entry.data.buffer_list.buffers[i].fname);
+ path_try_shorten_fname(cur_entry.data.buffer_list.buffers[i].fname);
buf_T *const buf =
buflist_new(cur_entry.data.buffer_list.buffers[i].fname, sfname, 0, BLN_LISTED);
if (buf != NULL) {
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 10abd16ca7..48aed9c6de 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -2415,7 +2415,7 @@ bool spell_iswordp(const char_u *p, const win_T *wp)
int c = utf_ptr2char((char *)s);
if (c > 255) {
- return spell_mb_isword_class(mb_get_class(s), wp);
+ return spell_mb_isword_class(mb_get_class((char *)s), wp);
}
return spelltab.st_isw[c];
}
@@ -2426,7 +2426,7 @@ bool spell_iswordp_nmw(const char_u *p, win_T *wp)
{
int c = utf_ptr2char((char *)p);
if (c > 255) {
- return spell_mb_isword_class(mb_get_class(p), wp);
+ return spell_mb_isword_class(mb_get_class((char *)p), wp);
}
return spelltab.st_isw[c];
}
@@ -3421,7 +3421,7 @@ static void dump_word(slang_T *slang, char *word, char *pat, Direction *dir, int
} else if (((dumpflags & DUMPFLAG_ICASE)
? mb_strnicmp(p, pat, strlen(pat)) == 0
: strncmp(p, pat, strlen(pat)) == 0)
- && ins_compl_add_infercase((char_u *)p, (int)strlen(p),
+ && ins_compl_add_infercase(p, (int)strlen(p),
p_ic, NULL, *dir, false) == OK) {
// if dir was BACKWARD then honor it just once
*dir = FORWARD;
@@ -3584,11 +3584,11 @@ void spell_expand_check_cap(colnr_T col)
// Used for Insert mode completion CTRL-X ?.
// Returns the number of matches. The matches are in "matchp[]", array of
// allocated strings.
-int expand_spelling(linenr_T lnum, char_u *pat, char ***matchp)
+int expand_spelling(linenr_T lnum, char *pat, char ***matchp)
{
garray_T ga;
- spell_suggest_list(&ga, pat, 100, spell_expand_need_cap, true);
+ spell_suggest_list(&ga, (char_u *)pat, 100, spell_expand_need_cap, true);
*matchp = ga.ga_data;
return ga.ga_len;
}
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index d0d667ef2c..e6257aeca1 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -1275,7 +1275,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
// convert the multi-byte strings to wide char strings
smp->sm_lead_w = mb_str2wide(smp->sm_lead);
- smp->sm_leadlen = mb_charlen(smp->sm_lead);
+ smp->sm_leadlen = mb_charlen((char *)smp->sm_lead);
if (smp->sm_oneof == NULL) {
smp->sm_oneof_w = NULL;
} else {
@@ -1664,7 +1664,7 @@ static int *mb_str2wide(char_u *s)
{
int i = 0;
- int *res = xmalloc(((size_t)mb_charlen(s) + 1) * sizeof(int));
+ int *res = xmalloc(((size_t)mb_charlen((char *)s) + 1) * sizeof(int));
for (char_u *p = s; *p != NUL;) {
res[i++] = mb_ptr2char_adv((const char_u **)&p);
}
@@ -3493,7 +3493,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char_u *afflist, afffil
p = (char_u *)word;
if (ae->ae_chop != NULL) {
// Skip chop string.
- i = mb_charlen((char_u *)ae->ae_chop);
+ i = mb_charlen(ae->ae_chop);
for (; i > 0; i--) {
MB_PTR_ADV(p);
}
@@ -3505,7 +3505,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char_u *afflist, afffil
if (ae->ae_chop != NULL) {
// Remove chop string.
p = (char_u *)newword + strlen(newword);
- i = mb_charlen((char_u *)ae->ae_chop);
+ i = mb_charlen(ae->ae_chop);
for (; i > 0; i--) {
MB_PTR_BACK(newword, p);
}
@@ -5641,7 +5641,7 @@ void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo)
// file. We may need to create the "spell" directory first. We
// already checked the runtime directory is writable in
// init_spellfile().
- if (!dir_of_file_exists((char_u *)fname)
+ if (!dir_of_file_exists(fname)
&& (p = (char_u *)path_tail_with_sep(fname)) != (char_u *)fname) {
int c = *p;
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 2768a89d6c..aef26ef288 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -1386,7 +1386,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
// For multi-byte chars check character length against
// COMPOUNDMIN.
if (slang->sl_compminlen > 0
- && mb_charlen((char_u *)tword + sp->ts_splitoff)
+ && mb_charlen(tword + sp->ts_splitoff)
< slang->sl_compminlen) {
break;
}
@@ -1582,7 +1582,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
&& sp->ts_twordlen - sp->ts_splitoff
>= slang->sl_compminlen
&& (slang->sl_compminlen == 0
- || mb_charlen((char_u *)tword + sp->ts_splitoff)
+ || mb_charlen(tword + sp->ts_splitoff)
>= slang->sl_compminlen)
&& (slang->sl_compsylmax < MAXWLEN
|| sp->ts_complen + 1 - sp->ts_compsplit
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 22a2049f26..73aa6eb9ca 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -1162,12 +1162,12 @@ void do_tags(exarg_T *eap)
// Compare two strings, for length "len", ignoring case the ASCII way.
// return 0 for match, < 0 for smaller, > 0 for bigger
// Make sure case is folded to uppercase in comparison (like for 'sort -f')
-static int tag_strnicmp(char_u *s1, char_u *s2, size_t len)
+static int tag_strnicmp(char *s1, char *s2, size_t len)
{
int i;
while (len > 0) {
- i = TOUPPER_ASC(*s1) - TOUPPER_ASC(*s2);
+ i = TOUPPER_ASC((uint8_t)(*s1)) - TOUPPER_ASC((uint8_t)(*s2));
if (i != 0) {
return i; // this character different
}
@@ -1775,7 +1775,7 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta
// Compare the current tag with the searched tag.
if (margs->sortic) {
- tagcmp = tag_strnicmp((char_u *)tagpp->tagname, (char_u *)st->orgpat->head,
+ tagcmp = tag_strnicmp(tagpp->tagname, st->orgpat->head,
(size_t)cmplen);
} else {
tagcmp = strncmp(tagpp->tagname, st->orgpat->head, (size_t)cmplen);
@@ -2358,10 +2358,10 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
p_ic = false;
break;
case TC_FOLLOWSCS:
- p_ic = ignorecase((char_u *)pat);
+ p_ic = ignorecase(pat);
break;
case TC_SMART:
- p_ic = ignorecase_opt((char_u *)pat, true, true);
+ p_ic = ignorecase_opt(pat, true, true);
break;
default:
abort();
@@ -2491,7 +2491,7 @@ static void found_tagfile_cb(char *fname, void *cookie)
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(tag_fname);
#endif
- simplify_filename((char_u *)tag_fname);
+ simplify_filename(tag_fname);
GA_APPEND(char *, &tag_fnames, tag_fname);
}
@@ -2547,7 +2547,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(buf);
#endif
- simplify_filename((char_u *)buf);
+ simplify_filename(buf);
for (int i = 0; i < tag_fnames.ga_len; i++) {
if (strcmp(buf, ((char **)(tag_fnames.ga_data))[i]) == 0) {
@@ -2593,7 +2593,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
buf[0] = NUL;
(void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,");
- r_ptr = (char *)vim_findfile_stopdir((char_u *)buf);
+ r_ptr = (char *)vim_findfile_stopdir(buf);
// move the filename one char forward and truncate the
// filepath with a NUL
filename = path_tail(buf);
@@ -3132,13 +3132,13 @@ static char *expand_tag_fname(char *fname, char *const tag_fname, const bool exp
char *retval;
if ((p_tr || curbuf->b_help)
- && !vim_isAbsName((char_u *)fname)
+ && !vim_isAbsName(fname)
&& (p = path_tail(tag_fname)) != tag_fname) {
retval = xmalloc(MAXPATHL);
STRCPY(retval, tag_fname);
xstrlcpy(retval + (p - tag_fname), fname, (size_t)(MAXPATHL - (p - tag_fname)));
// Translate names like "src/a/../b/file.c" into "src/b/file.c".
- simplify_filename((char_u *)retval);
+ simplify_filename(retval);
} else {
retval = xstrdup(fname);
}
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index c39e11f266..85e261fc39 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -573,7 +573,7 @@ int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, int re
}
if (size > 0) {
- uep->ue_array = xmalloc(sizeof(char_u *) * (size_t)size);
+ uep->ue_array = xmalloc(sizeof(char *) * (size_t)size);
linenr_T lnum;
long i;
for (i = 0, lnum = top + 1; i < size; i++) {
@@ -2322,7 +2322,7 @@ static void u_undoredo(int undo, bool do_buf_event)
linenr_T lnum;
for (lnum = bot - 1, i = oldsize; --i >= 0; lnum--) {
// what can we do when we run out of memory?
- newarray[i] = u_save_line(lnum);
+ newarray[i] = (char_u *)u_save_line(lnum);
// remember we deleted the last line in the buffer, and a
// dummy empty line will be inserted
if (curbuf->b_ml.ml_line_count == 1) {
@@ -2978,7 +2978,7 @@ void u_saveline(linenr_T lnum)
} else {
curbuf->b_u_line_colnr = 0;
}
- curbuf->b_u_line_ptr = (char *)u_save_line(lnum);
+ curbuf->b_u_line_ptr = u_save_line(lnum);
}
/// clear the line saved for the "U" command
@@ -3009,7 +3009,7 @@ void u_undoline(void)
return;
}
- char *oldp = (char *)u_save_line(curbuf->b_u_line_lnum);
+ char *oldp = u_save_line(curbuf->b_u_line_lnum);
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true);
changed_bytes(curbuf->b_u_line_lnum, 0);
extmark_splice_cols(curbuf, (int)curbuf->b_u_line_lnum - 1, 0, (colnr_T)strlen(oldp),
@@ -3043,9 +3043,9 @@ void u_blockfree(buf_T *buf)
/// Allocate memory and copy curbuf line into it.
///
/// @param lnum the line to copy
-static char_u *u_save_line(linenr_T lnum)
+static char *u_save_line(linenr_T lnum)
{
- return (char_u *)u_save_line_buf(curbuf, lnum);
+ return u_save_line_buf(curbuf, lnum);
}
/// Allocate memory and copy line into it
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index e175bd5b61..f8ed190fb2 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -1608,10 +1608,10 @@ int do_ucmd(exarg_T *eap, bool preview)
end = vim_strchr(start + 1, '>');
}
if (buf != NULL) {
- for (ksp = p; *ksp != NUL && (char_u)(*ksp) != K_SPECIAL; ksp++) {}
- if ((char_u)(*ksp) == K_SPECIAL
+ for (ksp = p; *ksp != NUL && (uint8_t)(*ksp) != K_SPECIAL; ksp++) {}
+ if ((uint8_t)(*ksp) == K_SPECIAL
&& (start == NULL || ksp < start || end == NULL)
- && ((char_u)ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)) {
+ && ((uint8_t)ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)) {
// K_SPECIAL has been put in the buffer as K_SPECIAL
// KS_SPECIAL KE_FILLER, like for mappings, but
// do_cmdline() doesn't handle that, so convert it back.