aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/cmdexpand.c4
-rw-r--r--src/nvim/debugger.c50
-rw-r--r--src/nvim/decoration.c2
-rw-r--r--src/nvim/drawline.c4
-rw-r--r--src/nvim/edit.c4
-rw-r--r--src/nvim/eval.c6
-rw-r--r--src/nvim/eval/funcs.c4
-rw-r--r--src/nvim/eval/userfunc.c16
-rw-r--r--src/nvim/eval/vars.c4
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--src/nvim/ex_docmd.c14
-rw-r--r--src/nvim/ex_getln.c21
-rw-r--r--src/nvim/fold.c104
-rw-r--r--src/nvim/mbyte.c21
-rw-r--r--src/nvim/path.c2
-rw-r--r--src/nvim/regexp.c53
-rw-r--r--src/nvim/regexp_bt.c14
-rw-r--r--src/nvim/regexp_nfa.c8
-rw-r--r--src/nvim/search.c4
-rw-r--r--src/nvim/shada.c2
-rw-r--r--src/nvim/sign.c317
-rw-r--r--src/nvim/sign_defs.h2
-rw-r--r--src/nvim/spell.c4
-rw-r--r--src/nvim/syntax.c247
-rw-r--r--src/nvim/tag.c88
-rw-r--r--src/nvim/ui.c2
26 files changed, 493 insertions, 510 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 1c35f28301..7e2adf7f29 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -1424,7 +1424,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons
set_context_in_cscope_cmd(xp, arg, cmdidx);
break;
case CMD_sign:
- set_context_in_sign_cmd(xp, (char_u *)arg);
+ set_context_in_sign_cmd(xp, (char *)arg);
break;
case CMD_bdelete:
case CMD_bwipeout:
@@ -2890,7 +2890,7 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
if (xpc.xp_context == EXPAND_SIGN) {
- set_context_in_sign_cmd(&xpc, (char_u *)xpc.xp_pattern);
+ set_context_in_sign_cmd(&xpc, xpc.xp_pattern);
xpc.xp_pattern_len = STRLEN(xpc.xp_pattern);
}
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index 36df62b502..b720628e33 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -33,7 +33,7 @@ static char *debug_newval = NULL;
struct debuggy {
int dbg_nr; ///< breakpoint number
int dbg_type; ///< DBG_FUNC or DBG_FILE or DBG_EXPR
- char_u *dbg_name; ///< function, expression or file name
+ char *dbg_name; ///< function, expression or file name
regprog_T *dbg_prog; ///< regexp program
linenr_T dbg_lnum; ///< line number in function or file
int dbg_forceit; ///< ! used
@@ -60,7 +60,7 @@ void do_debug(char *cmd)
bool typeahead_saved = false;
int save_ignore_script = 0;
int n;
- char_u *cmdline = NULL;
+ char *cmdline = NULL;
char *p;
char *tail = NULL;
static int last_cmd = 0;
@@ -129,8 +129,8 @@ void do_debug(char *cmd)
}
xfree(cmdline);
- cmdline = (char_u *)getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL,
- CALLBACK_NONE);
+ cmdline = getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL,
+ CALLBACK_NONE);
if (typeahead_saved) {
restore_typeahead(&typeaheadbuf);
@@ -144,7 +144,7 @@ void do_debug(char *cmd)
// If this is a debug command, set "last_cmd".
// If not, reset "last_cmd".
// For a blank line use previous command.
- p = skipwhite((char *)cmdline);
+ p = skipwhite(cmdline);
if (*p != NUL) {
switch (*p) {
case 'c':
@@ -239,14 +239,14 @@ void do_debug(char *cmd)
last_cmd = CMD_STEP;
break;
case CMD_BACKTRACE:
- do_showbacktrace((char_u *)cmd);
+ do_showbacktrace(cmd);
continue;
case CMD_FRAME:
if (*p == NUL) {
- do_showbacktrace((char_u *)cmd);
+ do_showbacktrace(cmd);
} else {
p = skipwhite(p);
- do_setdebugtracelevel((char_u *)p);
+ do_setdebugtracelevel(p);
}
continue;
case CMD_UP:
@@ -266,7 +266,7 @@ void do_debug(char *cmd)
// don't debug this command
n = debug_break_level;
debug_break_level = -1;
- (void)do_cmdline((char *)cmdline, getexline, NULL, DOCMD_VERBOSE|DOCMD_EXCRESET);
+ (void)do_cmdline(cmdline, getexline, NULL, DOCMD_VERBOSE|DOCMD_EXCRESET);
debug_break_level = n;
}
lines_left = Rows - 1;
@@ -306,9 +306,9 @@ static int get_maxbacktrace_level(char *sname)
return maxbacktrace;
}
-static void do_setdebugtracelevel(char_u *arg)
+static void do_setdebugtracelevel(char *arg)
{
- int level = atoi((char *)arg);
+ int level = atoi(arg);
if (*arg == '+' || level < 0) {
debug_backtrace_level += level;
} else {
@@ -335,7 +335,7 @@ static void do_checkbacktracelevel(void)
}
}
-static void do_showbacktrace(char_u *cmd)
+static void do_showbacktrace(char *cmd)
{
char *sname = estack_sfile(ESTACK_NONE);
int max = get_maxbacktrace_level(sname);
@@ -470,7 +470,7 @@ static typval_T *eval_expr_no_emsg(struct debuggy *const bp)
{
// Disable error messages, a bad expression would make Vim unusable.
emsg_off++;
- typval_T *const tv = eval_expr((char *)bp->dbg_name);
+ typval_T *const tv = eval_expr(bp->dbg_name);
emsg_off--;
return tv;
}
@@ -482,9 +482,9 @@ static typval_T *eval_expr_no_emsg(struct debuggy *const bp)
///
/// @param arg
/// @param gap either &dbg_breakp or &prof_ga
-static int dbg_parsearg(char_u *arg, garray_T *gap)
+static int dbg_parsearg(char *arg, garray_T *gap)
{
- char *p = (char *)arg;
+ char *p = arg;
char *q;
bool here = false;
@@ -531,11 +531,11 @@ static int dbg_parsearg(char_u *arg, garray_T *gap)
}
if (bp->dbg_type == DBG_FUNC) {
- bp->dbg_name = vim_strsave((char_u *)p);
+ bp->dbg_name = xstrdup(p);
} else if (here) {
- bp->dbg_name = vim_strsave((char_u *)curbuf->b_ffname);
+ bp->dbg_name = xstrdup(curbuf->b_ffname);
} else if (bp->dbg_type == DBG_EXPR) {
- bp->dbg_name = vim_strsave((char_u *)p);
+ bp->dbg_name = xstrdup(p);
bp->dbg_val = eval_expr_no_emsg(bp);
} else {
// Expand the file name in the same way as do_source(). This means
@@ -551,10 +551,10 @@ static int dbg_parsearg(char_u *arg, garray_T *gap)
return FAIL;
}
if (*p != '*') {
- bp->dbg_name = (char_u *)fix_fname(p);
+ bp->dbg_name = fix_fname(p);
xfree(p);
} else {
- bp->dbg_name = (char_u *)p;
+ bp->dbg_name = p;
}
}
@@ -572,12 +572,12 @@ void ex_breakadd(exarg_T *eap)
gap = &prof_ga;
}
- if (dbg_parsearg((char_u *)eap->arg, gap) == OK) {
+ if (dbg_parsearg(eap->arg, gap) == OK) {
struct debuggy *bp = &DEBUGGY(gap, gap->ga_len);
bp->dbg_forceit = eap->forceit;
if (bp->dbg_type != DBG_EXPR) {
- char *pat = file_pat_to_reg_pat((char *)bp->dbg_name, NULL, NULL, false);
+ char *pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, false);
if (pat != NULL) {
bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
xfree(pat);
@@ -639,7 +639,7 @@ void ex_breakdel(exarg_T *eap)
del_all = true;
} else {
// ":breakdel {func|file|expr} [lnum] {name}"
- if (dbg_parsearg((char_u *)eap->arg, gap) == FAIL) {
+ if (dbg_parsearg(eap->arg, gap) == FAIL) {
return;
}
bp = &DEBUGGY(gap, gap->ga_len);
@@ -697,13 +697,13 @@ void ex_breaklist(exarg_T *eap)
for (int i = 0; i < dbg_breakp.ga_len; i++) {
struct debuggy *bp = &BREAKP(i);
if (bp->dbg_type == DBG_FILE) {
- home_replace(NULL, (char *)bp->dbg_name, (char *)NameBuff, MAXPATHL, true);
+ home_replace(NULL, bp->dbg_name, (char *)NameBuff, MAXPATHL, true);
}
if (bp->dbg_type != DBG_EXPR) {
smsg(_("%3d %s %s line %" PRId64),
bp->dbg_nr,
bp->dbg_type == DBG_FUNC ? "func" : "file",
- bp->dbg_type == DBG_FUNC ? bp->dbg_name : (char_u *)NameBuff,
+ bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff,
(int64_t)bp->dbg_lnum);
} else {
smsg(_("%3d expr %s"), bp->dbg_nr, bp->dbg_name);
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 9f3e5a8638..8955048f45 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -394,7 +394,7 @@ void decor_redraw_signs(buf_T *buf, int row, int *num_signs, SignTextAttrs sattr
}
if (j < SIGN_SHOW_MAX) {
sattrs[j] = (SignTextAttrs) {
- .text = decor->sign_text,
+ .text = (char *)decor->sign_text,
.hl_attr_id = decor->sign_hl_id == 0 ? 0 : syn_id2attr(decor->sign_hl_id),
.priority = decor->priority
};
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 66d8a1fb32..85a0bf2f5f 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -306,7 +306,7 @@ static void get_sign_display_info(bool nrcol, win_T *wp, linenr_T lnum, SignText
if (row == startrow + filler_lines && filler_todo <= 0) {
SignTextAttrs *sattr = sign_get_attr(sign_idx, sattrs, wp->w_scwidth);
if (sattr != NULL) {
- *pp_extra = sattr->text;
+ *pp_extra = (char_u *)sattr->text;
if (*pp_extra != NULL) {
*c_extrap = NUL;
*c_finalp = NUL;
@@ -1349,7 +1349,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
linenr_T lnume = lnum + foldinfo.fi_lines - 1;
memset(buf_fold, ' ', FOLD_TEXT_LEN);
- p_extra = get_foldtext(wp, lnum, lnume, foldinfo, buf_fold);
+ p_extra = (char_u *)get_foldtext(wp, lnum, lnume, foldinfo, (char *)buf_fold);
n_extra = (int)STRLEN(p_extra);
if (p_extra != buf_fold) {
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 642162284c..9144d055f7 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -3236,7 +3236,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);
if (s + (p - look) <= line + curwin->w_cursor.col
&& (icase
- ? mb_strnicmp(s, look, (size_t)(p - look))
+ ? mb_strnicmp((char *)s, (char *)look, (size_t)(p - look))
: STRNCMP(s, look, p - look)) == 0) {
match = true;
}
@@ -3250,7 +3250,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
if ((curwin->w_cursor.col == (colnr_T)(p - look)
|| !vim_iswordc(line[-(p - look) - 1]))
&& (icase
- ? mb_strnicmp(line - (p - look), look, (size_t)(p - look))
+ ? mb_strnicmp((char *)line - (p - look), (char *)look, (size_t)(p - look))
: STRNCMP(line - (p - look), look, p - look)) == 0) {
match = true;
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 2ade64df3f..0b03cf3011 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -2292,7 +2292,7 @@ int eval0(char *arg, typval_T *rettv, char **nextcmd, int evaluate)
ret = FAIL;
}
if (nextcmd != NULL) {
- *nextcmd = (char *)check_nextcmd((char_u *)p);
+ *nextcmd = check_nextcmd(p);
}
return ret;
@@ -7639,7 +7639,7 @@ void ex_echo(exarg_T *eap)
tv_clear(&rettv);
arg = skipwhite(arg);
}
- eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
+ eap->nextcmd = check_nextcmd(arg);
if (eap->skip) {
emsg_skip--;
@@ -7736,7 +7736,7 @@ void ex_execute(exarg_T *eap)
emsg_skip--;
}
- eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
+ eap->nextcmd = check_nextcmd(arg);
}
/// Skip over the name of an option: "&option", "&g:option" or "&l:option".
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 6593a34f4a..5a5293780d 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -1065,7 +1065,7 @@ static void f_count(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
const size_t len = STRLEN(expr);
while (*p != NUL) {
- if (mb_strnicmp(p, expr, len) == 0) {
+ if (mb_strnicmp((char *)p, (char *)expr, len) == 0) {
n++;
p += len;
} else {
@@ -8687,7 +8687,7 @@ static void f_submatch(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (retList == 0) {
rettv->v_type = VAR_STRING;
- rettv->vval.v_string = (char *)reg_submatch(no);
+ rettv->vval.v_string = reg_submatch(no);
} else {
rettv->v_type = VAR_LIST;
rettv->vval.v_list = reg_submatch_list(no);
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 21bd662db5..bcaca0ca13 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -1942,7 +1942,7 @@ void ex_function(exarg_T *eap)
}
}
}
- eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
+ eap->nextcmd = check_nextcmd(eap->arg);
return;
}
@@ -1978,7 +1978,7 @@ void ex_function(exarg_T *eap)
if (*p == '/') {
p++;
}
- eap->nextcmd = (char *)check_nextcmd(p);
+ eap->nextcmd = check_nextcmd((char *)p);
return;
}
@@ -2032,7 +2032,7 @@ void ex_function(exarg_T *eap)
semsg(_(e_trailing_arg), p);
goto ret_free;
}
- eap->nextcmd = (char *)check_nextcmd(p);
+ eap->nextcmd = check_nextcmd((char *)p);
if (eap->nextcmd != NULL) {
*p = NUL;
}
@@ -2590,8 +2590,8 @@ int eval_fname_script(const char *const p)
// Use mb_strnicmp() because in Turkish comparing the "I" may not work with
// the standard library function.
if (p[0] == '<'
- && (mb_strnicmp((char_u *)p + 1, (char_u *)"SID>", 4) == 0
- || mb_strnicmp((char_u *)p + 1, (char_u *)"SNR>", 4) == 0)) {
+ && (mb_strnicmp(p + 1, "SID>", 4) == 0
+ || mb_strnicmp(p + 1, "SNR>", 4) == 0)) {
return 5;
}
if (p[0] == 's' && p[1] == ':') {
@@ -2700,7 +2700,7 @@ void ex_delfunction(exarg_T *eap)
semsg(_(e_trailing_arg), p);
return;
}
- eap->nextcmd = (char *)check_nextcmd(p);
+ eap->nextcmd = check_nextcmd((char *)p);
if (eap->nextcmd != NULL) {
*p = NUL;
}
@@ -2889,7 +2889,7 @@ void ex_return(exarg_T *eap)
if (returning) {
eap->nextcmd = NULL;
} else if (eap->nextcmd == NULL) { // no argument
- eap->nextcmd = (char *)check_nextcmd(arg);
+ eap->nextcmd = check_nextcmd((char *)arg);
}
if (eap->skip) {
@@ -3018,7 +3018,7 @@ void ex_call(exarg_T *eap)
semsg(_(e_trailing_arg), arg);
}
} else {
- eap->nextcmd = (char *)check_nextcmd(arg);
+ eap->nextcmd = check_nextcmd((char *)arg);
}
}
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index dbbb03b1b8..ba58254bdd 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -207,7 +207,7 @@ static void ex_let_const(exarg_T *eap, const bool is_const)
list_func_vars(&first);
list_vim_vars(&first);
}
- eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
+ eap->nextcmd = check_nextcmd(arg);
} else if (expr[0] == '=' && expr[1] == '<' && expr[2] == '<') {
// HERE document
list_T *l = heredoc_get(eap, expr + 3);
@@ -824,7 +824,7 @@ static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_ca
arg = skipwhite(name_end);
} while (!ends_excmd(*arg));
- eap->nextcmd = (char *)check_nextcmd((char_u *)arg);
+ eap->nextcmd = check_nextcmd(arg);
}
// TODO(ZyX-I): move to eval/ex_cmds
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 17d45f207e..d050562e4c 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -509,8 +509,8 @@ void ex_sort(exarg_T *eap)
} else if (*p == '"') {
// comment start
break;
- } else if (check_nextcmd((char_u *)p) != NULL) {
- eap->nextcmd = (char *)check_nextcmd((char_u *)p);
+ } else if (check_nextcmd(p) != NULL) {
+ eap->nextcmd = check_nextcmd(p);
break;
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
s = skip_regexp(p + 1, *p, true, NULL);
@@ -3625,7 +3625,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
*/
cmd = skipwhite(cmd);
if (*cmd && *cmd != '"') { // if not end-of-line or comment
- eap->nextcmd = (char *)check_nextcmd((char_u *)cmd);
+ eap->nextcmd = check_nextcmd(cmd);
if (eap->nextcmd == NULL) {
semsg(_(e_trailing_arg), cmd);
return 0;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 8f72ba0e23..01d141e557 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1929,7 +1929,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
// If we got a line, but no command, then go to the line.
// If we find a '|' or '\n' we set ea.nextcmd.
if (*ea.cmd == NUL || *ea.cmd == '"'
- || (ea.nextcmd = (char *)check_nextcmd((char_u *)ea.cmd)) != NULL) {
+ || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) {
// strange vi behaviour:
// ":3" jumps to line 3
// ":3|..." prints line 3
@@ -3934,7 +3934,7 @@ void separate_nextcmd(exarg_T *eap)
STRMOVE(p - 1, p); // remove the '\'
p--;
} else {
- eap->nextcmd = (char *)check_nextcmd((char_u *)p);
+ eap->nextcmd = check_nextcmd(p);
*p = NUL;
break;
}
@@ -4311,12 +4311,12 @@ char *find_nextcmd(const char *p)
/// Check if *p is a separator between Ex commands, skipping over white space.
///
/// @return NULL if it isn't, the following character if it is.
-char_u *check_nextcmd(char_u *p)
+char *check_nextcmd(char *p)
{
- char *s = skipwhite((char *)p);
+ char *s = skipwhite(p);
if (*s == '|' || *s == '\n') {
- return (char_u *)(s + 1);
+ return s + 1;
} else {
return NULL;
}
@@ -5674,7 +5674,7 @@ static void ex_wincmd(exarg_T *eap)
p = eap->arg + 1;
}
- eap->nextcmd = (char *)check_nextcmd((char_u *)p);
+ eap->nextcmd = check_nextcmd(p);
p = skipwhite(p);
if (*p != NUL && *p != '"' && eap->nextcmd == NULL) {
emsg(_(e_invarg));
@@ -6465,7 +6465,7 @@ static void ex_findpat(exarg_T *eap)
if (!ends_excmd(*p)) {
eap->errmsg = ex_errmsg(e_trailing_arg, p);
} else {
- eap->nextcmd = (char *)check_nextcmd((char_u *)p);
+ eap->nextcmd = check_nextcmd(p);
}
}
}
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index e8af99805d..9d1cebd43e 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -328,7 +328,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
int empty;
*end = NUL;
- empty = empty_pattern((char_u *)p);
+ empty = empty_pattern(p);
*end = c;
if (empty) {
goto theend;
@@ -489,7 +489,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat
if (!use_last_pat) {
next_char = ccline.cmdbuff[skiplen + patlen];
ccline.cmdbuff[skiplen + patlen] = NUL;
- if (empty_pattern(ccline.cmdbuff) && !no_hlsearch) {
+ if (empty_pattern((char *)ccline.cmdbuff) && !no_hlsearch) {
redraw_all_later(UPD_SOME_VALID);
set_no_hlsearch(true);
}
@@ -2027,7 +2027,7 @@ static int command_line_not_changed(CommandLineState *s)
/// Guess that the pattern matches everything. Only finds specific cases, such
/// as a trailing \|, which can happen while typing a pattern.
-static int empty_pattern(char_u *p)
+static int empty_pattern(char *p)
{
size_t n = STRLEN(p);
@@ -3952,8 +3952,9 @@ static int get_cmdline_type(void)
/// Get the current command line in allocated memory.
/// Only works when the command line is being edited.
-/// Returns NULL when something is wrong.
-static char_u *get_cmdline_str(void)
+///
+/// @return NULL when something is wrong.
+static char *get_cmdline_str(void)
{
if (cmdline_star > 0) {
return NULL;
@@ -3963,11 +3964,11 @@ static char_u *get_cmdline_str(void)
if (p == NULL) {
return NULL;
}
- return vim_strnsave(p->cmdbuff, (size_t)p->cmdlen);
+ return (char *)vim_strnsave(p->cmdbuff, (size_t)p->cmdlen);
}
/// Get the current command-line completion type.
-static char_u *get_cmdline_completion(void)
+static char *get_cmdline_completion(void)
{
if (cmdline_star > 0) {
return NULL;
@@ -3978,7 +3979,7 @@ static char_u *get_cmdline_completion(void)
set_expand_context(p->xpc);
char *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context);
if (cmd_compl != NULL) {
- return vim_strsave((char_u *)cmd_compl);
+ return xstrdup(cmd_compl);
}
}
@@ -3989,14 +3990,14 @@ static char_u *get_cmdline_completion(void)
void f_getcmdcompltype(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
rettv->v_type = VAR_STRING;
- rettv->vval.v_string = (char *)get_cmdline_completion();
+ rettv->vval.v_string = get_cmdline_completion();
}
/// "getcmdline()" function
void f_getcmdline(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
rettv->v_type = VAR_STRING;
- rettv->vval.v_string = (char *)get_cmdline_str();
+ rettv->vval.v_string = get_cmdline_str();
}
/// "getcmdpos()" function
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index d8c864df5b..0f085df3d0 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -111,7 +111,7 @@ static int prev_lnum_lvl = -1;
#define DONE_FOLD 2 // did find a fold
static size_t foldstartmarkerlen;
-static char_u *foldendmarker;
+static char *foldendmarker;
static size_t foldendmarkerlen;
// Exported folding functions. {{{1
@@ -982,7 +982,7 @@ void foldAdjustVisual(void)
}
pos_T *start, *end;
- char_u *ptr;
+ char *ptr;
if (ltoreq(VIsual, curwin->w_cursor)) {
start = &VIsual;
@@ -995,7 +995,7 @@ void foldAdjustVisual(void)
start->col = 0;
}
if (hasFolding(end->lnum, NULL, &end->lnum)) {
- ptr = (char_u *)ml_get(end->lnum);
+ ptr = ml_get(end->lnum);
end->col = (colnr_T)STRLEN(ptr);
if (end->col > 0 && *p_sel == 'o') {
end->col--;
@@ -1556,7 +1556,7 @@ static void foldCreateMarkers(win_T *wp, pos_T start, pos_T end)
}
parseMarker(wp);
- foldAddMarker(buf, start, (char_u *)wp->w_p_fmr, foldstartmarkerlen);
+ foldAddMarker(buf, start, wp->w_p_fmr, foldstartmarkerlen);
foldAddMarker(buf, end, foldendmarker, foldendmarkerlen);
// Update both changes here, to avoid all folds after the start are
@@ -1573,22 +1573,22 @@ static void foldCreateMarkers(win_T *wp, pos_T start, pos_T end)
// foldAddMarker() {{{2
/// Add "marker[markerlen]" in 'commentstring' to position `pos`.
-static void foldAddMarker(buf_T *buf, pos_T pos, const char_u *marker, size_t markerlen)
+static void foldAddMarker(buf_T *buf, pos_T pos, const char *marker, size_t markerlen)
{
- char_u *cms = (char_u *)buf->b_p_cms;
- char_u *newline;
- char_u *p = (char_u *)strstr(buf->b_p_cms, "%s");
+ char *cms = buf->b_p_cms;
+ char *newline;
+ char *p = strstr(buf->b_p_cms, "%s");
bool line_is_comment = false;
linenr_T lnum = pos.lnum;
// Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end
- char_u *line = ml_get_buf(buf, lnum, false);
+ char *line = (char *)ml_get_buf(buf, lnum, false);
size_t line_len = STRLEN(line);
size_t added = 0;
if (u_save(lnum - 1, lnum + 1) == OK) {
// Check if the line ends with an unclosed comment
- skip_comment((char *)line, false, false, &line_is_comment);
+ skip_comment(line, false, false, &line_is_comment);
newline = xmalloc(line_len + markerlen + STRLEN(cms) + 1);
STRCPY(newline, line);
// Append the marker to the end of the line
@@ -1601,7 +1601,7 @@ static void foldAddMarker(buf_T *buf, pos_T pos, const char_u *marker, size_t ma
STRCPY(newline + line_len + (p - cms) + markerlen, p + 2);
added = markerlen + STRLEN(cms) - 2;
}
- ml_replace_buf(buf, lnum, (char *)newline, false);
+ ml_replace_buf(buf, lnum, newline, false);
if (added) {
extmark_splice_cols(buf, (int)lnum - 1, (int)line_len,
0, (int)added, kExtmarkUndo);
@@ -1621,7 +1621,7 @@ static void deleteFoldMarkers(win_T *wp, fold_T *fp, int recursive, linenr_T lnu
lnum_off + fp->fd_top);
}
}
- foldDelMarker(wp->w_buffer, fp->fd_top + lnum_off, (char_u *)wp->w_p_fmr,
+ foldDelMarker(wp->w_buffer, fp->fd_top + lnum_off, wp->w_p_fmr,
foldstartmarkerlen);
foldDelMarker(wp->w_buffer, fp->fd_top + lnum_off + fp->fd_len - 1,
foldendmarker, foldendmarkerlen);
@@ -1632,16 +1632,16 @@ static void deleteFoldMarkers(win_T *wp, fold_T *fp, int recursive, linenr_T lnu
/// Delete 'commentstring' if it matches.
/// If the marker is not found, there is no error message. Could be a missing
/// close-marker.
-static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t markerlen)
+static void foldDelMarker(buf_T *buf, linenr_T lnum, char *marker, size_t markerlen)
{
// end marker may be missing and fold extends below the last line
if (lnum > buf->b_ml.ml_line_count) {
return;
}
- char_u *cms = (char_u *)buf->b_p_cms;
- char_u *line = ml_get_buf(buf, lnum, false);
- for (char_u *p = line; *p != NUL; p++) {
+ char *cms = buf->b_p_cms;
+ char *line = (char *)ml_get_buf(buf, lnum, false);
+ for (char *p = line; *p != NUL; p++) {
if (STRNCMP(p, marker, markerlen) != 0) {
continue;
}
@@ -1652,7 +1652,7 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t mark
}
if (*cms != NUL) {
// Also delete 'commentstring' if it matches.
- char_u *cms2 = (char_u *)strstr((char *)cms, "%s");
+ char *cms2 = strstr(cms, "%s");
if (p - line >= cms2 - cms
&& STRNCMP(p - (cms2 - cms), cms, cms2 - cms) == 0
&& STRNCMP(p + len, cms2 + 2, STRLEN(cms2 + 2)) == 0) {
@@ -1662,11 +1662,11 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t mark
}
if (u_save(lnum - 1, lnum + 1) == OK) {
// Make new line: text-before-marker + text-after-marker
- char_u *newline = xmalloc(STRLEN(line) - len + 1);
+ char *newline = xmalloc(STRLEN(line) - len + 1);
assert(p >= line);
memcpy(newline, line, (size_t)(p - line));
STRCPY(newline + (p - line), p + len);
- ml_replace_buf(buf, lnum, (char *)newline, false);
+ ml_replace_buf(buf, lnum, newline, false);
extmark_splice_cols(buf, (int)lnum - 1, (int)(p - line),
(int)len, 0, kExtmarkUndo);
}
@@ -1683,10 +1683,10 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t mark
/// @return the text for a closed fold
///
/// Otherwise the result is in allocated memory.
-char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldinfo, char_u *buf)
+char *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldinfo, char *buf)
FUNC_ATTR_NONNULL_ARG(1)
{
- char_u *text = NULL;
+ char *text = NULL;
// an error occurred when evaluating 'fdt' setting
static bool got_fdt_error = false;
int save_did_emsg = did_emsg;
@@ -1728,9 +1728,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
curbuf = wp->w_buffer;
emsg_silent++; // handle exceptions, but don't display errors
- text =
- (char_u *)eval_to_string_safe(wp->w_p_fdt, NULL,
- was_set_insecurely(wp, "foldtext", OPT_LOCAL));
+ text = eval_to_string_safe(wp->w_p_fdt, NULL, was_set_insecurely(wp, "foldtext", OPT_LOCAL));
emsg_silent--;
if (text == NULL || did_emsg) {
@@ -1751,23 +1749,23 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
if (text != NULL) {
// Replace unprintable characters, if there are any. But
// replace a TAB with a space.
- char_u *p;
+ char *p;
for (p = text; *p != NUL; p++) {
- int len = utfc_ptr2len((char *)p);
+ int len = utfc_ptr2len(p);
if (len > 1) {
- if (!vim_isprintc(utf_ptr2char((char *)p))) {
+ if (!vim_isprintc(utf_ptr2char(p))) {
break;
}
p += len - 1;
} else if (*p == TAB) {
*p = ' ';
- } else if (ptr2cells((char *)p) > 1) {
+ } else if (ptr2cells(p) > 1) {
break;
}
}
if (*p != NUL) {
- p = (char_u *)transstr((const char *)text, true);
+ p = transstr((const char *)text, true);
xfree(text);
text = p;
}
@@ -1776,7 +1774,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
if (text == NULL) {
unsigned long count = (unsigned long)(lnume - lnum + 1);
- vim_snprintf((char *)buf, FOLD_TEXT_LEN,
+ vim_snprintf(buf, FOLD_TEXT_LEN,
NGETTEXT("+--%3ld line folded",
"+--%3ld lines folded ", count),
count);
@@ -1787,17 +1785,17 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
// foldtext_cleanup() {{{2
/// Remove 'foldmarker' and 'commentstring' from "str" (in-place).
-static void foldtext_cleanup(char_u *str)
+static void foldtext_cleanup(char *str)
{
// Ignore leading and trailing white space in 'commentstring'.
- char_u *cms_start = (char_u *)skipwhite(curbuf->b_p_cms);
+ char *cms_start = skipwhite(curbuf->b_p_cms);
size_t cms_slen = STRLEN(cms_start);
while (cms_slen > 0 && ascii_iswhite(cms_start[cms_slen - 1])) {
cms_slen--;
}
// locate "%s" in 'commentstring', use the part before and after it.
- char_u *cms_end = (char_u *)strstr((char *)cms_start, "%s");
+ char *cms_end = strstr(cms_start, "%s");
size_t cms_elen = 0;
if (cms_end != NULL) {
cms_elen = cms_slen - (size_t)(cms_end - cms_start);
@@ -1809,7 +1807,7 @@ static void foldtext_cleanup(char_u *str)
}
// skip "%s" and white space after it
- char_u *s = (char_u *)skipwhite((char *)cms_end + 2);
+ char *s = skipwhite(cms_end + 2);
cms_elen -= (size_t)(s - cms_end);
cms_end = s;
}
@@ -1818,7 +1816,7 @@ static void foldtext_cleanup(char_u *str)
bool did1 = false;
bool did2 = false;
- for (char_u *s = str; *s != NUL;) {
+ for (char *s = str; *s != NUL;) {
size_t len = 0;
if (STRNCMP(s, curwin->w_p_fmr, foldstartmarkerlen) == 0) {
len = foldstartmarkerlen;
@@ -1832,7 +1830,7 @@ static void foldtext_cleanup(char_u *str)
// May remove 'commentstring' start. Useful when it's a double
// quote and we already removed a double quote.
- char_u *p;
+ char *p;
for (p = s; p > str && ascii_iswhite(p[-1]); p--) {}
if (p >= str + cms_slen
&& STRNCMP(p - cms_slen, cms_start, cms_slen) == 0) {
@@ -2850,7 +2848,7 @@ static void foldlevelIndent(fline_T *flp)
linenr_T lnum = flp->lnum + flp->off;
buf_T *buf = flp->wp->w_buffer;
- char_u *s = (char_u *)skipwhite((char *)ml_get_buf(buf, lnum, false));
+ char *s = skipwhite((char *)ml_get_buf(buf, lnum, false));
// empty line or lines starting with a character in 'foldignore': level
// depends on surrounding lines
@@ -2985,8 +2983,8 @@ static void foldlevelExpr(fline_T *flp)
/// Relies on the option value to have been checked for correctness already.
static void parseMarker(win_T *wp)
{
- foldendmarker = (char_u *)vim_strchr(wp->w_p_fmr, ',');
- foldstartmarkerlen = (size_t)(foldendmarker++ - (char_u *)wp->w_p_fmr);
+ foldendmarker = vim_strchr(wp->w_p_fmr, ',');
+ foldstartmarkerlen = (size_t)(foldendmarker++ - wp->w_p_fmr);
foldendmarkerlen = STRLEN(foldendmarker);
}
@@ -3003,23 +3001,23 @@ static void foldlevelMarker(fline_T *flp)
int start_lvl = flp->lvl;
// cache a few values for speed
- char_u *startmarker = (char_u *)flp->wp->w_p_fmr;
- int cstart = *startmarker;
+ char *startmarker = flp->wp->w_p_fmr;
+ int cstart = (unsigned char)(*startmarker);
startmarker++;
- int cend = *foldendmarker;
+ int cend = (unsigned char)(*foldendmarker);
// Default: no start found, next level is same as current level
flp->start = 0;
flp->lvl_next = flp->lvl;
- char_u *s = ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off, false);
+ char *s = (char *)ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off, false);
while (*s) {
if (*s == cstart
&& STRNCMP(s + 1, startmarker, foldstartmarkerlen - 1) == 0) {
// found startmarker: set flp->lvl
s += foldstartmarkerlen;
if (ascii_isdigit(*s)) {
- int n = atoi((char *)s);
+ int n = atoi(s);
if (n > 0) {
flp->lvl = n;
flp->lvl_next = n;
@@ -3039,7 +3037,7 @@ static void foldlevelMarker(fline_T *flp)
// found endmarker: set flp->lvl_next
s += foldendmarkerlen;
if (ascii_isdigit(*s)) {
- int n = atoi((char *)s);
+ int n = atoi(s);
if (n > 0) {
flp->lvl = n;
flp->lvl_next = n - 1;
@@ -3240,7 +3238,7 @@ void f_foldtext(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
linenr_T foldstart = (linenr_T)get_vim_var_nr(VV_FOLDSTART);
linenr_T foldend = (linenr_T)get_vim_var_nr(VV_FOLDEND);
- char_u *dashes = (char_u *)get_vim_var_str(VV_FOLDDASHES);
+ char *dashes = get_vim_var_str(VV_FOLDDASHES);
if (foldstart > 0 && foldend <= curbuf->b_ml.ml_line_count) {
// Find first non-empty line in the fold.
linenr_T lnum;
@@ -3268,20 +3266,20 @@ void f_foldtext(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
+ STRLEN(dashes) // for %s
+ 20 // for %3ld
+ STRLEN(s); // concatenated
- char_u *r = xmalloc(len);
- snprintf((char *)r, len, txt, dashes, count);
+ char *r = xmalloc(len);
+ snprintf(r, len, txt, dashes, count);
len = STRLEN(r);
STRCAT(r, s);
// remove 'foldmarker' and 'commentstring'
foldtext_cleanup(r + len);
- rettv->vval.v_string = (char *)r;
+ rettv->vval.v_string = r;
}
}
/// "foldtextresult(lnum)" function
void f_foldtextresult(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
- char_u buf[FOLD_TEXT_LEN];
+ char buf[FOLD_TEXT_LEN];
static bool entered = false;
rettv->v_type = VAR_STRING;
@@ -3298,11 +3296,11 @@ void f_foldtextresult(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
foldinfo_T info = fold_info(curwin, lnum);
if (info.fi_lines > 0) {
- char_u *text = get_foldtext(curwin, lnum, lnum + info.fi_lines - 1, info, buf);
+ char *text = get_foldtext(curwin, lnum, lnum + info.fi_lines - 1, info, buf);
if (text == buf) {
- text = vim_strsave(text);
+ text = xstrdup(text);
}
- rettv->vval.v_string = (char *)text;
+ rettv->vval.v_string = text;
}
entered = false;
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index f592b54f67..947594be4f 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1541,17 +1541,16 @@ ssize_t mb_utf_index_to_bytes(const char_u *s, size_t len, size_t index, bool us
return -1;
}
-/*
- * Version of strnicmp() that handles multi-byte characters.
- * Needed for Big5, Shift-JIS and UTF-8 encoding. Other DBCS encodings can
- * probably use strnicmp(), because there are no ASCII characters in the
- * second byte.
- * Returns zero if s1 and s2 are equal (ignoring case), the difference between
- * two characters otherwise.
- */
-int mb_strnicmp(const char_u *s1, const char_u *s2, const size_t nn)
+/// Version of strnicmp() that handles multi-byte characters.
+/// Needed for Big5, Shift-JIS and UTF-8 encoding. Other DBCS encodings can
+/// probably use strnicmp(), because there are no ASCII characters in the
+/// second byte.
+///
+/// @return zero if s1 and s2 are equal (ignoring case), the difference between
+/// two characters otherwise.
+int mb_strnicmp(const char *s1, const char *s2, const size_t nn)
{
- return utf_strnicmp(s1, s2, nn, nn);
+ return utf_strnicmp((char_u *)s1, (char_u *)s2, nn, nn);
}
/// Compare strings case-insensitively
@@ -1568,7 +1567,7 @@ int mb_strnicmp(const char_u *s1, const char_u *s2, const size_t nn)
/// @return 0 if strings are equal, <0 if s1 < s2, >0 if s1 > s2.
int mb_stricmp(const char *s1, const char *s2)
{
- return mb_strnicmp((const char_u *)s1, (const char_u *)s2, MAXCOL);
+ return mb_strnicmp(s1, s2, MAXCOL);
}
/*
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 5bbcbc7144..8973d4dfdb 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -384,7 +384,7 @@ int path_fnamencmp(const char *const fname1, const char *const fname2, size_t le
return p_fic ? CH_FOLD(c1) - CH_FOLD(c2) : c1 - c2;
#else
if (p_fic) {
- return mb_strnicmp((const char_u *)fname1, (const char_u *)fname2, len);
+ return mb_strnicmp(fname1, fname2, len);
}
return strncmp(fname1, fname2, len);
#endif
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index f471f1c8e0..563d85964c 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -1282,7 +1282,7 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
len = (int)STRLEN(p + ccol);
}
- if (cstrncmp(p + ccol, rex.input, &len) != 0) {
+ if (cstrncmp((char *)p + ccol, (char *)rex.input, &len) != 0) {
return RA_NOMATCH; // doesn't match
}
if (bytelen != NULL) {
@@ -1395,10 +1395,10 @@ static void mb_decompose(int c, int *c1, int *c2, int *c3)
}
}
-// Compare two strings, ignore case if rex.reg_ic set.
-// Return 0 if strings match, non-zero otherwise.
-// Correct the length "*n" when composing characters are ignored.
-static int cstrncmp(char_u *s1, char_u *s2, int *n)
+/// Compare two strings, ignore case if rex.reg_ic set.
+/// Return 0 if strings match, non-zero otherwise.
+/// Correct the length "*n" when composing characters are ignored.
+static int cstrncmp(char *s1, char *s2, int *n)
{
int result;
@@ -1406,12 +1406,12 @@ static int cstrncmp(char_u *s1, char_u *s2, int *n)
result = STRNCMP(s1, s2, *n);
} else {
assert(*n >= 0);
- result = mb_strnicmp(s1, s2, (size_t)*n);
+ result = mb_strnicmp(s1, s2, (size_t)(*n));
}
// if it failed and it's utf8 and we want to combineignore:
if (result != 0 && rex.reg_icombine) {
- char_u *str1, *str2;
+ char *str1, *str2;
int c1, c2, c11, c12;
int junk;
@@ -2112,36 +2112,33 @@ exit:
return (int)((dst - dest) + 1);
}
-/*
- * Call reg_getline() with the line numbers from the submatch. If a
- * substitute() was used the reg_maxline and other values have been
- * overwritten.
- */
-static char_u *reg_getline_submatch(linenr_T lnum)
+/// Call reg_getline() with the line numbers from the submatch. If a
+/// substitute() was used the reg_maxline and other values have been
+/// overwritten.
+static char *reg_getline_submatch(linenr_T lnum)
{
- char_u *s;
+ char *s;
linenr_T save_first = rex.reg_firstlnum;
linenr_T save_max = rex.reg_maxline;
rex.reg_firstlnum = rsm.sm_firstlnum;
rex.reg_maxline = rsm.sm_maxline;
- s = reg_getline(lnum);
+ s = (char *)reg_getline(lnum);
rex.reg_firstlnum = save_first;
rex.reg_maxline = save_max;
return s;
}
-/*
- * Used for the submatch() function: get the string from the n'th submatch in
- * allocated memory.
- * Returns NULL when not in a ":s" command and for a non-existing submatch.
- */
-char_u *reg_submatch(int no)
+/// Used for the submatch() function: get the string from the n'th submatch in
+/// allocated memory.
+///
+/// @return NULL when not in a ":s" command and for a non-existing submatch.
+char *reg_submatch(int no)
{
- char_u *retval = NULL;
- char_u *s;
+ char *retval = NULL;
+ char *s;
int round;
linenr_T lnum;
@@ -2211,11 +2208,11 @@ char_u *reg_submatch(int no)
}
}
} else {
- s = rsm.sm_match->startp[no];
+ s = (char *)rsm.sm_match->startp[no];
if (s == NULL || rsm.sm_match->endp[no] == NULL) {
retval = NULL;
} else {
- retval = vim_strnsave(s, (size_t)(rsm.sm_match->endp[no] - s));
+ retval = xstrnsave(s, (size_t)(rsm.sm_match->endp[no] - (char_u *)s));
}
}
@@ -2250,16 +2247,16 @@ list_T *reg_submatch_list(int no)
list = tv_list_alloc(elnum - slnum + 1);
- s = (const char *)reg_getline_submatch(slnum) + scol;
+ s = reg_getline_submatch(slnum) + scol;
if (slnum == elnum) {
tv_list_append_string(list, s, ecol - scol);
} else {
tv_list_append_string(list, s, -1);
for (int i = 1; i < elnum - slnum; i++) {
- s = (const char *)reg_getline_submatch(slnum + i);
+ s = reg_getline_submatch(slnum + i);
tv_list_append_string(list, s, -1);
}
- s = (const char *)reg_getline_submatch(elnum);
+ s = reg_getline_submatch(elnum);
tv_list_append_string(list, s, ecol);
}
} else {
diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c
index b951df69d6..9b9b33b09f 100644
--- a/src/nvim/regexp_bt.c
+++ b/src/nvim/regexp_bt.c
@@ -4039,7 +4039,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
} else {
// Need to match first byte again for multi-byte.
len = (int)STRLEN(opnd);
- if (cstrncmp(opnd, rex.input, &len) != 0) {
+ if (cstrncmp((char *)opnd, (char *)rex.input, &len) != 0) {
status = RA_NOMATCH;
}
}
@@ -4270,7 +4270,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
} else {
// Compare current input with back-ref in the same line.
len = (int)(rex.reg_endp[no] - rex.reg_startp[no]);
- if (cstrncmp(rex.reg_startp[no], rex.input, &len) != 0) {
+ if (cstrncmp((char *)rex.reg_startp[no], (char *)rex.input, &len) != 0) {
status = RA_NOMATCH;
}
}
@@ -4283,8 +4283,8 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
&& rex.reg_endpos[no].lnum == rex.lnum) {
// Compare back-ref within the current line.
len = rex.reg_endpos[no].col - rex.reg_startpos[no].col;
- if (cstrncmp(rex.line + rex.reg_startpos[no].col,
- rex.input, &len) != 0) {
+ if (cstrncmp((char *)rex.line + rex.reg_startpos[no].col,
+ (char *)rex.input, &len) != 0) {
status = RA_NOMATCH;
}
} else {
@@ -4320,7 +4320,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
if (re_extmatch_in != NULL
&& re_extmatch_in->matches[no] != NULL) {
int len = (int)STRLEN(re_extmatch_in->matches[no]);
- if (cstrncmp(re_extmatch_in->matches[no], rex.input, &len) != 0) {
+ if (cstrncmp((char *)re_extmatch_in->matches[no], (char *)rex.input, &len) != 0) {
status = RA_NOMATCH;
} else {
rex.input += len;
@@ -5069,14 +5069,14 @@ static long bt_regexec_both(char_u *line, colnr_T col, proftime_T *tm, int *time
// the loop to avoid overhead of conditions.
if (!rex.reg_ic) {
while ((s = (char_u *)vim_strchr((char *)s, c)) != NULL) {
- if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
+ if (cstrncmp((char *)s, (char *)prog->regmust, &prog->regmlen) == 0) {
break; // Found it.
}
MB_PTR_ADV(s);
}
} else {
while ((s = cstrchr(s, c)) != NULL) {
- if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
+ if (cstrncmp((char *)s, (char *)prog->regmust, &prog->regmlen) == 0) {
break; // Found it.
}
MB_PTR_ADV(s);
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index e1327ce155..d01404b5c2 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -5421,8 +5421,8 @@ retempty:
&& sub->list.multi[subidx].end_lnum == rex.lnum) {
len = sub->list.multi[subidx].end_col
- sub->list.multi[subidx].start_col;
- if (cstrncmp(rex.line + sub->list.multi[subidx].start_col,
- rex.input, &len) == 0) {
+ if (cstrncmp((char *)rex.line + sub->list.multi[subidx].start_col,
+ (char *)rex.input, &len) == 0) {
*bytelen = len;
return true;
}
@@ -5441,7 +5441,7 @@ retempty:
goto retempty;
}
len = (int)(sub->list.line[subidx].end - sub->list.line[subidx].start);
- if (cstrncmp(sub->list.line[subidx].start, rex.input, &len) == 0) {
+ if (cstrncmp((char *)sub->list.line[subidx].start, (char *)rex.input, &len) == 0) {
*bytelen = len;
return true;
}
@@ -5466,7 +5466,7 @@ static int match_zref(int subidx, int *bytelen)
}
len = (int)STRLEN(re_extmatch_in->matches[subidx]);
- if (cstrncmp(re_extmatch_in->matches[subidx], rex.input, &len) == 0) {
+ if (cstrncmp((char *)re_extmatch_in->matches[subidx], (char *)rex.input, &len) == 0) {
*bytelen = len;
return true;
}
diff --git a/src/nvim/search.c b/src/nvim/search.c
index d7f8d4e1cd..226d949825 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -1504,7 +1504,7 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char_u *pat)
} else if (*p != NUL) { // Ignore empty lines.
// Expanding lines or words.
assert(ins_compl_len() >= 0);
- if ((p_ic ? mb_strnicmp(p, pat, (size_t)ins_compl_len())
+ if ((p_ic ? mb_strnicmp((char *)p, (char *)pat, (size_t)ins_compl_len())
: STRNCMP(p, pat, ins_compl_len())) == 0) {
return OK;
}
@@ -3792,7 +3792,7 @@ search_line:
// compare the first "len" chars from "ptr"
startp = (char_u *)skipwhite((char *)p);
if (p_ic) {
- matched = !mb_strnicmp(startp, ptr, len);
+ matched = !mb_strnicmp((char *)startp, (char *)ptr, len);
} else {
matched = !STRNCMP(startp, ptr, len);
}
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index d2f1b39ca4..e20bce5b34 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -4001,7 +4001,7 @@ static bool shada_removable(const char *name)
if (part[0] == 'r') {
home_replace(NULL, part + 1, (char *)NameBuff, MAXPATHL, true);
size_t n = STRLEN(NameBuff);
- if (mb_strnicmp((char_u *)NameBuff, (char_u *)new_name, n) == 0) {
+ if (mb_strnicmp(NameBuff, new_name, n) == 0) {
retval = true;
break;
}
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index ed7f53d3ba..7d931a853b 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -26,11 +26,11 @@
typedef struct sign sign_T;
struct sign {
- sign_T *sn_next; // next sign in list
+ sign_T *sn_next; // next sign in list
int sn_typenr; // type number of sign
- char_u *sn_name; // name of sign
- char_u *sn_icon; // name of pixmap
- char_u *sn_text; // text used instead of pixmap
+ char *sn_name; // name of sign
+ char *sn_icon; // name of pixmap
+ char *sn_text; // text used instead of pixmap
int sn_line_hl; // highlight ID for line
int sn_text_hl; // highlight ID for text
int sn_cul_hl; // highlight ID for text on current line when 'cursorline' is set
@@ -71,14 +71,13 @@ void init_signs(void)
/// A new sign in group 'groupname' is added. If the group is not present,
/// create it. Otherwise reference the group.
-///
-static signgroup_T *sign_group_ref(const char_u *groupname)
+static signgroup_T *sign_group_ref(const char *groupname)
{
hash_T hash;
hashitem_T *hi;
signgroup_T *group;
- hash = hash_hash(groupname);
+ hash = hash_hash((char_u *)groupname);
hi = hash_lookup(&sg_table, (char *)groupname, STRLEN(groupname), hash);
if (HASHITEM_EMPTY(hi)) {
// new group
@@ -99,11 +98,11 @@ static signgroup_T *sign_group_ref(const char_u *groupname)
/// A sign in group 'groupname' is removed. If all the signs in this group are
/// removed, then remove the group.
-static void sign_group_unref(char_u *groupname)
+static void sign_group_unref(char *groupname)
{
signgroup_T *group;
- hashitem_T *hi = hash_find(&sg_table, (char *)groupname);
+ hashitem_T *hi = hash_find(&sg_table, groupname);
if (!HASHITEM_EMPTY(hi)) {
group = HI2SG(hi);
group->sg_refcount--;
@@ -118,7 +117,7 @@ static void sign_group_unref(char_u *groupname)
/// @return true if 'sign' is in 'group'.
/// A sign can either be in the global group (sign->group == NULL)
/// or in a named group. If 'group' is '*', then the sign is part of the group.
-static bool sign_in_group(sign_entry_T *sign, const char_u *group)
+static bool sign_in_group(sign_entry_T *sign, const char *group)
{
return ((group != NULL && STRCMP(group, "*") == 0)
|| (group == NULL && sign->se_group == NULL)
@@ -127,7 +126,7 @@ static bool sign_in_group(sign_entry_T *sign, const char_u *group)
}
/// Get the next free sign identifier in the specified group
-static int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
+static int sign_group_get_next_signid(buf_T *buf, const char *groupname)
{
int id = 1;
signgroup_T *group = NULL;
@@ -154,7 +153,7 @@ static int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
// Check whether this sign is already placed in the buffer
found = true;
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
- if (id == sign->se_id && sign_in_group(sign, groupname)) {
+ if (id == sign->se_id && sign_in_group(sign, (char *)groupname)) {
found = false; // sign identifier is in use
break;
}
@@ -177,7 +176,7 @@ static int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
/// @param typenr typenr of sign we are adding
/// @param has_text_or_icon sign has text or icon
static void insert_sign(buf_T *buf, sign_entry_T *prev, sign_entry_T *next, int id,
- const char_u *group, int prio, linenr_T lnum, int typenr,
+ const char *group, int prio, linenr_T lnum, int typenr,
bool has_text_or_icon)
{
sign_entry_T *newsign = xmalloc(sizeof(sign_entry_T));
@@ -224,7 +223,7 @@ static void insert_sign(buf_T *buf, sign_entry_T *prev, sign_entry_T *next, int
/// @param lnum line number which gets the mark
/// @param typenr typenr of sign we are adding
/// @param has_text_or_icon sign has text or icon
-static void insert_sign_by_lnum_prio(buf_T *buf, sign_entry_T *prev, int id, const char_u *group,
+static void insert_sign_by_lnum_prio(buf_T *buf, sign_entry_T *prev, int id, const char *group,
int prio, linenr_T lnum, int typenr, bool has_text_or_icon)
{
sign_entry_T *sign;
@@ -259,7 +258,7 @@ static sign_T *find_sign_by_typenr(int typenr)
}
/// Get the name of a sign by its typenr.
-static char_u *sign_typenr2name(int typenr)
+static char *sign_typenr2name(int typenr)
{
sign_T *sp;
@@ -268,7 +267,7 @@ static char_u *sign_typenr2name(int typenr)
return sp->sn_name;
}
}
- return (char_u *)_("[Deleted]");
+ return _("[Deleted]");
}
/// Return information about a sign in a Dict
@@ -280,7 +279,7 @@ static dict_T *sign_get_info(sign_entry_T *sign)
? (char *)""
: (char *)sign->se_group->sg_name));
tv_dict_add_nr(d, S_LEN("lnum"), sign->se_lnum);
- tv_dict_add_str(d, S_LEN("name"), (char *)sign_typenr2name(sign->se_typenr));
+ tv_dict_add_str(d, S_LEN("name"), sign_typenr2name(sign->se_typenr));
tv_dict_add_nr(d, S_LEN("priority"), sign->se_priority);
return d;
@@ -369,7 +368,7 @@ static void sign_sort_by_prio_on_line(buf_T *buf, sign_entry_T *sign)
/// @param lnum line number which gets the mark
/// @param typenr typenr of sign we are adding
/// @param has_text_or_icon sign has text or icon
-static void buf_addsign(buf_T *buf, int id, const char_u *groupname, int prio, linenr_T lnum,
+static void buf_addsign(buf_T *buf, int id, const char *groupname, int prio, linenr_T lnum,
int typenr, bool has_text_or_icon)
{
sign_entry_T *sign; // a sign in the signlist
@@ -416,13 +415,13 @@ static void buf_addsign(buf_T *buf, int id, const char_u *groupname, int prio, l
/// @param group sign group
/// @param typenr typenr of sign we are adding
/// @param prio sign priority
-static linenr_T buf_change_sign_type(buf_T *buf, int markId, const char_u *group, int typenr,
+static linenr_T buf_change_sign_type(buf_T *buf, int markId, const char *group, int typenr,
int prio)
{
sign_entry_T *sign; // a sign in the signlist
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
- if (sign->se_id == markId && sign_in_group(sign, group)) {
+ if (sign->se_id == markId && sign_in_group(sign, (char *)group)) {
sign->se_typenr = typenr;
sign->se_priority = prio;
sign_sort_by_prio_on_line(buf, sign);
@@ -534,7 +533,7 @@ int buf_get_signattrs(buf_T *buf, linenr_T lnum, SignTextAttrs sattrs[], HlPriAt
///
/// @return the line number of the deleted sign. If multiple signs are deleted,
/// then returns the line number of the last sign deleted.
-static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char_u *group)
+static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char *group)
{
sign_entry_T **lastp; // pointer to pointer to current sign
sign_entry_T *sign; // a sign in a b_signlist
@@ -555,7 +554,7 @@ static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char_u *group)
lnum = sign->se_lnum;
buf_signcols_del_check(buf, lnum, lnum);
if (sign->se_group != NULL) {
- sign_group_unref(sign->se_group->sg_name);
+ sign_group_unref((char *)sign->se_group->sg_name);
}
xfree(sign);
redraw_buf_line_later(buf, lnum);
@@ -590,7 +589,7 @@ static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char_u *group)
/// @param buf buffer to store sign in
/// @param id sign ID
/// @param group sign group
-static int buf_findsign(buf_T *buf, int id, char_u *group)
+static int buf_findsign(buf_T *buf, int id, char *group)
{
sign_entry_T *sign; // a sign in the signlist
@@ -609,7 +608,7 @@ static int buf_findsign(buf_T *buf, int id, char_u *group)
/// @param buf buffer whose sign we are searching for
/// @param lnum line number of sign
/// @param groupname sign group name
-static sign_entry_T *buf_getsign_at_line(buf_T *buf, linenr_T lnum, char_u *groupname)
+static sign_entry_T *buf_getsign_at_line(buf_T *buf, linenr_T lnum, char *groupname)
{
sign_entry_T *sign; // a sign in the signlist
@@ -633,7 +632,7 @@ static sign_entry_T *buf_getsign_at_line(buf_T *buf, linenr_T lnum, char_u *grou
/// @param buf buffer whose sign we are searching for
/// @param lnum line number of sign
/// @param groupname sign group name
-static int buf_findsign_id(buf_T *buf, linenr_T lnum, char_u *groupname)
+static int buf_findsign_id(buf_T *buf, linenr_T lnum, char *groupname)
{
sign_entry_T *sign; // a sign in the signlist
@@ -661,13 +660,13 @@ void buf_delete_signs(buf_T *buf, char *group)
lastp = &buf->b_signlist;
for (sign = buf->b_signlist; sign != NULL; sign = next) {
next = sign->se_next;
- if (sign_in_group(sign, (char_u *)group)) {
+ if (sign_in_group(sign, group)) {
*lastp = next;
if (next != NULL) {
next->se_prev = sign->se_prev;
}
if (sign->se_group != NULL) {
- sign_group_unref(sign->se_group->sg_name);
+ sign_group_unref((char *)sign->se_group->sg_name);
}
xfree(sign);
} else {
@@ -678,7 +677,7 @@ void buf_delete_signs(buf_T *buf, char *group)
}
/// List placed signs for "rbuf". If "rbuf" is NULL do it for all buffers.
-static void sign_list_placed(buf_T *rbuf, char_u *sign_group)
+static void sign_list_placed(buf_T *rbuf, char *sign_group)
{
buf_T *buf;
sign_entry_T *sign;
@@ -778,12 +777,12 @@ void sign_mark_adjust(linenr_T line1, linenr_T line2, linenr_T amount, linenr_T
///
/// @param begin_cmd begin of sign subcmd
/// @param end_cmd just after sign subcmd
-static int sign_cmd_idx(char_u *begin_cmd, char_u *end_cmd)
+static int sign_cmd_idx(char *begin_cmd, char *end_cmd)
{
int idx;
- char_u save = *end_cmd;
+ char save = *end_cmd;
- *end_cmd = (char_u)NUL;
+ *end_cmd = NUL;
for (idx = 0;; idx++) {
if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0) {
break;
@@ -794,7 +793,7 @@ static int sign_cmd_idx(char_u *begin_cmd, char_u *end_cmd)
}
/// Find a sign by name. Also returns pointer to the previous sign.
-static sign_T *sign_find(const char_u *name, sign_T **sp_prev)
+static sign_T *sign_find(const char *name, sign_T **sp_prev)
{
sign_T *sp;
@@ -814,7 +813,7 @@ static sign_T *sign_find(const char_u *name, sign_T **sp_prev)
}
/// Allocate a new sign
-static sign_T *alloc_new_sign(char_u *name)
+static sign_T *alloc_new_sign(char *name)
{
sign_T *sp;
sign_T *lp;
@@ -848,24 +847,24 @@ static sign_T *alloc_new_sign(char_u *name)
next_sign_typenr = 1; // wrap around
}
- sp->sn_name = vim_strsave(name);
+ sp->sn_name = xstrdup(name);
return sp;
}
/// Initialize the icon information for a new sign
-static void sign_define_init_icon(sign_T *sp, char_u *icon)
+static void sign_define_init_icon(sign_T *sp, char *icon)
{
xfree(sp->sn_icon);
- sp->sn_icon = vim_strsave(icon);
- backslash_halve((char *)sp->sn_icon);
+ sp->sn_icon = xstrdup(icon);
+ backslash_halve(sp->sn_icon);
}
/// Initialize the text for a new sign
-static int sign_define_init_text(sign_T *sp, char_u *text)
+static int sign_define_init_text(sign_T *sp, char *text)
{
- char_u *s;
- char_u *endp;
+ char *s;
+ char *endp;
int cells;
size_t len;
@@ -880,11 +879,11 @@ static int sign_define_init_text(sign_T *sp, char_u *text)
}
// Count cells and check for non-printable chars
cells = 0;
- for (s = text; s < endp; s += utfc_ptr2len((char *)s)) {
- if (!vim_isprintc(utf_ptr2char((char *)s))) {
+ for (s = text; s < endp; s += utfc_ptr2len(s)) {
+ if (!vim_isprintc(utf_ptr2char(s))) {
break;
}
- cells += utf_ptr2cells((char *)s);
+ cells += utf_ptr2cells(s);
}
// Currently must be empty, one or two display cells
if (s != endp || cells > 2) {
@@ -900,7 +899,7 @@ static int sign_define_init_text(sign_T *sp, char_u *text)
// Allocate one byte more if we need to pad up
// with a space.
len = (size_t)(endp - text + ((cells == 1) ? 1 : 0));
- sp->sn_text = vim_strnsave(text, len);
+ sp->sn_text = xstrnsave(text, len);
if (cells == 1) {
STRCPY(sp->sn_text + len - 1, " ");
@@ -910,8 +909,8 @@ static int sign_define_init_text(sign_T *sp, char_u *text)
}
/// Define a new sign or update an existing sign
-static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text,
- char_u *texthl, char_u *culhl, char *numhl)
+static int sign_define_by_name(char *name, char *icon, char *linehl, char *text, char *texthl,
+ char *culhl, char *numhl)
{
sign_T *sp_prev;
sign_T *sp;
@@ -952,7 +951,7 @@ static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_
if (*linehl == NUL) {
sp->sn_line_hl = 0;
} else {
- sp->sn_line_hl = syn_check_group((char *)linehl, STRLEN(linehl));
+ sp->sn_line_hl = syn_check_group(linehl, STRLEN(linehl));
}
}
@@ -960,7 +959,7 @@ static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_
if (*texthl == NUL) {
sp->sn_text_hl = 0;
} else {
- sp->sn_text_hl = syn_check_group((char *)texthl, STRLEN(texthl));
+ sp->sn_text_hl = syn_check_group(texthl, STRLEN(texthl));
}
}
@@ -968,7 +967,7 @@ static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_
if (*culhl == NUL) {
sp->sn_cul_hl = 0;
} else {
- sp->sn_cul_hl = syn_check_group((char *)culhl, STRLEN(culhl));
+ sp->sn_cul_hl = syn_check_group(culhl, STRLEN(culhl));
}
}
@@ -984,7 +983,7 @@ static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_
}
/// Free the sign specified by 'name'.
-static int sign_undefine_by_name(const char_u *name)
+static int sign_undefine_by_name(const char *name)
{
sign_T *sp_prev;
sign_T *sp;
@@ -1000,7 +999,7 @@ static int sign_undefine_by_name(const char_u *name)
}
/// List the signs matching 'name'
-static void sign_list_by_name(char_u *name)
+static void sign_list_by_name(char *name)
{
sign_T *sp;
@@ -1024,7 +1023,7 @@ static void may_force_numberwidth_recompute(buf_T *buf, int unplace)
}
/// Place a sign at the specified file location or update a sign.
-static int sign_place(int *sign_id, const char_u *sign_group, const char_u *sign_name, buf_T *buf,
+static int sign_place(int *sign_id, const char *sign_group, const char *sign_name, buf_T *buf,
linenr_T lnum, int prio)
{
sign_T *sp;
@@ -1044,7 +1043,7 @@ static int sign_place(int *sign_id, const char_u *sign_group, const char_u *sign
return FAIL;
}
if (*sign_id == 0) {
- *sign_id = sign_group_get_next_signid(buf, sign_group);
+ *sign_id = sign_group_get_next_signid(buf, (char *)sign_group);
}
if (lnum > 0) {
@@ -1053,14 +1052,14 @@ static int sign_place(int *sign_id, const char_u *sign_group, const char_u *sign
bool has_text_or_icon = sp->sn_text != NULL || sp->sn_icon != NULL;
buf_addsign(buf,
*sign_id,
- sign_group,
+ (char *)sign_group,
prio,
lnum,
sp->sn_typenr,
has_text_or_icon);
} else {
// ":sign place {id} file={fname}": change sign type and/or priority
- lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr, prio);
+ lnum = buf_change_sign_type(buf, *sign_id, (char *)sign_group, sp->sn_typenr, prio);
}
if (lnum > 0) {
redraw_buf_line_later(buf, lnum);
@@ -1077,7 +1076,7 @@ static int sign_place(int *sign_id, const char_u *sign_group, const char_u *sign
}
/// Unplace the specified sign
-static int sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T atlnum)
+static int sign_unplace(int sign_id, char *sign_group, buf_T *buf, linenr_T atlnum)
{
if (buf->b_signlist == NULL) { // No signs in the buffer
return OK;
@@ -1085,7 +1084,7 @@ static int sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T at
if (sign_id == 0) {
// Delete all the signs in the specified buffer
redraw_buf_later(buf, UPD_NOT_VALID);
- buf_delete_signs(buf, (char *)sign_group);
+ buf_delete_signs(buf, sign_group);
} else {
linenr_T lnum;
@@ -1108,7 +1107,7 @@ static int sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T at
}
/// Unplace the sign at the current cursor line.
-static void sign_unplace_at_cursor(char_u *groupname)
+static void sign_unplace_at_cursor(char *groupname)
{
int id = -1;
@@ -1121,7 +1120,7 @@ static void sign_unplace_at_cursor(char_u *groupname)
}
/// Jump to a sign.
-static linenr_T sign_jump(int sign_id, char_u *sign_group, buf_T *buf)
+static linenr_T sign_jump(int sign_id, char *sign_group, buf_T *buf)
{
linenr_T lnum;
@@ -1154,49 +1153,49 @@ static linenr_T sign_jump(int sign_id, char_u *sign_group, buf_T *buf)
}
/// ":sign define {name} ..." command
-static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
-{
- char_u *arg;
- char_u *p = cmdline;
- char_u *icon = NULL;
- char_u *text = NULL;
- char_u *linehl = NULL;
- char_u *texthl = NULL;
- char_u *culhl = NULL;
- char_u *numhl = NULL;
+static void sign_define_cmd(char *sign_name, char *cmdline)
+{
+ char *arg;
+ char *p = cmdline;
+ char *icon = NULL;
+ char *text = NULL;
+ char *linehl = NULL;
+ char *texthl = NULL;
+ char *culhl = NULL;
+ char *numhl = NULL;
int failed = false;
// set values for a defined sign.
for (;;) {
- arg = (char_u *)skipwhite((char *)p);
+ arg = skipwhite(p);
if (*arg == NUL) {
break;
}
- p = (char_u *)skiptowhite_esc((char *)arg);
+ p = skiptowhite_esc(arg);
if (STRNCMP(arg, "icon=", 5) == 0) {
arg += 5;
XFREE_CLEAR(icon);
- icon = vim_strnsave(arg, (size_t)(p - arg));
+ icon = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "text=", 5) == 0) {
arg += 5;
XFREE_CLEAR(text);
- text = vim_strnsave(arg, (size_t)(p - arg));
+ text = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "linehl=", 7) == 0) {
arg += 7;
XFREE_CLEAR(linehl);
- linehl = vim_strnsave(arg, (size_t)(p - arg));
+ linehl = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "texthl=", 7) == 0) {
arg += 7;
XFREE_CLEAR(texthl);
- texthl = vim_strnsave(arg, (size_t)(p - arg));
+ texthl = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "culhl=", 6) == 0) {
arg += 6;
XFREE_CLEAR(culhl);
- culhl = vim_strnsave(arg, (size_t)(p - arg));
+ culhl = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "numhl=", 6) == 0) {
arg += 6;
XFREE_CLEAR(numhl);
- numhl = vim_strnsave(arg, (size_t)(p - arg));
+ numhl = xstrnsave(arg, (size_t)(p - arg));
} else {
semsg(_(e_invarg2), arg);
failed = true;
@@ -1205,7 +1204,8 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
}
if (!failed) {
- sign_define_by_name(sign_name, icon, linehl, text, texthl, culhl, (char *)numhl);
+ sign_define_by_name(sign_name, icon, linehl, text,
+ texthl, culhl, numhl);
}
xfree(icon);
@@ -1217,7 +1217,7 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
}
/// ":sign place" command
-static void sign_place_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id, char_u *group,
+static void sign_place_cmd(buf_T *buf, linenr_T lnum, char *sign_name, int id, char *group,
int prio)
{
if (id <= 0) {
@@ -1250,7 +1250,7 @@ static void sign_place_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id,
}
/// ":sign unplace" command
-static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id, char_u *group)
+static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char *sign_name, int id, char *group)
{
if (lnum >= 0 || sign_name != NULL || (group != NULL && *group == '\0')) {
emsg(_(e_invarg));
@@ -1272,7 +1272,7 @@ static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int i
// :sign unplace * group=*
FOR_ALL_BUFFERS(cbuf) {
if (cbuf->b_signlist != NULL) {
- buf_delete_signs(cbuf, (char *)group);
+ buf_delete_signs(cbuf, group);
}
}
}
@@ -1307,7 +1307,7 @@ static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int i
/// :sign jump {id} buffer={nr}
/// :sign jump {id} group={group} file={fname}
/// :sign jump {id} group={group} buffer={nr}
-static void sign_jump_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id, char_u *group)
+static void sign_jump_cmd(buf_T *buf, linenr_T lnum, char *sign_name, int id, char *group)
{
if (sign_name == NULL && group == NULL && id == -1) {
emsg(_(e_argreq));
@@ -1329,31 +1329,31 @@ static void sign_jump_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id,
/// ":sign jump" commands.
/// The supported arguments are: line={lnum} name={name} group={group}
/// priority={prio} and file={fname} or buffer={nr}.
-static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *signid,
- char_u **group, int *prio, buf_T **buf, linenr_T *lnum)
+static int parse_sign_cmd_args(int cmd, char *arg, char **sign_name, int *signid, char **group,
+ int *prio, buf_T **buf, linenr_T *lnum)
{
- char_u *arg1;
- char_u *name;
- char_u *filename = NULL;
+ char *arg1;
+ char *name;
+ char *filename = NULL;
int lnum_arg = false;
// first arg could be placed sign id
arg1 = arg;
if (ascii_isdigit(*arg)) {
- *signid = getdigits_int((char **)&arg, true, 0);
+ *signid = getdigits_int(&arg, true, 0);
if (!ascii_iswhite(*arg) && *arg != NUL) {
*signid = -1;
arg = arg1;
} else {
- arg = (char_u *)skipwhite((char *)arg);
+ arg = skipwhite(arg);
}
}
while (*arg != NUL) {
if (STRNCMP(arg, "line=", 5) == 0) {
arg += 5;
- *lnum = atoi((char *)arg);
- arg = (char_u *)skiptowhite((char *)arg);
+ *lnum = atoi(arg);
+ arg = skiptowhite(arg);
lnum_arg = true;
} else if (STRNCMP(arg, "*", 1) == 0 && cmd == SIGNCMD_UNPLACE) {
if (*signid != -1) {
@@ -1361,11 +1361,11 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
return FAIL;
}
*signid = -2;
- arg = (char_u *)skiptowhite((char *)arg + 1);
+ arg = skiptowhite(arg + 1);
} else if (STRNCMP(arg, "name=", 5) == 0) {
arg += 5;
name = arg;
- arg = (char_u *)skiptowhite((char *)arg);
+ arg = skiptowhite(arg);
if (*arg != NUL) {
*arg++ = NUL;
}
@@ -1376,24 +1376,24 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
} else if (STRNCMP(arg, "group=", 6) == 0) {
arg += 6;
*group = arg;
- arg = (char_u *)skiptowhite((char *)arg);
+ arg = skiptowhite(arg);
if (*arg != NUL) {
*arg++ = NUL;
}
} else if (STRNCMP(arg, "priority=", 9) == 0) {
arg += 9;
- *prio = atoi((char *)arg);
- arg = (char_u *)skiptowhite((char *)arg);
+ *prio = atoi(arg);
+ arg = skiptowhite(arg);
} else if (STRNCMP(arg, "file=", 5) == 0) {
arg += 5;
filename = arg;
- *buf = buflist_findname_exp((char *)arg);
+ *buf = buflist_findname_exp(arg);
break;
} else if (STRNCMP(arg, "buffer=", 7) == 0) {
arg += 7;
filename = arg;
- *buf = buflist_findnr(getdigits_int((char **)&arg, true, 0));
- if (*skipwhite((char *)arg) != NUL) {
+ *buf = buflist_findnr(getdigits_int(&arg, true, 0));
+ if (*skipwhite(arg) != NUL) {
semsg(_(e_trailing_arg), arg);
}
break;
@@ -1401,7 +1401,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
emsg(_(e_invarg));
return FAIL;
}
- arg = (char_u *)skipwhite((char *)arg);
+ arg = skipwhite(arg);
}
if (filename != NULL && *buf == NULL) {
@@ -1421,19 +1421,19 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
/// ":sign" command
void ex_sign(exarg_T *eap)
{
- char_u *arg = (char_u *)eap->arg;
- char_u *p;
+ char *arg = eap->arg;
+ char *p;
int idx;
sign_T *sp;
// Parse the subcommand.
- p = (char_u *)skiptowhite((char *)arg);
+ p = skiptowhite(arg);
idx = sign_cmd_idx(arg, p);
if (idx == SIGNCMD_LAST) {
semsg(_("E160: Unknown sign command: %s"), arg);
return;
}
- arg = (char_u *)skipwhite((char *)p);
+ arg = skipwhite(p);
if (idx <= SIGNCMD_LIST) {
// Define, undefine or list signs.
@@ -1445,18 +1445,18 @@ void ex_sign(exarg_T *eap)
} else if (*arg == NUL) {
emsg(_("E156: Missing sign name"));
} else {
- char_u *name;
+ char *name;
// Isolate the sign name. If it's a number skip leading zeroes,
// so that "099" and "99" are the same sign. But keep "0".
- p = (char_u *)skiptowhite((char *)arg);
+ p = skiptowhite(arg);
if (*p != NUL) {
*p++ = NUL;
}
while (arg[0] == '0' && arg[1] != NUL) {
arg++;
}
- name = vim_strsave(arg);
+ name = xstrdup(arg);
if (idx == SIGNCMD_DEFINE) {
sign_define_cmd(name, p);
@@ -1474,8 +1474,8 @@ void ex_sign(exarg_T *eap)
} else {
int id = -1;
linenr_T lnum = -1;
- char_u *sign_name = NULL;
- char_u *group = NULL;
+ char *sign_name = NULL;
+ char *group = NULL;
int prio = SIGN_DEF_PRIO;
buf_T *buf = NULL;
@@ -1500,12 +1500,12 @@ static void sign_getinfo(sign_T *sp, dict_T *retdict)
{
const char *p;
- tv_dict_add_str(retdict, S_LEN("name"), (char *)sp->sn_name);
+ tv_dict_add_str(retdict, S_LEN("name"), sp->sn_name);
if (sp->sn_icon != NULL) {
- tv_dict_add_str(retdict, S_LEN("icon"), (char *)sp->sn_icon);
+ tv_dict_add_str(retdict, S_LEN("icon"), sp->sn_icon);
}
if (sp->sn_text != NULL) {
- tv_dict_add_str(retdict, S_LEN("text"), (char *)sp->sn_text);
+ tv_dict_add_str(retdict, S_LEN("text"), sp->sn_text);
}
if (sp->sn_line_hl > 0) {
p = get_highlight_name_ext(NULL, sp->sn_line_hl - 1, false);
@@ -1539,13 +1539,13 @@ static void sign_getinfo(sign_T *sp, dict_T *retdict)
/// If 'name' is NULL, return a list of all the defined signs.
/// Otherwise, return information about the specified sign.
-static void sign_getlist(const char_u *name, list_T *retlist)
+static void sign_getlist(const char *name, list_T *retlist)
{
sign_T *sp = first_sign;
dict_T *dict;
if (name != NULL) {
- sp = sign_find(name, NULL);
+ sp = sign_find((char *)name, NULL);
if (sp == NULL) {
return;
}
@@ -1577,8 +1577,8 @@ list_T *get_buffer_signs(buf_T *buf)
return l;
}
-/// Return information about all the signs placed in a buffer
-static void sign_get_placed_in_buf(buf_T *buf, linenr_T lnum, int sign_id, const char_u *sign_group,
+/// @return information about all the signs placed in a buffer
+static void sign_get_placed_in_buf(buf_T *buf, linenr_T lnum, int sign_id, const char *sign_group,
list_T *retlist)
{
dict_T *d;
@@ -1594,7 +1594,7 @@ static void sign_get_placed_in_buf(buf_T *buf, linenr_T lnum, int sign_id, const
tv_dict_add_list(d, S_LEN("signs"), l);
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
- if (!sign_in_group(sign, sign_group)) {
+ if (!sign_in_group(sign, (char *)sign_group)) {
continue;
}
if ((lnum == 0 && sign_id == 0)
@@ -1609,7 +1609,7 @@ static void sign_get_placed_in_buf(buf_T *buf, linenr_T lnum, int sign_id, const
/// Get a list of signs placed in buffer 'buf'. If 'num' is non-zero, return the
/// sign placed at the line number. If 'lnum' is zero, return all the signs
/// placed in 'buf'. If 'buf' is NULL, return signs placed in all the buffers.
-static void sign_get_placed(buf_T *buf, linenr_T lnum, int sign_id, const char_u *sign_group,
+static void sign_get_placed(buf_T *buf, linenr_T lnum, int sign_id, const char *sign_group,
list_T *retlist)
{
if (buf != NULL) {
@@ -1629,12 +1629,12 @@ static void sign_list_defined(sign_T *sp)
smsg("sign %s", sp->sn_name);
if (sp->sn_icon != NULL) {
msg_puts(" icon=");
- msg_outtrans((char *)sp->sn_icon);
+ msg_outtrans(sp->sn_icon);
msg_puts(_(" (not supported)"));
}
if (sp->sn_text != NULL) {
msg_puts(" text=");
- msg_outtrans((char *)sp->sn_text);
+ msg_outtrans(sp->sn_text);
}
if (sp->sn_line_hl > 0) {
msg_puts(" linehl=");
@@ -1710,8 +1710,8 @@ static enum {
EXP_SIGN_GROUPS, // expand with name of placed sign groups
} expand_what;
-// Return the n'th sign name (used for command line completion)
-static char_u *get_nth_sign_name(int idx)
+/// @return the n'th sign name (used for command line completion)
+static char *get_nth_sign_name(int idx)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
// Complete with name of signs already defined
@@ -1724,8 +1724,8 @@ static char_u *get_nth_sign_name(int idx)
return NULL;
}
-// Return the n'th sign group name (used for command line completion)
-static char_u *get_nth_sign_group_name(int idx)
+/// @return the n'th sign group name (used for command line completion)
+static char *get_nth_sign_group_name(int idx)
{
// Complete with name of sign groups already defined
int current_idx = 0;
@@ -1735,7 +1735,7 @@ static char_u *get_nth_sign_group_name(int idx)
todo--;
if (current_idx++ == idx) {
signgroup_T *const group = HI2SG(hi);
- return group->sg_name;
+ return (char *)group->sg_name;
}
}
}
@@ -1768,28 +1768,28 @@ char *get_sign_name(expand_T *xp, int idx)
return unplace_arg[idx];
}
case EXP_SIGN_NAMES:
- return (char *)get_nth_sign_name(idx);
+ return get_nth_sign_name(idx);
case EXP_SIGN_GROUPS:
- return (char *)get_nth_sign_group_name(idx);
+ return get_nth_sign_group_name(idx);
default:
return NULL;
}
}
/// Handle command line completion for :sign command.
-void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
+void set_context_in_sign_cmd(expand_T *xp, char *arg)
{
- char_u *end_subcmd;
- char_u *last;
+ char *end_subcmd;
+ char *last;
int cmd_idx;
- char_u *begin_subcmd_args;
+ char *begin_subcmd_args;
// Default: expand subcommands.
xp->xp_context = EXPAND_SIGN;
expand_what = EXP_SUBCMD;
- xp->xp_pattern = (char *)arg;
+ xp->xp_pattern = arg;
- end_subcmd = (char_u *)skiptowhite((char *)arg);
+ end_subcmd = skiptowhite(arg);
if (*end_subcmd == NUL) {
// expand subcmd name
// :sign {subcmd}<CTRL-D>
@@ -1801,7 +1801,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
// :sign {subcmd} {subcmd_args}
// |
// begin_subcmd_args
- begin_subcmd_args = (char_u *)skipwhite((char *)end_subcmd);
+ begin_subcmd_args = skipwhite(end_subcmd);
// Expand last argument of subcmd.
//
@@ -1810,21 +1810,21 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
// p
// Loop until reaching last argument.
- char_u *p = begin_subcmd_args;
+ char *p = begin_subcmd_args;
do {
- p = (char_u *)skipwhite((char *)p);
+ p = skipwhite(p);
last = p;
- p = (char_u *)skiptowhite((char *)p);
+ p = skiptowhite(p);
} while (*p != NUL);
- p = (char_u *)vim_strchr((char *)last, '=');
+ p = vim_strchr(last, '=');
// :sign define {name} {args}... {last}=
// | |
// last p
if (p == NULL) {
// Expand last argument name (before equal sign).
- xp->xp_pattern = (char *)last;
+ xp->xp_pattern = last;
switch (cmd_idx) {
case SIGNCMD_DEFINE:
expand_what = EXP_DEFINE;
@@ -1854,7 +1854,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
}
} else {
// Expand last argument value (after equal sign).
- xp->xp_pattern = (char *)p + 1;
+ xp->xp_pattern = p + 1;
switch (cmd_idx) {
case SIGNCMD_DEFINE:
if (STRNCMP(last, "texthl", 6) == 0
@@ -1928,8 +1928,8 @@ static int sign_define_from_dict(const char *name_arg, dict_T *dict)
numhl = tv_dict_get_string(dict, "numhl", true);
}
- if (sign_define_by_name((char_u *)name, (char_u *)icon, (char_u *)linehl,
- (char_u *)text, (char_u *)texthl, (char_u *)culhl, numhl)
+ if (sign_define_by_name(name, icon, linehl,
+ text, texthl, culhl, numhl)
== OK) {
retval = 0;
}
@@ -2005,7 +2005,7 @@ void f_sign_getdefined(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
name = tv_get_string(&argvars[0]);
}
- sign_getlist((const char_u *)name, rettv->vval.v_list);
+ sign_getlist(name, rettv->vval.v_list);
}
/// "sign_getplaced()" function
@@ -2062,8 +2062,7 @@ void f_sign_getplaced(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
}
- sign_get_placed(buf, lnum, sign_id, (const char_u *)group,
- rettv->vval.v_list);
+ sign_get_placed(buf, lnum, sign_id, group, rettv->vval.v_list);
}
/// "sign_jump()" function
@@ -2103,7 +2102,7 @@ void f_sign_jump(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
goto cleanup;
}
- rettv->vval.v_number = sign_jump(sign_id, (char_u *)sign_group, buf);
+ rettv->vval.v_number = sign_jump(sign_id, sign_group, buf);
cleanup:
xfree(sign_group);
@@ -2115,8 +2114,8 @@ static int sign_place_from_dict(typval_T *id_tv, typval_T *group_tv, typval_T *n
typval_T *buf_tv, dict_T *dict)
{
int sign_id = 0;
- char_u *group = NULL;
- char_u *sign_name = NULL;
+ char *group = NULL;
+ char *sign_name = NULL;
buf_T *buf = NULL;
dictitem_T *di;
linenr_T lnum = 0;
@@ -2154,14 +2153,14 @@ static int sign_place_from_dict(typval_T *id_tv, typval_T *group_tv, typval_T *n
if (group_tv == NULL) {
group = NULL; // global group
} else {
- group = (char_u *)tv_get_string_chk(group_tv);
+ group = (char *)tv_get_string_chk(group_tv);
if (group == NULL) {
goto cleanup;
}
if (group[0] == '\0') { // global sign group
group = NULL;
} else {
- group = vim_strsave(group);
+ group = xstrdup(group);
}
}
@@ -2175,7 +2174,7 @@ static int sign_place_from_dict(typval_T *id_tv, typval_T *group_tv, typval_T *n
if (name_tv == NULL) {
goto cleanup;
}
- sign_name = (char_u *)tv_get_string_chk(name_tv);
+ sign_name = (char *)tv_get_string_chk(name_tv);
if (sign_name == NULL) {
goto cleanup;
}
@@ -2269,13 +2268,13 @@ void f_sign_placelist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
/// Undefine multiple signs
static void sign_undefine_multiple(list_T *l, list_T *retlist)
{
- char_u *name;
+ char *name;
int retval;
TV_LIST_ITER_CONST(l, li, {
retval = -1;
- name = (char_u *)tv_get_string_chk(TV_LIST_ITEM_TV(li));
- if (name != NULL && (sign_undefine_by_name(name) == OK)) {
+ name = (char *)tv_get_string_chk(TV_LIST_ITEM_TV(li));
+ if (name != NULL && (sign_undefine_by_name((char *)name) == OK)) {
retval = 0;
}
tv_list_append_number(retlist, retval);
@@ -2308,7 +2307,7 @@ void f_sign_undefine(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
return;
}
- if (sign_undefine_by_name((const char_u *)name) == OK) {
+ if (sign_undefine_by_name(name) == OK) {
rettv->vval.v_number = 0;
}
}
@@ -2321,20 +2320,20 @@ static int sign_unplace_from_dict(typval_T *group_tv, dict_T *dict)
dictitem_T *di;
int sign_id = 0;
buf_T *buf = NULL;
- char_u *group = NULL;
+ char *group = NULL;
int retval = -1;
// sign group
if (group_tv != NULL) {
- group = (char_u *)tv_get_string(group_tv);
+ group = (char *)tv_get_string(group_tv);
} else {
- group = (char_u *)tv_dict_get_string(dict, "group", false);
+ group = tv_dict_get_string(dict, "group", false);
}
if (group != NULL) {
if (group[0] == '\0') { // global sign group
group = NULL;
} else {
- group = vim_strsave(group);
+ group = xstrdup(group);
}
}
diff --git a/src/nvim/sign_defs.h b/src/nvim/sign_defs.h
index a4fb325ec8..1efde30008 100644
--- a/src/nvim/sign_defs.h
+++ b/src/nvim/sign_defs.h
@@ -34,7 +34,7 @@ struct sign_entry {
/// Sign attributes. Used by the screen refresh routines.
typedef struct {
- char_u *text;
+ char *text;
int hl_attr_id;
int priority;
} SignTextAttrs;
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index d8bc4b22c2..7c05c9fe53 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -3289,7 +3289,7 @@ void spell_dump_compl(char_u *pat, int ic, Direction *dir, int dumpflags_arg)
// ignore case...
assert(depth >= 0);
if (depth <= patlen
- && mb_strnicmp(word, pat, (size_t)depth) != 0) {
+ && mb_strnicmp((char *)word, (char *)pat, (size_t)depth) != 0) {
depth--;
}
}
@@ -3371,7 +3371,7 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, Direction *dir,
ml_append(lnum, (char *)p, (colnr_T)0, false);
} else if (((dumpflags & DUMPFLAG_ICASE)
- ? mb_strnicmp(p, pat, STRLEN(pat)) == 0
+ ? mb_strnicmp((char *)p, (char *)pat, STRLEN(pat)) == 0
: STRNCMP(p, pat, STRLEN(pat)) == 0)
&& ins_compl_add_infercase(p, (int)STRLEN(p),
p_ic, NULL, *dir, false) == OK) {
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 1319894226..d8de23182c 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -797,7 +797,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid)
validate_current_state();
}
-static void save_chartab(char_u *chartab)
+static void save_chartab(char *chartab)
{
if (syn_block->b_syn_isk != empty_option) {
memmove(chartab, syn_buf->b_chartab, (size_t)32);
@@ -805,7 +805,7 @@ static void save_chartab(char_u *chartab)
}
}
-static void restore_chartab(char_u *chartab)
+static void restore_chartab(char *chartab)
{
if (syn_win->w_s->b_syn_isk != empty_option) {
memmove(syn_buf->b_chartab, chartab, (size_t)32);
@@ -819,7 +819,7 @@ static int syn_match_linecont(linenr_T lnum)
regmmatch_T regmatch;
// chartab array for syn iskeyword
char_u buf_chartab[32];
- save_chartab(buf_chartab);
+ save_chartab((char *)buf_chartab);
regmatch.rmm_ic = syn_block->b_syn_linecont_ic;
regmatch.regprog = syn_block->b_syn_linecont_prog;
@@ -827,7 +827,7 @@ static int syn_match_linecont(linenr_T lnum)
IF_SYN_TIME(&syn_block->b_syn_linecont_time));
syn_block->b_syn_linecont_prog = regmatch.regprog;
- restore_chartab(buf_chartab);
+ restore_chartab((char *)buf_chartab);
return r;
}
return false;
@@ -1677,7 +1677,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
ga_init(&zero_width_next_ga, (int)sizeof(int), 10);
// use syntax iskeyword option
- save_chartab(buf_chartab);
+ save_chartab((char *)buf_chartab);
/*
* Repeat matching keywords and patterns, to find contained items at the
@@ -1713,7 +1713,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
&& (current_col == 0
|| !vim_iswordp_buf(cur_pos - 1 - utf_head_off((char *)line, (char *)cur_pos - 1),
syn_buf))) {
- syn_id = check_keyword_id(line, (int)current_col, &endcol, &flags,
+ syn_id = check_keyword_id((char *)line, (int)current_col, &endcol, &flags,
&next_list, cur_si, &cchar);
if (syn_id != 0) {
push_current_state(KEYWORD_IDX);
@@ -2004,7 +2004,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
}
} while (found_match);
- restore_chartab(buf_chartab);
+ restore_chartab((char *)buf_chartab);
/*
* Use attributes from the current state, if within its highlighting.
@@ -2596,7 +2596,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_
best_regmatch.startpos[0].col = 0; // avoid compiler warning
// use syntax iskeyword option
- save_chartab(buf_chartab);
+ save_chartab((char *)buf_chartab);
for (;;) {
/*
@@ -2747,7 +2747,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_
m_endpos->lnum = 0;
}
- restore_chartab(buf_chartab);
+ restore_chartab((char *)buf_chartab);
// Remove external matches.
unref_extmatch(re_extmatch_in);
@@ -2932,17 +2932,17 @@ static int syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T
/// @param next_listp return: next_list of matching keyword
/// @param cur_si item at the top of the stack
/// @param ccharp conceal substitution char
-static int check_keyword_id(char_u *const line, const int startcol, int *const endcolp,
+static int check_keyword_id(char *const line, const int startcol, int *const endcolp,
long *const flagsp, int16_t **const next_listp,
stateitem_T *const cur_si, int *const ccharp)
{
// Find first character after the keyword. First character was already
// checked.
- char_u *const kwp = line + startcol;
+ char *const kwp = line + startcol;
int kwlen = 0;
do {
- kwlen += utfc_ptr2len((char *)kwp + kwlen);
- } while (vim_iswordp_buf(kwp + kwlen, syn_buf));
+ kwlen += utfc_ptr2len(kwp + kwlen);
+ } while (vim_iswordp_buf((char_u *)kwp + kwlen, syn_buf));
if (kwlen > MAXKEYWLEN) {
return 0;
@@ -2957,13 +2957,13 @@ static int check_keyword_id(char_u *const line, const int startcol, int *const e
// matching case
if (syn_block->b_keywtab.ht_used != 0) {
- kp = match_keyword(keyword, &syn_block->b_keywtab, cur_si);
+ kp = match_keyword((char *)keyword, &syn_block->b_keywtab, cur_si);
}
// ignoring case
if (kp == NULL && syn_block->b_keywtab_ic.ht_used != 0) {
- str_foldcase(kwp, kwlen, keyword, MAXKEYWLEN + 1);
- kp = match_keyword(keyword, &syn_block->b_keywtab_ic, cur_si);
+ str_foldcase((char_u *)kwp, kwlen, keyword, MAXKEYWLEN + 1);
+ kp = match_keyword((char *)keyword, &syn_block->b_keywtab_ic, cur_si);
}
if (kp != NULL) {
@@ -2982,9 +2982,9 @@ static int check_keyword_id(char_u *const line, const int startcol, int *const e
/// When current_next_list is non-zero accept only that group, otherwise:
/// Accept a not-contained keyword at toplevel.
/// Accept a keyword at other levels only if it is in the contains list.
-static keyentry_T *match_keyword(char_u *keyword, hashtab_T *ht, stateitem_T *cur_si)
+static keyentry_T *match_keyword(char *keyword, hashtab_T *ht, stateitem_T *cur_si)
{
- hashitem_T *hi = hash_find(ht, (char *)keyword);
+ hashitem_T *hi = hash_find(ht, keyword);
if (!HASHITEM_EMPTY(hi)) {
for (keyentry_T *kp = HI2KE(hi); kp != NULL; kp = kp->ke_next) {
if (current_next_list != 0
@@ -3029,20 +3029,18 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing)
}
}
-/*
- * Handle ":syntax case" command.
- */
+/// Handle ":syntax case" command.
static void syn_cmd_case(exarg_T *eap, int syncing)
{
- char_u *arg = (char_u *)eap->arg;
- char_u *next;
+ char *arg = eap->arg;
+ char *next;
- eap->nextcmd = find_nextcmd((char *)arg);
+ eap->nextcmd = find_nextcmd(arg);
if (eap->skip) {
return;
}
- next = (char_u *)skiptowhite((char *)arg);
+ next = skiptowhite(arg);
if (*arg == NUL) {
if (curwin->w_s->b_syn_ic) {
msg("syntax case ignore");
@@ -3097,20 +3095,18 @@ static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
}
}
-/*
- * Handle ":syntax spell" command.
- */
+/// Handle ":syntax spell" command.
static void syn_cmd_spell(exarg_T *eap, int syncing)
{
- char_u *arg = (char_u *)eap->arg;
- char_u *next;
+ char *arg = eap->arg;
+ char *next;
- eap->nextcmd = find_nextcmd((char *)arg);
+ eap->nextcmd = find_nextcmd(arg);
if (eap->skip) {
return;
}
- next = (char_u *)skiptowhite((char *)arg);
+ next = skiptowhite(arg);
if (*arg == NUL) {
if (curwin->w_s->b_syn_spell == SYNSPL_TOP) {
msg("syntax spell toplevel");
@@ -3137,15 +3133,15 @@ static void syn_cmd_spell(exarg_T *eap, int syncing)
/// Handle ":syntax iskeyword" command.
static void syn_cmd_iskeyword(exarg_T *eap, int syncing)
{
- char_u *arg = (char_u *)eap->arg;
- char_u save_chartab[32];
- char_u *save_isk;
+ char *arg = eap->arg;
+ char save_chartab[32];
+ char *save_isk;
if (eap->skip) {
return;
}
- arg = (char_u *)skipwhite((char *)arg);
+ arg = skipwhite(arg);
if (*arg == NUL) {
msg_puts("\n");
if (curwin->w_s->b_syn_isk != empty_option) {
@@ -3160,15 +3156,15 @@ static void syn_cmd_iskeyword(exarg_T *eap, int syncing)
clear_string_option(&curwin->w_s->b_syn_isk);
} else {
memmove(save_chartab, curbuf->b_chartab, (size_t)32);
- save_isk = (char_u *)curbuf->b_p_isk;
- curbuf->b_p_isk = (char *)vim_strsave(arg);
+ save_isk = curbuf->b_p_isk;
+ curbuf->b_p_isk = xstrdup(arg);
buf_init_chartab(curbuf, false);
memmove(curwin->w_s->b_syn_chartab, curbuf->b_chartab, (size_t)32);
memmove(curbuf->b_chartab, save_chartab, (size_t)32);
clear_string_option(&curwin->w_s->b_syn_isk);
curwin->w_s->b_syn_isk = curbuf->b_p_isk;
- curbuf->b_p_isk = (char *)save_isk;
+ curbuf->b_p_isk = save_isk;
}
}
redraw_later(curwin, UPD_NOT_VALID);
@@ -3303,16 +3299,14 @@ static void syn_clear_cluster(synblock_T *block, int i)
xfree(SYN_CLSTR(block)[i].scl_list);
}
-/*
- * Handle ":syntax clear" command.
- */
+/// Handle ":syntax clear" command.
static void syn_cmd_clear(exarg_T *eap, int syncing)
{
- char_u *arg = (char_u *)eap->arg;
- char_u *arg_end;
+ char *arg = eap->arg;
+ char *arg_end;
int id;
- eap->nextcmd = find_nextcmd((char *)arg);
+ eap->nextcmd = find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -3345,7 +3339,7 @@ static void syn_cmd_clear(exarg_T *eap, int syncing)
* Clear the group IDs that are in the argument.
*/
while (!ends_excmd(*arg)) {
- arg_end = (char_u *)skiptowhite((char *)arg);
+ arg_end = skiptowhite(arg);
if (*arg == '@') {
id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
if (id == 0) {
@@ -3360,7 +3354,7 @@ static void syn_cmd_clear(exarg_T *eap, int syncing)
XFREE_CLEAR(SYN_CLSTR(curwin->w_s)[scl_id].scl_list);
}
} else {
- id = syn_name2id_len((char *)arg, (size_t)(arg_end - arg));
+ id = syn_name2id_len(arg, (size_t)(arg_end - arg));
if (id == 0) {
semsg(_(e_nogroup), arg);
break;
@@ -3368,7 +3362,7 @@ static void syn_cmd_clear(exarg_T *eap, int syncing)
syn_clear_one(id, syncing);
}
}
- arg = (char_u *)skipwhite((char *)arg_end);
+ arg = skipwhite(arg_end);
}
}
redraw_curbuf_later(UPD_SOME_VALID);
@@ -3412,7 +3406,7 @@ static void syn_cmd_on(exarg_T *eap, int syncing)
*/
static void syn_cmd_reset(exarg_T *eap, int syncing)
{
- eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
+ eap->nextcmd = check_nextcmd(eap->arg);
if (!eap->skip) {
init_highlight(true, true);
}
@@ -3437,7 +3431,7 @@ static void syn_cmd_off(exarg_T *eap, int syncing)
static void syn_cmd_onoff(exarg_T *eap, char *name)
FUNC_ATTR_NONNULL_ALL
{
- eap->nextcmd = (char *)check_nextcmd((char_u *)eap->arg);
+ eap->nextcmd = check_nextcmd(eap->arg);
if (!eap->skip) {
did_syntax_onoff = true;
char buf[100];
@@ -3524,7 +3518,7 @@ static void syn_cmd_list(exarg_T *eap, int syncing)
while (!ends_excmd(*arg) && !got_int) {
arg_end = (char_u *)skiptowhite((char *)arg);
if (*arg == '@') {
- int id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
+ int id = syn_scl_namen2id((char *)arg + 1, (int)(arg_end - arg - 1));
if (id == 0) {
semsg(_("E392: No such syntax cluster: %s"), arg);
} else {
@@ -3541,7 +3535,7 @@ static void syn_cmd_list(exarg_T *eap, int syncing)
arg = (char_u *)skipwhite((char *)arg_end);
}
}
- eap->nextcmd = (char *)check_nextcmd(arg);
+ eap->nextcmd = check_nextcmd((char *)arg);
}
static void syn_lines_msg(void)
@@ -3977,13 +3971,14 @@ static void clear_keywtab(hashtab_T *ht)
/// @param flags flags for this keyword
/// @param cont_in_list containedin for this keyword
/// @param next_list nextgroup for this keyword
-static void add_keyword(char_u *const name, const int id, const int flags,
+static void add_keyword(char *const name, const int id, const int flags,
int16_t *const cont_in_list, int16_t *const next_list,
const int conceal_char)
{
- char_u name_folded[MAXKEYWLEN + 1];
- const char_u *const name_ic = (curwin->w_s->b_syn_ic)
- ? str_foldcase(name, (int)STRLEN(name), name_folded, sizeof(name_folded))
+ char name_folded[MAXKEYWLEN + 1];
+ const char *const name_ic = (curwin->w_s->b_syn_ic)
+ ? (char *)str_foldcase((char_u *)name, (int)STRLEN(name), (char_u *)name_folded,
+ sizeof(name_folded))
: name;
keyentry_T *const kp = xmalloc(sizeof(keyentry_T) + STRLEN(name_ic));
@@ -4249,7 +4244,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
emsg(_("E397: Filename required"));
return;
}
- sgl_id = syn_check_cluster((char_u *)arg, (int)(group_name_end - arg));
+ sgl_id = syn_check_cluster(arg, (int)(group_name_end - arg));
if (sgl_id == 0) {
return;
}
@@ -4364,7 +4359,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
if (p != NULL) {
*p = NUL;
}
- add_keyword((char_u *)kw, syn_id, syn_opt_arg.flags,
+ add_keyword(kw, syn_id, syn_opt_arg.flags,
syn_opt_arg.cont_in_list,
syn_opt_arg.next_list, conceal_char);
if (p == NULL) {
@@ -4399,7 +4394,7 @@ error:
}
if (rest != NULL) {
- eap->nextcmd = (char *)check_nextcmd((char_u *)rest);
+ eap->nextcmd = check_nextcmd(rest);
} else {
semsg(_(e_invarg2), arg);
}
@@ -4439,7 +4434,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
// get the pattern.
init_syn_patterns();
CLEAR_FIELD(item);
- rest = get_syn_pattern((char_u *)rest, &item);
+ rest = get_syn_pattern(rest, &item);
if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) {
syn_opt_arg.flags |= HL_HAS_EOL;
}
@@ -4451,7 +4446,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
/*
* Check for trailing command and illegal trailing arguments.
*/
- eap->nextcmd = (char *)check_nextcmd((char_u *)rest);
+ eap->nextcmd = check_nextcmd(rest);
if (!ends_excmd(*rest) || eap->skip) {
rest = NULL;
} else {
@@ -4631,7 +4626,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
assert(item == ITEM_SKIP || item == ITEM_END);
reg_do_extmatch = REX_USE;
}
- rest = get_syn_pattern((char_u *)rest, ppp->pp_synp);
+ rest = get_syn_pattern(rest, ppp->pp_synp);
reg_do_extmatch = 0;
if (item == ITEM_END && vim_regcomp_had_eol()
&& !(syn_opt_arg.flags & HL_EXCLUDENL)) {
@@ -4658,7 +4653,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
* Check for trailing garbage or command.
* If OK, add the item.
*/
- eap->nextcmd = (char *)check_nextcmd((char_u *)rest);
+ eap->nextcmd = check_nextcmd(rest);
if (!ends_excmd(*rest) || eap->skip) {
rest = NULL;
} else {
@@ -4863,12 +4858,12 @@ static void syn_combine_list(int16_t **const clstr1, int16_t **const clstr2, con
*clstr1 = clstr;
}
-// Lookup a syntax cluster name and return its ID.
-// If it is not found, 0 is returned.
-static int syn_scl_name2id(char_u *name)
+/// Lookup a syntax cluster name and return its ID.
+/// If it is not found, 0 is returned.
+static int syn_scl_name2id(char *name)
{
// Avoid using stricmp() too much, it's slow on some systems
- char_u *name_u = vim_strsave_up(name);
+ char *name_u = (char *)vim_strsave_up((char_u *)name);
int i;
for (i = curwin->w_s->b_syn_clusters.ga_len; --i >= 0;) {
if (SYN_CLSTR(curwin->w_s)[i].scl_name_u != NULL
@@ -4880,25 +4875,24 @@ static int syn_scl_name2id(char_u *name)
return i < 0 ? 0 : i + SYNID_CLUSTER;
}
-/*
- * Like syn_scl_name2id(), but take a pointer + length argument.
- */
-static int syn_scl_namen2id(char_u *linep, int len)
+/// Like syn_scl_name2id(), but take a pointer + length argument.
+static int syn_scl_namen2id(char *linep, int len)
{
- char_u *name = vim_strnsave(linep, (size_t)len);
+ char *name = xstrnsave(linep, (size_t)len);
int id = syn_scl_name2id(name);
xfree(name);
return id;
}
-// Find syntax cluster name in the table and return its ID.
-// The argument is a pointer to the name and the length of the name.
-// If it doesn't exist yet, a new entry is created.
-// Return 0 for failure.
-static int syn_check_cluster(char_u *pp, int len)
+/// Find syntax cluster name in the table and return its ID.
+/// The argument is a pointer to the name and the length of the name.
+/// If it doesn't exist yet, a new entry is created.
+///
+/// @return 0 for failure.
+static int syn_check_cluster(char *pp, int len)
{
- char_u *name = vim_strnsave(pp, (size_t)len);
+ char *name = xstrnsave(pp, (size_t)len);
int id = syn_scl_name2id(name);
if (id == 0) { // doesn't exist yet
id = syn_add_cluster(name);
@@ -4908,10 +4902,11 @@ static int syn_check_cluster(char_u *pp, int len)
return id;
}
-// Add new syntax cluster and return its ID.
-// "name" must be an allocated string, it will be consumed.
-// Return 0 for failure.
-static int syn_add_cluster(char_u *name)
+/// Add new syntax cluster and return its ID.
+/// "name" must be an allocated string, it will be consumed.
+///
+/// @return 0 for failure.
+static int syn_add_cluster(char *name)
{
/*
* First call for this growarray: init growing array.
@@ -4931,8 +4926,8 @@ static int syn_add_cluster(char_u *name)
syn_cluster_T *scp = GA_APPEND_VIA_PTR(syn_cluster_T,
&curwin->w_s->b_syn_clusters);
CLEAR_POINTER(scp);
- scp->scl_name = name;
- scp->scl_name_u = vim_strsave_up(name);
+ scp->scl_name = (char_u *)name;
+ scp->scl_name_u = vim_strsave_up((char_u *)name);
scp->scl_list = NULL;
if (STRICMP(name, "Spell") == 0) {
@@ -4966,7 +4961,7 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing)
rest = get_group_name(arg, &group_name_end);
if (rest != NULL) {
- int scl_id = syn_check_cluster((char_u *)arg, (int)(group_name_end - arg));
+ int scl_id = syn_check_cluster(arg, (int)(group_name_end - arg));
if (scl_id == 0) {
return;
}
@@ -5030,7 +5025,7 @@ static void init_syn_patterns(void)
/// Stores the pattern and program in a synpat_T.
///
/// @return a pointer to the next argument, or NULL in case of an error.
-static char *get_syn_pattern(char_u *arg, synpat_T *ci)
+static char *get_syn_pattern(char *arg, synpat_T *ci)
{
char *end;
int *p;
@@ -5042,13 +5037,13 @@ static char *get_syn_pattern(char_u *arg, synpat_T *ci)
return NULL;
}
- end = skip_regexp((char *)arg + 1, *arg, true, NULL);
- if (*end != (char)(*arg)) { // end delimiter not found
+ end = skip_regexp(arg + 1, *arg, true, NULL);
+ if (*end != *arg) { // end delimiter not found
semsg(_("E401: Pattern delimiter not found: %s"), arg);
return NULL;
}
// store the pattern and compiled regexp program
- ci->sp_pattern = vim_strnsave(arg + 1, (size_t)(end - (char *)arg) - 1);
+ ci->sp_pattern = vim_strnsave((char_u *)arg + 1, (size_t)(end - arg) - 1);
// Make 'cpoptions' empty, to avoid the 'l' flag
cpo_save = p_cpo;
@@ -5122,15 +5117,13 @@ static char *get_syn_pattern(char_u *arg, synpat_T *ci)
return skipwhite(end);
}
-/*
- * Handle ":syntax sync .." command.
- */
+/// Handle ":syntax sync .." command.
static void syn_cmd_sync(exarg_T *eap, int syncing)
{
- char_u *arg_start = (char_u *)eap->arg;
+ char *arg_start = eap->arg;
char *arg_end;
- char_u *key = NULL;
- char_u *next_arg;
+ char *key = NULL;
+ char *next_arg;
int illegal = false;
int finished = false;
char *cpo_save;
@@ -5141,21 +5134,21 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
}
while (!ends_excmd(*arg_start)) {
- arg_end = skiptowhite((char *)arg_start);
- next_arg = (char_u *)skipwhite(arg_end);
+ arg_end = skiptowhite(arg_start);
+ next_arg = skipwhite(arg_end);
xfree(key);
- key = vim_strnsave_up(arg_start, (size_t)(arg_end - (char *)arg_start));
+ key = (char *)vim_strnsave_up((char_u *)arg_start, (size_t)(arg_end - arg_start));
if (STRCMP(key, "CCOMMENT") == 0) {
if (!eap->skip) {
curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
}
if (!ends_excmd(*next_arg)) {
- arg_end = skiptowhite((char *)next_arg);
+ arg_end = skiptowhite(next_arg);
if (!eap->skip) {
curwin->w_s->b_syn_sync_id =
- (int16_t)syn_check_group((char *)next_arg, (size_t)(arg_end - (char *)next_arg));
+ (int16_t)syn_check_group(next_arg, (size_t)(arg_end - next_arg));
}
- next_arg = (char_u *)skipwhite(arg_end);
+ next_arg = skipwhite(arg_end);
} else if (!eap->skip) {
curwin->w_s->b_syn_sync_id = (int16_t)syn_name2id("Comment");
}
@@ -5164,11 +5157,11 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
|| STRNCMP(key, "MAXLINES", 8) == 0
|| STRNCMP(key, "LINEBREAKS", 10) == 0) {
if (key[4] == 'S') {
- arg_end = (char *)key + 6;
+ arg_end = key + 6;
} else if (key[0] == 'L') {
- arg_end = (char *)key + 11;
+ arg_end = key + 11;
} else {
- arg_end = (char *)key + 9;
+ arg_end = key + 9;
}
if (arg_end[-1] != '=' || !ascii_isdigit(*arg_end)) {
illegal = true;
@@ -5199,8 +5192,8 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
finished = true;
break;
}
- arg_end = skip_regexp((char *)next_arg + 1, *next_arg, true, NULL);
- if (*arg_end != (char)(*next_arg)) { // end delimiter not found
+ arg_end = skip_regexp(next_arg + 1, *next_arg, true, NULL);
+ if (*arg_end != *next_arg) { // end delimiter not found
illegal = true;
break;
}
@@ -5208,7 +5201,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
if (!eap->skip) {
// store the pattern and compiled regexp program
curwin->w_s->b_syn_linecont_pat =
- (char *)vim_strnsave(next_arg + 1, (size_t)(arg_end - (char *)next_arg) - 1);
+ xstrnsave(next_arg + 1, (size_t)(arg_end - next_arg) - 1);
curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic;
// Make 'cpoptions' empty, to avoid the 'l' flag
@@ -5225,9 +5218,9 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
break;
}
}
- next_arg = (char_u *)skipwhite(arg_end + 1);
+ next_arg = skipwhite(arg_end + 1);
} else {
- eap->arg = (char *)next_arg;
+ eap->arg = next_arg;
if (STRCMP(key, "MATCH") == 0) {
syn_cmd_match(eap, true);
} else if (STRCMP(key, "REGION") == 0) {
@@ -5246,7 +5239,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
if (illegal) {
semsg(_("E404: Illegal arguments: %s"), arg_start);
} else if (!finished) {
- eap->nextcmd = (char *)check_nextcmd(arg_start);
+ eap->nextcmd = check_nextcmd(arg_start);
redraw_curbuf_later(UPD_SOME_VALID);
syn_stack_free_all(curwin->w_s); // Need to recompute all syntax.
}
@@ -5327,7 +5320,7 @@ static int get_id_list(char **const arg, const int keylen, int16_t **const list,
if (skip) {
id = -1;
} else {
- id = syn_check_cluster((char_u *)name + 2, (int)(end - p - 1));
+ id = syn_check_cluster(name + 2, (int)(end - p - 1));
}
} else {
/*
@@ -5565,21 +5558,19 @@ static struct subcommand subcommands[] =
{ NULL, NULL }
};
-/*
- * ":syntax".
- * This searches the subcommands[] table for the subcommand name, and calls a
- * syntax_subcommand() function to do the rest.
- */
+/// ":syntax".
+/// This searches the subcommands[] table for the subcommand name, and calls a
+/// syntax_subcommand() function to do the rest.
void ex_syntax(exarg_T *eap)
{
- char_u *arg = (char_u *)eap->arg;
- char_u *subcmd_end;
+ char *arg = eap->arg;
+ char *subcmd_end;
syn_cmdlinep = eap->cmdlinep;
// isolate subcommand name
for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) {}
- char_u *const subcmd_name = vim_strnsave(arg, (size_t)(subcmd_end - arg));
+ char *const subcmd_name = xstrnsave(arg, (size_t)(subcmd_end - arg));
if (eap->skip) { // skip error messages for all subcommands
emsg_skip++;
}
@@ -5588,8 +5579,8 @@ void ex_syntax(exarg_T *eap)
semsg(_("E410: Invalid :syntax subcommand: %s"), subcmd_name);
break;
}
- if (STRCMP(subcmd_name, (char_u *)subcommands[i].name) == 0) {
- eap->arg = skipwhite((char *)subcmd_end);
+ if (STRCMP(subcmd_name, subcommands[i].name) == 0) {
+ eap->arg = skipwhite(subcmd_end);
(subcommands[i].func)(eap, false);
break;
}
@@ -5602,8 +5593,8 @@ void ex_syntax(exarg_T *eap)
void ex_ownsyntax(exarg_T *eap)
{
- char_u *old_value;
- char_u *new_value;
+ char *old_value;
+ char *new_value;
if (curwin->w_s == &curwin->w_buffer->b_s) {
curwin->w_s = xcalloc(1, sizeof(synblock_T));
@@ -5620,25 +5611,25 @@ void ex_ownsyntax(exarg_T *eap)
}
// Save value of b:current_syntax.
- old_value = get_var_value("b:current_syntax");
+ old_value = (char *)get_var_value("b:current_syntax");
if (old_value != NULL) {
- old_value = vim_strsave(old_value);
+ old_value = xstrdup(old_value);
}
// Apply the "syntax" autocommand event, this finds and loads the syntax file.
apply_autocmds(EVENT_SYNTAX, eap->arg, curbuf->b_fname, true, curbuf);
// Move value of b:current_syntax to w:current_syntax.
- new_value = get_var_value("b:current_syntax");
+ new_value = (char *)get_var_value("b:current_syntax");
if (new_value != NULL) {
- set_internal_string_var("w:current_syntax", (char *)new_value);
+ set_internal_string_var("w:current_syntax", new_value);
}
// Restore value of b:current_syntax.
if (old_value == NULL) {
do_unlet(S_LEN("b:current_syntax"), true);
} else {
- set_internal_string_var("b:current_syntax", (char *)old_value);
+ set_internal_string_var("b:current_syntax", old_value);
xfree(old_value);
}
}
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 4fd99b058b..54c1dc7741 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -502,9 +502,9 @@ bool do_tag(char_u *tag, int type, int count, int forceit, int verbose)
// Find the position of each old match in the new list. Need
// to use parse_match() to find the tag line.
for (j = 0; j < num_matches; j++) {
- parse_match((char_u *)matches[j], &tagp);
+ parse_match(matches[j], &tagp);
for (i = idx; i < new_num_matches; i++) {
- parse_match((char_u *)new_matches[i], &tagp2);
+ parse_match(new_matches[i], &tagp2);
if (STRCMP(tagp.tagname, tagp2.tagname) == 0) {
char_u *p = (char_u *)new_matches[i];
for (k = i; k > idx; k--) {
@@ -585,7 +585,7 @@ bool do_tag(char_u *tag, int type, int count, int forceit, int verbose)
tagstack[tagstackidx].cur_fnum = cur_fnum;
// store user-provided data originating from tagfunc
- if (use_tfu && parse_match((char_u *)matches[cur_match], &tagp2) == OK
+ if (use_tfu && parse_match(matches[cur_match], &tagp2) == OK
&& tagp2.user_data) {
XFREE_CLEAR(tagstack[tagstackidx].user_data);
tagstack[tagstackidx].user_data = (char *)vim_strnsave(tagp2.user_data,
@@ -705,7 +705,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
// Assume that the first match indicates how long the tags can
// be, and align the file names to that.
- parse_match((char_u *)matches[0], &tagp);
+ parse_match(matches[0], &tagp);
taglen = (int)(tagp.tagname_end - tagp.tagname + 2);
if (taglen < 18) {
taglen = 18;
@@ -723,7 +723,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
msg_puts_attr(_("file\n"), HL_ATTR(HLF_T));
for (i = 0; i < num_matches && !got_int; i++) {
- parse_match((char_u *)matches[i], &tagp);
+ parse_match(matches[i], &tagp);
if (!new_tag && (
(g_do_tagpreview != 0
&& i == ptag_entry.cur_match)
@@ -897,7 +897,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char **matches)
long lnum;
dict_T *dict;
- parse_match((char_u *)matches[i], &tagp);
+ parse_match(matches[i], &tagp);
// Save the tag name
len = (int)(tagp.tagname_end - tagp.tagname);
@@ -1957,7 +1957,7 @@ parse_line:
break;
} else if (state == TS_SKIP_BACK) {
assert(cmplen >= 0);
- if (mb_strnicmp(tagp.tagname, orgpat.head, (size_t)cmplen) != 0) {
+ if (mb_strnicmp((char *)tagp.tagname, (char *)orgpat.head, (size_t)cmplen) != 0) {
state = TS_STEP_FORWARD;
} else {
// Have to skip back more. Restore the curr_offset
@@ -1967,7 +1967,7 @@ parse_line:
continue;
} else if (state == TS_STEP_FORWARD) {
assert(cmplen >= 0);
- if (mb_strnicmp(tagp.tagname, orgpat.head, (size_t)cmplen) != 0) {
+ if (mb_strnicmp((char *)tagp.tagname, (char *)orgpat.head, (size_t)cmplen) != 0) {
if ((off_T)vim_ftell(fp) > search_info.match_offset) {
break; // past last match
} else {
@@ -1978,7 +1978,7 @@ parse_line:
// skip this match if it can't match
assert(cmplen >= 0);
}
- if (mb_strnicmp(tagp.tagname, orgpat.head, (size_t)cmplen) != 0) {
+ if (mb_strnicmp((char *)tagp.tagname, (char *)orgpat.head, (size_t)cmplen) != 0) {
continue;
}
@@ -2014,7 +2014,7 @@ parse_line:
} else {
if (orgpat.regmatch.rm_ic) {
assert(cmplen >= 0);
- match = mb_strnicmp(tagp.tagname, orgpat.pat, (size_t)cmplen) == 0;
+ match = mb_strnicmp((char *)tagp.tagname, (char *)orgpat.pat, (size_t)cmplen) == 0;
if (match) {
match_no_ic = (STRNCMP(tagp.tagname, orgpat.pat,
cmplen) == 0);
@@ -2552,18 +2552,17 @@ static size_t matching_line_len(const char_u *const lbuf)
/// @param tagp output: pointers into the line
///
/// @return OK or FAIL.
-static int parse_match(char_u *lbuf, tagptrs_T *tagp)
+static int parse_match(char *lbuf, tagptrs_T *tagp)
{
int retval;
- char_u *p;
- char_u *pc, *pt;
+ char *p;
+ char *pc, *pt;
- tagp->tag_fname = lbuf + 1;
+ tagp->tag_fname = (char_u *)lbuf + 1;
lbuf += STRLEN(tagp->tag_fname) + 2;
// Find search pattern and the file name for non-etags.
- retval = parse_tag_line(lbuf,
- tagp);
+ retval = parse_tag_line((char_u *)lbuf, tagp);
tagp->tagkind = NULL;
tagp->user_data = NULL;
@@ -2572,32 +2571,32 @@ static int parse_match(char_u *lbuf, tagptrs_T *tagp)
if (retval == OK) {
// Try to find a kind field: "kind:<kind>" or just "<kind>"
- p = tagp->command;
- if (find_extra(&p) == OK) {
- tagp->command_end = p;
- if (p > tagp->command && p[-1] == '|') {
- tagp->command_end = p - 1; // drop trailing bar
+ p = (char *)tagp->command;
+ if (find_extra((char_u **)&p) == OK) {
+ tagp->command_end = (char_u *)p;
+ if (p > (char *)tagp->command && p[-1] == '|') {
+ tagp->command_end = (char_u *)p - 1; // drop trailing bar
}
p += 2; // skip ";\""
if (*p++ == TAB) {
// Accept ASCII alphabetic kind characters and any multi-byte
// character.
- while (ASCII_ISALPHA(*p) || utfc_ptr2len((char *)p) > 1) {
+ while (ASCII_ISALPHA(*p) || utfc_ptr2len(p) > 1) {
if (STRNCMP(p, "kind:", 5) == 0) {
- tagp->tagkind = p + 5;
+ tagp->tagkind = (char_u *)p + 5;
} else if (STRNCMP(p, "user_data:", 10) == 0) {
- tagp->user_data = p + 10;
+ tagp->user_data = (char_u *)p + 10;
} else if (STRNCMP(p, "line:", 5) == 0) {
- tagp->tagline = atoi((char *)p + 5);
+ tagp->tagline = atoi(p + 5);
}
if (tagp->tagkind != NULL && tagp->user_data != NULL) {
break;
}
- pc = (char_u *)vim_strchr((char *)p, ':');
- pt = (char_u *)vim_strchr((char *)p, '\t');
+ pc = vim_strchr(p, ':');
+ pt = vim_strchr(p, '\t');
if (pc == NULL || (pt != NULL && pc > pt)) {
- tagp->tagkind = p;
+ tagp->tagkind = (char_u *)p;
}
if (pt == NULL) {
break;
@@ -2608,16 +2607,16 @@ static int parse_match(char_u *lbuf, tagptrs_T *tagp)
}
}
if (tagp->tagkind != NULL) {
- for (p = tagp->tagkind;
+ for (p = (char *)tagp->tagkind;
*p && *p != '\t' && *p != '\r' && *p != '\n';
MB_PTR_ADV(p)) {}
- tagp->tagkind_end = p;
+ tagp->tagkind_end = (char_u *)p;
}
if (tagp->user_data != NULL) {
- for (p = tagp->user_data;
+ for (p = (char *)tagp->user_data;
*p && *p != '\t' && *p != '\r' && *p != '\n';
MB_PTR_ADV(p)) {}
- tagp->user_data_end = p;
+ tagp->user_data_end = (char_u *)p;
}
}
return retval;
@@ -2671,7 +2670,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
pbuf = xmalloc(LSIZE);
// parse the match line into the tagp structure
- if (parse_match(lbuf, &tagp) == FAIL) {
+ if (parse_match((char *)lbuf, &tagp) == FAIL) {
tagp.fname_end = NULL;
goto erret;
}
@@ -3121,7 +3120,7 @@ int expand_tags(int tagnames, char_u *pat, int *num_file, char ***file)
for (i = 0; i < *num_file; i++) {
size_t len;
- parse_match((char_u *)(*file)[i], &t_p);
+ parse_match((*file)[i], &t_p);
len = (size_t)(t_p.tagname_end - t_p.tagname);
if (len > name_buf_size - 3) {
char_u *buf;
@@ -3201,7 +3200,7 @@ int get_tags(list_T *list, char_u *pat, char_u *buf_fname)
TAG_REGEXP | TAG_NOIC, MAXCOL, (char *)buf_fname);
if (ret == OK && num_matches > 0) {
for (i = 0; i < num_matches; i++) {
- int parse_result = parse_match((char_u *)matches[i], &tp);
+ int parse_result = parse_match(matches[i], &tp);
// Avoid an unused variable warning in release builds.
(void)parse_result;
@@ -3350,9 +3349,9 @@ static void tagstack_shift(win_T *wp)
wp->w_tagstacklen--;
}
-// Push a new item to the tag stack
-static void tagstack_push_item(win_T *wp, char_u *tagname, int cur_fnum, int cur_match, pos_T mark,
- int fnum, char_u *user_data)
+/// Push a new item to the tag stack
+static void tagstack_push_item(win_T *wp, char *tagname, int cur_fnum, int cur_match, pos_T mark,
+ int fnum, char *user_data)
{
taggy_T *tagstack = wp->w_tagstack;
int idx = wp->w_tagstacklen; // top of the stack
@@ -3364,7 +3363,7 @@ static void tagstack_push_item(win_T *wp, char_u *tagname, int cur_fnum, int cur
}
wp->w_tagstacklen++;
- tagstack[idx].tagname = (char *)tagname;
+ tagstack[idx].tagname = tagname;
tagstack[idx].cur_fnum = cur_fnum;
tagstack[idx].cur_match = cur_match;
if (tagstack[idx].cur_match < 0) {
@@ -3372,16 +3371,16 @@ static void tagstack_push_item(win_T *wp, char_u *tagname, int cur_fnum, int cur
}
tagstack[idx].fmark.mark = mark;
tagstack[idx].fmark.fnum = fnum;
- tagstack[idx].user_data = (char *)user_data;
+ tagstack[idx].user_data = user_data;
}
-// Add a list of items to the tag stack in the specified window
+/// Add a list of items to the tag stack in the specified window
static void tagstack_push_items(win_T *wp, list_T *l)
{
listitem_T *li;
dictitem_T *di;
dict_T *itemdict;
- char_u *tagname;
+ char *tagname;
pos_T mark;
int fnum;
@@ -3400,8 +3399,7 @@ static void tagstack_push_items(win_T *wp, list_T *l)
if (list2fpos(&di->di_tv, &mark, &fnum, NULL, false) != OK) {
continue;
}
- if ((tagname = (char_u *)tv_dict_get_string(itemdict, "tagname", true))
- == NULL) {
+ if ((tagname = tv_dict_get_string(itemdict, "tagname", true)) == NULL) {
continue;
}
@@ -3413,7 +3411,7 @@ static void tagstack_push_items(win_T *wp, list_T *l)
(int)tv_dict_get_number(itemdict, "bufnr"),
(int)tv_dict_get_number(itemdict, "matchnr") - 1,
mark, fnum,
- (char_u *)tv_dict_get_string(itemdict, "user_data", true));
+ tv_dict_get_string(itemdict, "user_data", true));
}
}
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 46f4d137c4..08c1946e13 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -565,7 +565,7 @@ void ui_check_mouse(void)
// - 'a' is in 'mouse' and "c" is in MOUSE_A, or
// - the current buffer is a help file and 'h' is in 'mouse' and we are in a
// normal editing mode (not at hit-return message).
- for (char_u *p = (char_u *)p_mouse; *p; p++) {
+ for (char *p = p_mouse; *p; p++) {
switch (*p) {
case 'a':
if (vim_strchr(MOUSE_A, checkfor) != NULL) {