aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2022-12-21 12:00:05 +0100
committerGitHub <noreply@github.com>2022-12-21 19:00:05 +0800
commitec1738a6ed08dd3a89fd07950fa2dcc55a72b705 (patch)
tree2df3877a3d10926a2fcb17b4e2ff07fd70d03ceb
parentc24605a5a08873d0c7161941b0c7d0aba63d1ccc (diff)
downloadrneovim-ec1738a6ed08dd3a89fd07950fa2dcc55a72b705.tar.gz
rneovim-ec1738a6ed08dd3a89fd07950fa2dcc55a72b705.tar.bz2
rneovim-ec1738a6ed08dd3a89fd07950fa2dcc55a72b705.zip
refactor: replace char_u with char 16 - remove STRNCMP (#21208)
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
-rw-r--r--src/nvim/buffer_defs.h2
-rw-r--r--src/nvim/cmdexpand.c10
-rw-r--r--src/nvim/edit.c52
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/ex_cmds.c7
-rw-r--r--src/nvim/ex_docmd.c6
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/getchar.c14
-rw-r--r--src/nvim/hardcopy.c12
-rw-r--r--src/nvim/indent_c.c472
-rw-r--r--src/nvim/insexpand.c18
-rw-r--r--src/nvim/keycodes.c28
-rw-r--r--src/nvim/mapping.c74
-rw-r--r--src/nvim/normal.c2
-rw-r--r--src/nvim/option.c4
-rw-r--r--src/nvim/os/input.c2
-rw-r--r--src/nvim/os/shell.c2
-rw-r--r--src/nvim/os/users.c2
-rw-r--r--src/nvim/regexp.c16
-rw-r--r--src/nvim/spell.c80
-rw-r--r--src/nvim/spell_defs.h4
-rw-r--r--src/nvim/spellfile.c38
-rw-r--r--src/nvim/spellsuggest.c212
-rw-r--r--src/nvim/strings.c4
-rw-r--r--src/nvim/vim.h1
-rw-r--r--src/nvim/viml/parser/expressions.c2
26 files changed, 534 insertions, 534 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index e828b294b9..90fdaf9d3b 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -318,7 +318,7 @@ typedef struct {
typedef struct mapblock mapblock_T;
struct mapblock {
mapblock_T *m_next; // next mapblock in list
- uint8_t *m_keys; // mapped from, lhs
+ char *m_keys; // mapped from, lhs
char *m_str; // mapped to, rhs
char *m_orig_str; // rhs as entered by the user
LuaRef m_luaref; // lua function reference as rhs
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index d1a56feef4..c964c96dd7 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -2960,7 +2960,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
if (xp->xp_context == EXPAND_FILES
|| xp->xp_context == EXPAND_DIRECTORIES
|| xp->xp_context == EXPAND_SHELLCMD) {
- char_u upseg[5];
+ char upseg[5];
upseg[0] = PATHSEP;
upseg[1] = '.';
@@ -2977,7 +2977,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
// go down a directory
c = (int)p_wc;
KeyTyped = true; // in case the key was mapped
- } else if (STRNCMP(xp->xp_pattern, upseg + 1, 3) == 0
+ } else if (strncmp(xp->xp_pattern, upseg + 1, 3) == 0
&& c == K_DOWN) {
// If in a direct ancestor, strip off one ../ to go down
int found = false;
@@ -3024,9 +3024,9 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
if (!found) {
j = i;
- } else if (STRNCMP(cclp->cmdbuff + j, upseg, 4) == 0) {
+ } else if (strncmp(cclp->cmdbuff + j, upseg, 4) == 0) {
j += 4;
- } else if (STRNCMP(cclp->cmdbuff + j, upseg + 1, 3) == 0
+ } else if (strncmp(cclp->cmdbuff + j, upseg + 1, 3) == 0
&& j == i) {
j += 3;
} else {
@@ -3037,7 +3037,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
// TODO(tarruda): this is only for DOS/Unix systems - need to put in
// machine-specific stuff here and in upseg init
cmdline_del(cclp, j);
- put_on_cmdline(upseg + 1, 3, false);
+ put_on_cmdline((char_u *)upseg + 1, 3, false);
} else if (cclp->cmdpos > i) {
cmdline_del(cclp, i);
}
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 09836e747f..5df52ab56e 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -2777,7 +2777,7 @@ static bool echeck_abbr(int c)
return false;
}
- return check_abbr(c, (char_u *)get_cursor_line_ptr(), curwin->w_cursor.col,
+ return check_abbr(c, get_cursor_line_ptr(), curwin->w_cursor.col,
curwin->w_cursor.lnum == Insstart.lnum ? Insstart.col : 0);
}
@@ -3018,11 +3018,11 @@ bool cindent_on(void)
/// @param line_is_empty when true, accept keys with '0' before them.
bool in_cinkeys(int keytyped, int when, bool line_is_empty)
{
- uint8_t *look;
+ char *look;
int try_match;
int try_match_word;
- uint8_t *p;
- uint8_t *line;
+ char *p;
+ char *line;
bool icase;
if (keytyped == NUL) {
@@ -3031,9 +3031,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
}
if (*curbuf->b_p_inde != NUL) {
- look = (uint8_t *)curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys'
+ look = curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys'
} else {
- look = (uint8_t *)curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys'
+ look = curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys'
}
while (*look) {
// Find out if we want to try a match with this key, depending on
@@ -3086,9 +3086,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
// cursor.
} else if (*look == 'e') {
if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) {
- p = (uint8_t *)get_cursor_line_ptr();
- if ((uint8_t *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4
- && STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) {
+ p = get_cursor_line_ptr();
+ if (skipwhite(p) == p + curwin->w_cursor.col - 4
+ && strncmp(p + curwin->w_cursor.col - 4, "else", 4) == 0) {
return true;
}
}
@@ -3099,12 +3099,12 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
// class::method for C++).
} else if (*look == ':') {
if (try_match && keytyped == ':') {
- p = (uint8_t *)get_cursor_line_ptr();
+ p = get_cursor_line_ptr();
if (cin_iscase((char_u *)p, false) || cin_isscopedecl((char_u *)p) || cin_islabel()) {
return true;
}
// Need to get the line again after cin_islabel().
- p = (uint8_t *)get_cursor_line_ptr();
+ p = get_cursor_line_ptr();
if (curwin->w_cursor.col > 2
&& p[curwin->w_cursor.col - 1] == ':'
&& p[curwin->w_cursor.col - 2] == ':') {
@@ -3112,7 +3112,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
const bool i = cin_iscase((char_u *)p, false)
|| cin_isscopedecl((char_u *)p)
|| cin_islabel();
- p = (uint8_t *)get_cursor_line_ptr();
+ p = get_cursor_line_ptr();
p[curwin->w_cursor.col - 1] = ':';
if (i) {
return true;
@@ -3151,22 +3151,22 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
} else {
icase = false;
}
- p = (uint8_t *)vim_strchr((char *)look, ',');
+ p = vim_strchr(look, ',');
if (p == NULL) {
- p = look + strlen((char *)look);
+ p = look + strlen(look);
}
if ((try_match || try_match_word)
&& curwin->w_cursor.col >= (colnr_T)(p - look)) {
bool match = false;
if (keytyped == KEY_COMPLETE) {
- uint8_t *n, *s;
+ char *n, *s;
// Just completed a word, check if it starts with "look".
// search back for the start of a word.
- line = (uint8_t *)get_cursor_line_ptr();
+ line = get_cursor_line_ptr();
for (s = line + curwin->w_cursor.col; s > line; s = n) {
- n = mb_prevptr((char_u *)line, (char_u *)s);
+ n = (char *)mb_prevptr((char_u *)line, (char_u *)s);
if (!vim_iswordp((char_u *)n)) {
break;
}
@@ -3174,22 +3174,22 @@ 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((char *)s, (char *)look, (size_t)(p - look))
- : STRNCMP(s, look, p - look)) == 0) {
+ ? mb_strnicmp(s, look, (size_t)(p - look))
+ : strncmp(s, look, (size_t)(p - look))) == 0) {
match = true;
}
} else {
// TODO(@brammool): multi-byte
- if (keytyped == (int)p[-1]
+ if (keytyped == (int)(uint8_t)p[-1]
|| (icase && keytyped < 256
&& TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) {
- line = (uint8_t *)get_cursor_pos_ptr();
+ line = get_cursor_pos_ptr();
assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);
if ((curwin->w_cursor.col == (colnr_T)(p - look)
- || !vim_iswordc(line[-(p - look) - 1]))
+ || !vim_iswordc((uint8_t)line[-(p - look) - 1]))
&& (icase
- ? mb_strnicmp((char *)line - (p - look), (char *)look, (size_t)(p - look))
- : STRNCMP(line - (p - look), look, p - look)) == 0) {
+ ? mb_strnicmp(line - (p - look), look, (size_t)(p - look))
+ : strncmp(line - (p - look), look, (size_t)(p - look))) == 0) {
match = true;
}
}
@@ -3210,7 +3210,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
// Ok, it's a boring generic character.
} else {
- if (try_match && *look == keytyped) {
+ if (try_match && (uint8_t)(*look) == keytyped) {
return true;
}
if (*look != NUL) {
@@ -3219,7 +3219,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
}
// Skip over ", ".
- look = (uint8_t *)skip_to_option_part((char *)look);
+ look = skip_to_option_part(look);
}
return false;
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 8734700305..d9081680ae 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -3838,7 +3838,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
if (p[1] != '*') {
flags |= FSK_SIMPLIFY;
}
- extra = trans_special((const char_u **)&p, strlen(p), (char_u *)name, flags, false, NULL);
+ extra = trans_special((const char **)&p, strlen(p), (char_u *)name, flags, false, NULL);
if (extra != 0) {
name += extra;
if (name >= rettv->vval.v_string + len) {
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index e6e6176669..5eb5359e90 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1367,12 +1367,13 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp)
{
bool is_fish_shell =
#if defined(UNIX)
- STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
+ strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
#else
false;
#endif
- bool is_pwsh = STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0
- || STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "powershell", 10) == 0;
+ bool is_pwsh = strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0
+ || strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "powershell",
+ 10) == 0;
size_t len = strlen(cmd) + 1; // At least enough space for cmd + NULL.
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 3a28d557e3..b99df64a3d 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6631,7 +6631,7 @@ enum {
/// Check "str" for starting with a special cmdline variable.
/// If found return one of the SPEC_ values and set "*usedlen" to the length of
/// the variable. Otherwise return -1 and "*usedlen" is unchanged.
-ssize_t find_cmdline_var(const char_u *src, size_t *usedlen)
+ssize_t find_cmdline_var(const char *src, size_t *usedlen)
FUNC_ATTR_NONNULL_ALL
{
static char *(spec_str[]) = {
@@ -6655,7 +6655,7 @@ ssize_t find_cmdline_var(const char_u *src, size_t *usedlen)
for (size_t i = 0; i < ARRAY_SIZE(spec_str); i++) {
size_t len = strlen(spec_str[i]);
- if (STRNCMP(src, spec_str[i], len) == 0) {
+ if (strncmp(src, spec_str[i], len) == 0) {
*usedlen = len;
assert(i <= SSIZE_MAX);
return (ssize_t)i;
@@ -6711,7 +6711,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T
}
// Check if there is something to do.
- ssize_t spec_idx = find_cmdline_var(src, usedlen);
+ ssize_t spec_idx = find_cmdline_var((char *)src, usedlen);
if (spec_idx < 0) { // no match
*usedlen = 1;
return NULL;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index bd77df1704..97f4c6261b 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -3929,7 +3929,7 @@ static int ccheck_abbr(int c)
spos = 0;
}
- return check_abbr(c, (char_u *)ccline.cmdbuff, ccline.cmdpos, spos);
+ return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos);
}
/// Escape special characters in "fname", depending on "what":
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index fa4d2942f6..db4d640f46 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1968,7 +1968,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
// Only consider an entry if the first character matches and it is
// for the current state.
// Skip ":lmap" mappings if keys were mapped.
- if (mp->m_keys[0] == tb_c1 && (mp->m_mode & local_State)
+ if ((uint8_t)mp->m_keys[0] == tb_c1 && (mp->m_mode & local_State)
&& ((mp->m_mode & MODE_LANGMAP) == 0 || typebuf.tb_maplen == 0)) {
int nomap = nolmaplen;
int modifiers = 0;
@@ -1994,7 +1994,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
}
modifiers = 0;
}
- if (mp->m_keys[mlen] != c2) {
+ if ((uint8_t)mp->m_keys[mlen] != c2) {
break;
}
}
@@ -2002,7 +2002,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
// Don't allow mapping the first byte(s) of a multi-byte char.
// Happens when mapping <M-a> and then changing 'encoding'.
// Beware that 0x80 is escaped.
- char_u *p1 = mp->m_keys;
+ char_u *p1 = (char_u *)mp->m_keys;
char_u *p2 = (char_u *)mb_unescape((const char **)&p1);
if (p2 != NULL && MB_BYTE2LEN(tb_c1) > utfc_ptr2len((char *)p2)) {
@@ -2020,8 +2020,8 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
// mapping starts with K_SNR.
uint8_t *s = typebuf.tb_noremap + typebuf.tb_off;
if (*s == RM_SCRIPT
- && (mp->m_keys[0] != K_SPECIAL
- || mp->m_keys[1] != KS_EXTRA
+ && ((uint8_t)mp->m_keys[0] != K_SPECIAL
+ || (uint8_t)mp->m_keys[1] != KS_EXTRA
|| mp->m_keys[2] != KE_SNR)) {
continue;
}
@@ -2212,7 +2212,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
vgetc_busy = 0;
may_garbage_collect = false;
- save_m_keys = xstrdup((char *)mp->m_keys);
+ save_m_keys = xstrdup(mp->m_keys);
if (save_m_luaref == LUA_NOREF) {
save_m_str = xstrdup(mp->m_str);
}
@@ -2266,7 +2266,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
if (save_m_noremap != REMAP_YES) {
noremap = save_m_noremap;
- } else if (strncmp(map_str, save_m_keys != NULL ? save_m_keys : (char *)mp->m_keys,
+ } else if (strncmp(map_str, save_m_keys != NULL ? save_m_keys : mp->m_keys,
(size_t)keylen) != 0) {
noremap = REMAP_YES;
} else {
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 3e43eca92c..0240761483 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -232,7 +232,7 @@ struct prt_ps_resource_S {
char_u filename[MAXPATHL + 1];
PrtResourceType type;
char_u title[256];
- char_u version[256];
+ char version[256];
};
struct prt_dsc_comment_S {
@@ -243,7 +243,7 @@ struct prt_dsc_comment_S {
struct prt_dsc_line_S {
int type;
- char_u *string;
+ char *string;
int len;
};
@@ -251,7 +251,7 @@ struct prt_dsc_line_S {
// couple of KB of comments!
#define PRT_FILE_BUFFER_LEN (2048)
struct prt_resfile_buffer_S {
- char_u buffer[PRT_FILE_BUFFER_LEN];
+ char buffer[PRT_FILE_BUFFER_LEN];
int len;
int line_start;
int line_end;
@@ -1550,8 +1550,8 @@ static int prt_resfile_strncmp(int offset, const char *string, int len)
if (len > (prt_resfile.line_end - (prt_resfile.line_start + offset))) {
return 1;
}
- return STRNCMP(&prt_resfile.buffer[prt_resfile.line_start + offset],
- string, len);
+ return strncmp(&prt_resfile.buffer[prt_resfile.line_start + offset],
+ string, (size_t)len);
}
static int prt_resfile_skip_nonws(int offset)
@@ -1751,7 +1751,7 @@ static bool prt_check_resource(const struct prt_ps_resource_S *resource, const c
FUNC_ATTR_NONNULL_ALL
{
// Version number m.n should match, the revision number does not matter
- if (STRNCMP(resource->version, version, strlen(version)) != 0) {
+ if (strncmp(resource->version, version, strlen(version)) != 0) {
semsg(_("E621: \"%s\" resource file has wrong version"),
resource->name);
return false;
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 18f301f96e..ca08f67e32 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -131,7 +131,7 @@ static pos_T *find_start_rawstring(int ind_maxcomment) // XXX
// Skip to the end of a "string" and a 'c' character.
// If there is no string or character, return argument unmodified.
-static const char_u *skip_string(const char_u *p)
+static const char *skip_string(const char *p)
{
int i;
@@ -172,7 +172,7 @@ static const char_u *skip_string(const char_u *p)
const ptrdiff_t delim_len = paren - delim;
for (p += 3; *p; p++) {
- if (p[0] == ')' && STRNCMP(p + 1, delim, delim_len) == 0
+ if (p[0] == ')' && strncmp(p + 1, delim, (size_t)delim_len) == 0
&& p[delim_len + 1] == '"') {
p += delim_len + 1;
break;
@@ -197,7 +197,7 @@ int is_pos_in_string(const char_u *line, colnr_T col)
const char_u *p;
for (p = line; *p && (colnr_T)(p - line) < col; p++) {
- p = skip_string(p);
+ p = (char_u *)skip_string((char *)p);
}
return !((colnr_T)(p - line) <= col);
}
@@ -213,12 +213,12 @@ bool cin_is_cinword(const char *line)
bool retval = false;
size_t cinw_len = strlen(curbuf->b_p_cinw) + 1;
- char_u *cinw_buf = xmalloc(cinw_len);
+ char *cinw_buf = xmalloc(cinw_len);
line = skipwhite((char *)line);
for (char *cinw = curbuf->b_p_cinw; *cinw;) {
- size_t len = copy_option_part(&cinw, (char *)cinw_buf, cinw_len, ",");
- if (STRNCMP(line, cinw_buf, len) == 0
+ size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
+ if (strncmp(line, cinw_buf, len) == 0
&& (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) {
retval = true;
break;
@@ -350,7 +350,7 @@ bool cin_islabel(void) // XXX
// Exclude "default" from labels, since it should be indented
// like a switch label. Same for C++ scope declarations.
- if (cin_isdefault(s)) {
+ if (cin_isdefault((char *)s)) {
return false;
}
if (cin_isscopedecl(s)) {
@@ -408,7 +408,7 @@ static int cin_isinit(void)
s = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (cin_starts_with(s, "typedef")) {
+ if (cin_starts_with((char *)s, "typedef")) {
s = cin_skipcomment(s + 7);
}
@@ -417,7 +417,7 @@ static int cin_isinit(void)
for (i = 0; i < (int)ARRAY_SIZE(skip); i++) {
l = (int)strlen(skip[i]);
- if (cin_starts_with(s, skip[i])) {
+ if (cin_starts_with((char *)s, skip[i])) {
s = cin_skipcomment(s + l);
l = 0;
break;
@@ -428,11 +428,11 @@ static int cin_isinit(void)
}
}
- if (cin_starts_with(s, "enum")) {
+ if (cin_starts_with((char *)s, "enum")) {
return true;
}
- if (cin_ends_in(s, (char_u *)"=", (char_u *)"{")) {
+ if (cin_ends_in((char *)s, "=", "{")) {
return true;
}
@@ -445,7 +445,7 @@ static int cin_isinit(void)
bool cin_iscase(const char_u *s, bool strict)
{
s = cin_skipcomment(s);
- if (cin_starts_with(s, "case")) {
+ if (cin_starts_with((char *)s, "case")) {
for (s += 4; *s; s++) {
s = cin_skipcomment(s);
if (*s == NUL) {
@@ -473,34 +473,34 @@ bool cin_iscase(const char_u *s, bool strict)
return false;
}
- if (cin_isdefault(s)) {
+ if (cin_isdefault((char *)s)) {
return true;
}
return false;
}
// Recognize a "default" switch label.
-static int cin_isdefault(const char_u *s)
+static int cin_isdefault(const char *s)
{
- return STRNCMP(s, "default", 7) == 0
- && *(s = cin_skipcomment(s + 7)) == ':'
+ return strncmp(s, "default", 7) == 0
+ && *(s = (char *)cin_skipcomment((char_u *)s + 7)) == ':'
&& s[1] != ':';
}
/// Recognize a scope declaration label set in 'cinscopedecls'.
bool cin_isscopedecl(const char_u *p)
{
- const char_u *s = cin_skipcomment(p);
+ const char *s = (char *)cin_skipcomment(p);
const size_t cinsd_len = strlen(curbuf->b_p_cinsd) + 1;
- char_u *cinsd_buf = xmalloc(cinsd_len);
+ char *cinsd_buf = xmalloc(cinsd_len);
bool found = false;
for (char *cinsd = curbuf->b_p_cinsd; *cinsd;) {
- const size_t len = copy_option_part(&cinsd, (char *)cinsd_buf, cinsd_len, ",");
- if (STRNCMP(s, cinsd_buf, len) == 0) {
- const char_u *skip = cin_skipcomment(s + len);
+ const size_t len = copy_option_part(&cinsd, cinsd_buf, cinsd_len, ",");
+ if (strncmp(s, cinsd_buf, len) == 0) {
+ const char_u *skip = cin_skipcomment((char_u *)s + len);
if (*skip == ':' && skip[1] != ':') {
found = true;
break;
@@ -517,19 +517,19 @@ bool cin_isscopedecl(const char_u *p)
#define FIND_NAMESPACE_LIM 20
// Recognize a "namespace" scope declaration.
-static bool cin_is_cpp_namespace(const char_u *s)
+static bool cin_is_cpp_namespace(const char *s)
{
const char_u *p;
bool has_name = false;
bool has_name_start = false;
- s = cin_skipcomment(s);
+ s = (char *)cin_skipcomment((char_u *)s);
- if (STRNCMP(s, "inline", 6) == 0 && (s[6] == NUL || !vim_iswordc(s[6]))) {
- s = cin_skipcomment((char_u *)skipwhite((char *)s + 6));
+ if (strncmp(s, "inline", 6) == 0 && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) {
+ s = (char *)cin_skipcomment((char_u *)skipwhite((char *)s + 6));
}
- if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9]))) {
+ if (strncmp(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc((uint8_t)s[9]))) {
p = cin_skipcomment((char_u *)skipwhite((char *)s + 9));
while (*p != NUL) {
if (ascii_iswhite(*p)) {
@@ -610,25 +610,25 @@ static int get_indent_nolabel(linenr_T lnum) // XXX
// Also return a pointer to the text (after the label) in "pp".
// label: if (asdf && asdfasdf)
// ^
-static int skip_label(linenr_T lnum, const char_u **pp)
+static int skip_label(linenr_T lnum, const char **pp)
{
- const char_u *l;
+ const char *l;
int amount;
pos_T cursor_save;
cursor_save = curwin->w_cursor;
curwin->w_cursor.lnum = lnum;
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
// XXX
- if (cin_iscase(l, false) || cin_isscopedecl(l) || cin_islabel()) {
+ if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l) || cin_islabel()) {
amount = get_indent_nolabel(lnum);
- l = after_label((char_u *)get_cursor_line_ptr());
+ l = (char *)after_label((char_u *)get_cursor_line_ptr());
if (l == NULL) { // just in case
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
}
} else {
amount = get_indent();
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
}
*pp = l;
@@ -643,38 +643,38 @@ static int skip_label(linenr_T lnum, const char_u **pp)
// Returns zero when it doesn't look like a declaration.
static int cin_first_id_amount(void)
{
- char_u *line, *p, *s;
+ char *line, *p, *s;
int len;
pos_T fp;
colnr_T col;
- line = (char_u *)get_cursor_line_ptr();
- p = (char_u *)skipwhite((char *)line);
- len = (int)((char_u *)skiptowhite((char *)p) - p);
- if (len == 6 && STRNCMP(p, "static", 6) == 0) {
- p = (char_u *)skipwhite((char *)p + 6);
- len = (int)((char_u *)skiptowhite((char *)p) - p);
- }
- if (len == 6 && STRNCMP(p, "struct", 6) == 0) {
- p = (char_u *)skipwhite((char *)p + 6);
- } else if (len == 4 && STRNCMP(p, "enum", 4) == 0) {
- p = (char_u *)skipwhite((char *)p + 4);
- } else if ((len == 8 && STRNCMP(p, "unsigned", 8) == 0)
- || (len == 6 && STRNCMP(p, "signed", 6) == 0)) {
- s = (char_u *)skipwhite((char *)p + len);
- if ((STRNCMP(s, "int", 3) == 0 && ascii_iswhite(s[3]))
- || (STRNCMP(s, "long", 4) == 0 && ascii_iswhite(s[4]))
- || (STRNCMP(s, "short", 5) == 0 && ascii_iswhite(s[5]))
- || (STRNCMP(s, "char", 4) == 0 && ascii_iswhite(s[4]))) {
+ line = get_cursor_line_ptr();
+ p = skipwhite(line);
+ len = (int)(skiptowhite(p) - p);
+ if (len == 6 && strncmp(p, "static", 6) == 0) {
+ p = skipwhite(p + 6);
+ len = (int)(skiptowhite(p) - p);
+ }
+ if (len == 6 && strncmp(p, "struct", 6) == 0) {
+ p = skipwhite(p + 6);
+ } else if (len == 4 && strncmp(p, "enum", 4) == 0) {
+ p = skipwhite(p + 4);
+ } else if ((len == 8 && strncmp(p, "unsigned", 8) == 0)
+ || (len == 6 && strncmp(p, "signed", 6) == 0)) {
+ s = skipwhite(p + len);
+ if ((strncmp(s, "int", 3) == 0 && ascii_iswhite(s[3]))
+ || (strncmp(s, "long", 4) == 0 && ascii_iswhite(s[4]))
+ || (strncmp(s, "short", 5) == 0 && ascii_iswhite(s[5]))
+ || (strncmp(s, "char", 4) == 0 && ascii_iswhite(s[4]))) {
p = s;
}
}
for (len = 0; vim_isIDc(p[len]); len++) {}
- if (len == 0 || !ascii_iswhite(p[len]) || cin_nocode(p)) {
+ if (len == 0 || !ascii_iswhite(p[len]) || cin_nocode((char_u *)p)) {
return 0;
}
- p = (char_u *)skipwhite((char *)p + len);
+ p = skipwhite(p + len);
fp.lnum = curwin->w_cursor.lnum;
fp.col = (colnr_T)(p - line);
getvcol(curwin, &fp, &col, NULL, NULL);
@@ -743,9 +743,9 @@ static int cin_ispreproc(const char_u *s)
/// continuation line of a preprocessor statement. Decrease "*lnump" to the
/// start and return the line in "*pp".
/// Put the amount of indent in "*amount".
-static int cin_ispreproc_cont(const char_u **pp, linenr_T *lnump, int *amount)
+static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount)
{
- const char_u *line = *pp;
+ const char_u *line = (char_u *)(*pp);
linenr_T lnum = *lnump;
int retval = false;
int candidate_amount = *amount;
@@ -770,7 +770,7 @@ static int cin_ispreproc_cont(const char_u **pp, linenr_T *lnump, int *amount)
}
if (lnum != *lnump) {
- *pp = (char_u *)ml_get(*lnump);
+ *pp = ml_get(*lnump);
}
if (retval) {
*amount = candidate_amount;
@@ -809,17 +809,17 @@ static char_u cin_isterminated(const char_u *s, int incl_open, int incl_comma)
s = cin_skipcomment(s);
- if (*s == '{' || (*s == '}' && !cin_iselse(s))) {
+ if (*s == '{' || (*s == '}' && !cin_iselse((char *)s))) {
found_start = *s;
}
if (!found_start) {
- is_else = cin_iselse(s);
+ is_else = cin_iselse((char *)s);
}
while (*s) {
// skip over comments, "" strings and 'c'haracters
- s = skip_string(cin_skipcomment(s));
+ s = (char_u *)skip_string((char *)cin_skipcomment(s));
if (*s == '}' && n_open > 0) {
n_open--;
}
@@ -852,7 +852,7 @@ static char_u cin_isterminated(const char_u *s, int incl_open, int incl_comma)
/// lines here.
/// @param[in] first_lnum Where to start looking.
/// @param[in] min_lnum The line before which we will not be looking.
-static int cin_isfuncdecl(const char_u **sp, linenr_T first_lnum, linenr_T min_lnum)
+static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnum)
{
const char_u *s;
linenr_T lnum = first_lnum;
@@ -864,7 +864,7 @@ static int cin_isfuncdecl(const char_u **sp, linenr_T first_lnum, linenr_T min_l
if (sp == NULL) {
s = (char_u *)ml_get(lnum);
} else {
- s = *sp;
+ s = (char_u *)(*sp);
}
curwin->w_cursor.lnum = lnum;
@@ -956,28 +956,28 @@ static int cin_isfuncdecl(const char_u **sp, linenr_T first_lnum, linenr_T min_l
done:
if (lnum != first_lnum && sp != NULL) {
- *sp = (char_u *)ml_get(first_lnum);
+ *sp = ml_get(first_lnum);
}
return retval;
}
-static int cin_isif(const char_u *p)
+static int cin_isif(const char *p)
{
- return STRNCMP(p, "if", 2) == 0 && !vim_isIDc(p[2]);
+ return strncmp(p, "if", 2) == 0 && !vim_isIDc((uint8_t)p[2]);
}
-static int cin_iselse(const char_u *p)
+static int cin_iselse(const char *p)
{
if (*p == '}') { // accept "} else"
- p = cin_skipcomment(p + 1);
+ p = (char *)cin_skipcomment((char_u *)p + 1);
}
- return STRNCMP(p, "else", 4) == 0 && !vim_isIDc(p[4]);
+ return strncmp(p, "else", 4) == 0 && !vim_isIDc((uint8_t)p[4]);
}
-static int cin_isdo(const char_u *p)
+static int cin_isdo(const char *p)
{
- return STRNCMP(p, "do", 2) == 0 && !vim_isIDc(p[2]);
+ return strncmp(p, "do", 2) == 0 && !vim_isIDc((uint8_t)p[2]);
}
// Check if this is a "while" that should have a matching "do".
@@ -993,7 +993,7 @@ static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX
if (*p == '}') { // accept "} while (cond);"
p = cin_skipcomment(p + 1);
}
- if (cin_starts_with(p, "while")) {
+ if (cin_starts_with((char *)p, "while")) {
cursor_save = curwin->w_cursor;
curwin->w_cursor.lnum = lnum;
curwin->w_cursor.col = 0;
@@ -1015,7 +1015,7 @@ static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX
// Return 0 if there is none.
// Otherwise return !0 and update "*poffset" to point to the place where the
// string was found.
-static int cin_is_if_for_while_before_offset(const char_u *line, int *poffset)
+static int cin_is_if_for_while_before_offset(const char *line, int *poffset)
{
int offset = *poffset;
@@ -1027,19 +1027,19 @@ static int cin_is_if_for_while_before_offset(const char_u *line, int *poffset)
}
offset -= 1;
- if (!STRNCMP(line + offset, "if", 2)) {
+ if (!strncmp(line + offset, "if", 2)) {
goto probablyFound;
}
if (offset >= 1) {
offset -= 1;
- if (!STRNCMP(line + offset, "for", 3)) {
+ if (!strncmp(line + offset, "for", 3)) {
goto probablyFound;
}
if (offset >= 2) {
offset -= 2;
- if (!STRNCMP(line + offset, "while", 5)) {
+ if (!strncmp(line + offset, "while", 5)) {
goto probablyFound;
}
}
@@ -1047,7 +1047,7 @@ static int cin_is_if_for_while_before_offset(const char_u *line, int *poffset)
return 0;
probablyFound:
- if (!offset || !vim_isIDc(line[offset - 1])) {
+ if (!offset || !vim_isIDc((uint8_t)line[offset - 1])) {
*poffset = offset;
return 1;
}
@@ -1088,7 +1088,7 @@ static int cin_iswhileofdo_end(int terminated)
if (*s == '}') { // accept "} while (cond);"
s = cin_skipcomment(s + 1);
}
- if (cin_starts_with(s, "while")) {
+ if (cin_starts_with((char *)s, "while")) {
curwin->w_cursor.lnum = trypos->lnum;
return true;
}
@@ -1106,9 +1106,9 @@ static int cin_iswhileofdo_end(int terminated)
return false;
}
-static int cin_isbreak(const char_u *p)
+static int cin_isbreak(const char *p)
{
- return STRNCMP(p, "break", 5) == 0 && !vim_isIDc(p[5]);
+ return strncmp(p, "break", 5) == 0 && !vim_isIDc((uint8_t)p[5]);
}
// Find the position of a C++ base-class declaration or
@@ -1125,10 +1125,10 @@ static int cin_isbreak(const char_u *p)
static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
{
lpos_T *pos = &cached->lpos; // find position
- const char_u *s;
+ const char *s;
int class_or_struct, lookfor_ctor_init, cpp_base_class;
linenr_T lnum = curwin->w_cursor.lnum;
- const char_u *line = (char_u *)get_cursor_line_ptr();
+ const char *line = get_cursor_line_ptr();
if (pos->lnum <= lnum) {
return cached->found; // Use the cached result
@@ -1136,11 +1136,11 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
pos->col = 0;
- s = (char_u *)skipwhite((char *)line);
+ s = skipwhite(line);
if (*s == '#') { // skip #define FOO x ? (x) : x
return false;
}
- s = cin_skipcomment(s);
+ s = (char *)cin_skipcomment((char_u *)s);
if (*s == NUL) {
return false;
}
@@ -1160,15 +1160,15 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
// somethingelse(3)
// {}
while (lnum > 1) {
- line = (char_u *)ml_get(lnum - 1);
- s = (char_u *)skipwhite((char *)line);
+ line = ml_get(lnum - 1);
+ s = skipwhite(line);
if (*s == '#' || *s == NUL) {
break;
}
while (*s != NUL) {
- s = cin_skipcomment(s);
+ s = (char *)cin_skipcomment((char_u *)s);
if (*s == '{' || *s == '}'
- || (*s == ';' && cin_nocode(s + 1))) {
+ || (*s == ';' && cin_nocode((char_u *)s + 1))) {
break;
}
if (*s != NUL) {
@@ -1182,7 +1182,7 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
}
pos->lnum = lnum;
- line = (char_u *)ml_get(lnum);
+ line = ml_get(lnum);
s = line;
for (;;) {
if (*s == NUL) {
@@ -1190,47 +1190,47 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
break;
}
// Continue in the cursor line.
- line = (char_u *)ml_get(++lnum);
+ line = ml_get(++lnum);
s = line;
}
if (s == line) {
// don't recognize "case (foo):" as a baseclass */
- if (cin_iscase(s, false)) {
+ if (cin_iscase((char_u *)s, false)) {
break;
}
- s = cin_skipcomment(line);
+ s = (char *)cin_skipcomment((char_u *)line);
if (*s == NUL) {
continue;
}
}
if (s[0] == '"' || (s[0] == 'R' && s[1] == '"')) {
- s = skip_string(s) + 1;
+ s = (char *)skip_string(s) + 1;
} else if (s[0] == ':') {
if (s[1] == ':') {
// skip double colon. It can't be a constructor
// initialization any more
lookfor_ctor_init = false;
- s = cin_skipcomment(s + 2);
+ s = (char *)cin_skipcomment((char_u *)s + 2);
} else if (lookfor_ctor_init || class_or_struct) {
// we have something found, that looks like the start of
// cpp-base-class-declaration or constructor-initialization
cpp_base_class = true;
lookfor_ctor_init = class_or_struct = false;
pos->col = 0;
- s = cin_skipcomment(s + 1);
+ s = (char *)cin_skipcomment((char_u *)s + 1);
} else {
- s = cin_skipcomment(s + 1);
+ s = (char *)cin_skipcomment((char_u *)s + 1);
}
- } else if ((STRNCMP(s, "class", 5) == 0 && !vim_isIDc(s[5]))
- || (STRNCMP(s, "struct", 6) == 0 && !vim_isIDc(s[6]))) {
+ } else if ((strncmp(s, "class", 5) == 0 && !vim_isIDc((uint8_t)s[5]))
+ || (strncmp(s, "struct", 6) == 0 && !vim_isIDc((uint8_t)s[6]))) {
class_or_struct = true;
lookfor_ctor_init = false;
if (*s == 'c') {
- s = cin_skipcomment(s + 5);
+ s = (char *)cin_skipcomment((char_u *)s + 5);
} else {
- s = cin_skipcomment(s + 6);
+ s = (char *)cin_skipcomment((char_u *)s + 6);
}
} else {
if (s[0] == '{' || s[0] == '}' || s[0] == ';') {
@@ -1243,7 +1243,7 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
} else if (s[0] == '?') {
// Avoid seeing '() :' after '?' as constructor init.
return false;
- } else if (!vim_isIDc(s[0])) {
+ } else if (!vim_isIDc((uint8_t)s[0])) {
// if it is not an identifier, we are wrong
class_or_struct = false;
lookfor_ctor_init = false;
@@ -1258,11 +1258,11 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
}
// When the line ends in a comma don't align with it.
- if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode(s + 1)) {
+ if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode((char_u *)s + 1)) {
pos->col = 0;
}
- s = cin_skipcomment(s + 1);
+ s = (char *)cin_skipcomment((char_u *)s + 1);
}
}
@@ -1285,7 +1285,7 @@ static int get_baseclass_amount(int col)
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
amount = get_indent_lnum(trypos->lnum); // XXX
}
- if (!cin_ends_in((char_u *)get_cursor_line_ptr(), (char_u *)",", NULL)) {
+ if (!cin_ends_in(get_cursor_line_ptr(), ",", NULL)) {
amount += curbuf->b_ind_cpp_baseclass;
}
} else {
@@ -1302,20 +1302,20 @@ static int get_baseclass_amount(int col)
/// Return true if string "s" ends with the string "find", possibly followed by
/// white space and comments. Skip strings and comments.
/// Ignore "ignore" after "find" if it's not NULL.
-static int cin_ends_in(const char_u *s, const char_u *find, const char_u *ignore)
+static int cin_ends_in(const char *s, const char *find, const char *ignore)
{
- const char_u *p = s;
- const char_u *r;
+ const char *p = (char *)s;
+ const char *r;
int len = (int)strlen((char *)find);
while (*p != NUL) {
- p = cin_skipcomment(p);
- if (STRNCMP(p, find, len) == 0) {
- r = (char_u *)skipwhite((char *)p + len);
- if (ignore != NULL && STRNCMP(r, ignore, strlen((char *)ignore)) == 0) {
- r = (char_u *)skipwhite((char *)r + strlen((char *)ignore));
+ p = (char *)cin_skipcomment((char_u *)p);
+ if (strncmp(p, find, (size_t)len) == 0) {
+ r = skipwhite((char *)p + len);
+ if (ignore != NULL && strncmp(r, ignore, strlen((char *)ignore)) == 0) {
+ r = skipwhite((char *)r + strlen((char *)ignore));
}
- if (cin_nocode(r)) {
+ if (cin_nocode((char_u *)r)) {
return true;
}
}
@@ -1327,21 +1327,21 @@ static int cin_ends_in(const char_u *s, const char_u *find, const char_u *ignore
}
/// Return true when "s" starts with "word" and then a non-ID character.
-static int cin_starts_with(const char_u *s, const char *word)
+static int cin_starts_with(const char *s, const char *word)
{
- int l = (int)strlen(word);
+ size_t l = strlen(word);
- return STRNCMP(s, word, l) == 0 && !vim_isIDc(s[l]);
+ return strncmp(s, word, l) == 0 && !vim_isIDc((uint8_t)s[l]);
}
/// Recognize a `extern "C"` or `extern "C++"` linkage specifications.
-static int cin_is_cpp_extern_c(const char_u *s)
+static int cin_is_cpp_extern_c(const char *s)
{
const char_u *p;
int has_string_literal = false;
- s = cin_skipcomment(s);
- if (STRNCMP(s, "extern", 6) == 0 && (s[6] == NUL || !vim_iswordc(s[6]))) {
+ s = (char *)cin_skipcomment((char_u *)s);
+ if (strncmp(s, "extern", 6) == 0 && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) {
p = cin_skipcomment((char_u *)skipwhite((char *)s + 6));
while (*p != NUL) {
if (ascii_iswhite(*p)) {
@@ -1384,7 +1384,7 @@ static int cin_skip2pos(pos_T *trypos)
if (cin_iscomment(p)) {
p = cin_skipcomment(p);
} else {
- new_p = skip_string(p);
+ new_p = (char_u *)skip_string((char *)p);
if (new_p == p) {
p++;
} else {
@@ -1524,7 +1524,7 @@ static int find_last_paren(const char_u *l, int start, int end)
for (i = 0; l[i] != NUL; i++) {
i = (int)(cin_skipcomment(l + i) - l); // ignore parens in comments
- i = (int)(skip_string(l + i) - l); // ignore parens in quotes
+ i = (int)(skip_string((char *)l + i) - (char *)l); // ignore parens in quotes
if (l[i] == start) {
open_count++;
} else if (l[i] == end) {
@@ -1844,7 +1844,7 @@ int get_c_indent(void)
int scope_amount;
int cur_amount = MAXCOL;
colnr_T col;
- char_u *theline;
+ char *theline;
char *linecopy;
pos_T *trypos;
pos_T *comment_pos;
@@ -1857,8 +1857,8 @@ int get_c_indent(void)
#define BRACE_AT_START 2 // '{' is at start of line
#define BRACE_AT_END 3 // '{' is at end of line
linenr_T ourscope;
- const char_u *l;
- const char_u *look;
+ const char *l;
+ const char *look;
char_u terminated;
int lookfor;
#define LOOKFOR_INITIAL 0
@@ -1913,7 +1913,7 @@ int get_c_indent(void)
linecopy[curwin->w_cursor.col] = NUL;
}
- theline = (char_u *)skipwhite(linecopy);
+ theline = skipwhite(linecopy);
// move the cursor to the start of the line
@@ -1938,8 +1938,8 @@ int get_c_indent(void)
// #defines and so on go at the left when included in 'cinkeys',
// excluding pragmas when customized in 'cinoptions'
if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', true))) {
- const char_u *const directive = (char_u *)skipwhite((char *)theline + 1);
- if (curbuf->b_ind_pragma == 0 || STRNCMP(directive, "pragma", 6) != 0) {
+ const char *const directive = skipwhite(theline + 1);
+ if (curbuf->b_ind_pragma == 0 || strncmp(directive, "pragma", 6) != 0) {
amount = curbuf->b_ind_hash_comment;
goto theend;
}
@@ -1954,7 +1954,7 @@ int get_c_indent(void)
}
// If we're inside a "//" comment and there is a "//" comment in a
// previous line, lineup with that one.
- if (cin_islinecomment(theline)) {
+ if (cin_islinecomment((char_u *)theline)) {
pos_T linecomment_pos;
trypos = find_line_comment(); // XXX
@@ -1976,7 +1976,7 @@ int get_c_indent(void)
}
// If we're inside a comment and not looking at the start of the
// comment, try using the 'comments' option.
- if (!cin_iscomment(theline) && comment_pos != NULL) { // XXX
+ if (!cin_iscomment((char_u *)theline) && comment_pos != NULL) { // XXX
int lead_start_len = 2;
int lead_middle_len = 1;
char lead_start[COM_MAX_LEN]; // start-comment string
@@ -2026,22 +2026,22 @@ int get_c_indent(void)
} else if (what == COM_END) {
// If our line starts with the middle comment string, line it
// up with the comment opener per the 'comments' option.
- if (STRNCMP(theline, lead_middle, lead_middle_len) == 0
- && STRNCMP(theline, lead_end, strlen(lead_end)) != 0) {
+ if (strncmp(theline, lead_middle, (size_t)lead_middle_len) == 0
+ && strncmp(theline, lead_end, strlen(lead_end)) != 0) {
done = true;
if (curwin->w_cursor.lnum > 1) {
// If the start comment string matches in the previous
// line, use the indent of that line plus offset. If
// the middle comment string matches in the previous
// line, use the indent of that line. XXX
- look = (char_u *)skipwhite(ml_get(curwin->w_cursor.lnum - 1));
- if (STRNCMP(look, lead_start, lead_start_len) == 0) {
+ look = skipwhite(ml_get(curwin->w_cursor.lnum - 1));
+ if (strncmp(look, lead_start, (size_t)lead_start_len) == 0) {
amount = get_indent_lnum(curwin->w_cursor.lnum - 1);
- } else if (STRNCMP(look, lead_middle, lead_middle_len) == 0) {
+ } else if (strncmp(look, lead_middle, (size_t)lead_middle_len) == 0) {
amount = get_indent_lnum(curwin->w_cursor.lnum - 1);
break;
- } else if (STRNCMP(ml_get(comment_pos->lnum) + comment_pos->col,
- lead_start, lead_start_len) != 0) {
+ } else if (strncmp(ml_get(comment_pos->lnum) + comment_pos->col,
+ lead_start, (size_t)lead_start_len) != 0) {
// If the start comment string doesn't match with the
// start of the comment, skip this entry. XXX
continue;
@@ -2057,8 +2057,8 @@ int get_c_indent(void)
// If our line starts with the end comment string, line it up
// with the middle comment
- if (STRNCMP(theline, lead_middle, lead_middle_len) != 0
- && STRNCMP(theline, lead_end, strlen(lead_end)) == 0) {
+ if (strncmp(theline, lead_middle, (size_t)lead_middle_len) != 0
+ && strncmp(theline, lead_end, strlen(lead_end)) == 0) {
amount = get_indent_lnum(curwin->w_cursor.lnum - 1);
// XXX
if (off != 0) {
@@ -2096,7 +2096,7 @@ int get_c_indent(void)
if (amount == -1) { // use the comment opener
if (!curbuf->b_ind_in_comment2) {
start = (char_u *)ml_get(comment_pos->lnum);
- look = start + comment_pos->col + 2; // skip / and *
+ look = (char *)start + comment_pos->col + 2; // skip / and *
if (*look != NUL) { // if something after it
comment_pos->col = (colnr_T)((char_u *)skipwhite((char *)look) - start);
}
@@ -2111,7 +2111,7 @@ int get_c_indent(void)
goto theend;
}
// Are we looking at a ']' that has a match?
- if (*skipwhite((char *)theline) == ']'
+ if (*skipwhite(theline) == ']'
&& (trypos = find_match_char('[', curbuf->b_ind_maxparen)) != NULL) {
// align with the line containing the '['.
amount = get_indent_lnum(trypos->lnum);
@@ -2145,8 +2145,8 @@ int get_c_indent(void)
} else {
amount = -1;
for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; lnum--) {
- l = (char_u *)skipwhite(ml_get(lnum));
- if (cin_nocode(l)) { // skip comment lines
+ l = skipwhite(ml_get(lnum));
+ if (cin_nocode((char_u *)l)) { // skip comment lines
continue;
}
if (cin_ispreproc_cont(&l, &lnum, &amount)) {
@@ -2207,11 +2207,11 @@ int get_c_indent(void)
line = (char_u *)ml_get(outermost.lnum);
is_if_for_while =
- cin_is_if_for_while_before_offset(line, &outermost.col);
+ cin_is_if_for_while_before_offset((char *)line, &outermost.col);
}
amount = skip_label(our_paren_pos.lnum, &look);
- look = (char_u *)skipwhite((char *)look);
+ look = skipwhite((char *)look);
if (*look == '(') {
linenr_T save_lnum = curwin->w_cursor.lnum;
char_u *line;
@@ -2221,7 +2221,7 @@ int get_c_indent(void)
// our matching '('.
curwin->w_cursor.lnum = our_paren_pos.lnum;
line = (char_u *)get_cursor_line_ptr();
- look_col = (int)(look - line);
+ look_col = (int)(look - (char *)line);
curwin->w_cursor.col = look_col + 1;
if ((trypos = findmatchlimit(NULL, ')', 0,
curbuf->b_ind_maxparen))
@@ -2232,7 +2232,7 @@ int get_c_indent(void)
}
curwin->w_cursor.lnum = save_lnum;
- look = (char_u *)ml_get(our_paren_pos.lnum) + look_col;
+ look = ml_get(our_paren_pos.lnum) + look_col;
}
if (theline[0] == ')' || (curbuf->b_ind_unclosed == 0
&& is_if_for_while == 0)
@@ -2247,9 +2247,9 @@ int get_c_indent(void)
// lines).
if (theline[0] != ')') {
cur_amount = MAXCOL;
- l = (char_u *)ml_get(our_paren_pos.lnum);
+ l = ml_get(our_paren_pos.lnum);
if (curbuf->b_ind_unclosed_wrapped
- && cin_ends_in(l, (char_u *)"(", NULL)) {
+ && cin_ends_in(l, "(", NULL)) {
// look for opening unmatched paren, indent one level
// for each additional level
n = 1;
@@ -2352,7 +2352,7 @@ int get_c_indent(void)
}
// add extra indent for a comment
- if (cin_iscomment(theline)) {
+ if (cin_iscomment((char_u *)theline)) {
amount += curbuf->b_ind_comment;
}
} else {
@@ -2370,7 +2370,7 @@ int get_c_indent(void)
// If the brace was at the start of the line, we use that;
// otherwise, check out the indentation of the line as
// a whole and then add the "imaginary indent" to that.
- look = (char_u *)skipwhite((char *)start);
+ look = skipwhite((char *)start);
if (*look == '{') {
getvcol(curwin, trypos, &col, NULL, NULL);
amount = col;
@@ -2409,7 +2409,7 @@ int get_c_indent(void)
}
// For Javascript check if the line starts with "key:".
- bool js_cur_has_key = curbuf->b_ind_js ? cin_has_js_key(theline) : false;
+ bool js_cur_has_key = curbuf->b_ind_js ? cin_has_js_key((char_u *)theline) : false;
// If we're looking at a closing brace, that's where
// we want to be. Otherwise, add the amount of room
@@ -2426,7 +2426,7 @@ int get_c_indent(void)
lookfor = LOOKFOR_INITIAL;
if (cin_iselse(theline)) {
lookfor = LOOKFOR_IF;
- } else if (cin_iswhileofdo(theline, cur_curpos.lnum)) { // XXX
+ } else if (cin_iswhileofdo((char_u *)theline, cur_curpos.lnum)) { // XXX
lookfor = LOOKFOR_DO;
}
if (lookfor != LOOKFOR_INITIAL) {
@@ -2456,8 +2456,8 @@ int get_c_indent(void)
if (start_brace == BRACE_AT_END) { // '{' is at end of line
amount += curbuf->b_ind_open_imag;
- l = (char_u *)skipwhite(get_cursor_line_ptr());
- if (cin_is_cpp_namespace(l)) {
+ l = skipwhite(get_cursor_line_ptr());
+ if (cin_is_cpp_namespace((char *)l)) {
amount += curbuf->b_ind_cpp_namespace;
} else if (cin_is_cpp_extern_c(l)) {
amount += curbuf->b_ind_cpp_extern_c;
@@ -2473,10 +2473,10 @@ int get_c_indent(void)
lookfor_break = false;
- if (cin_iscase(theline, false)) { // it's a switch() label
+ if (cin_iscase((char_u *)theline, false)) { // it's a switch() label
lookfor = LOOKFOR_CASE; // find a previous switch() label
amount += curbuf->b_ind_case;
- } else if (cin_isscopedecl(theline)) { // private:, ...
+ } else if (cin_isscopedecl((char_u *)theline)) { // private:, ...
lookfor = LOOKFOR_SCOPEDECL; // class decl is this block
amount += curbuf->b_ind_scopedecl;
} else {
@@ -2529,7 +2529,7 @@ int get_c_indent(void)
break;
}
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
// If we're in a comment or raw string now, skip to
// the start of it.
@@ -2547,11 +2547,11 @@ int get_c_indent(void)
continue;
}
- if (cin_nocode(l)) {
+ if (cin_nocode((char_u *)l)) {
continue;
}
- terminated = cin_isterminated(l, false, true);
+ terminated = cin_isterminated((char_u *)l, false, true);
// If we are at top level and the line looks like a
// function declaration, we are done
@@ -2586,11 +2586,11 @@ int get_c_indent(void)
// will take us back to the start of the line.
// XXX
trypos = NULL;
- if (find_last_paren(l, '(', ')')) {
+ if (find_last_paren((char_u *)l, '(', ')')) {
trypos = find_match_paren(curbuf->b_ind_maxparen);
}
- if (trypos == NULL && find_last_paren(l, '{', '}')) {
+ if (trypos == NULL && find_last_paren((char_u *)l, '{', '}')) {
trypos = find_start_brace();
}
@@ -2640,7 +2640,7 @@ int get_c_indent(void)
break;
}
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
// If we're in a comment or raw string now, skip
// to the start of it.
@@ -2657,7 +2657,7 @@ int get_c_indent(void)
}
// Finally the actual check for "namespace".
- if (cin_is_cpp_namespace(l)) {
+ if (cin_is_cpp_namespace((char *)l)) {
amount += curbuf->b_ind_cpp_namespace
- added_to_amount;
break;
@@ -2666,7 +2666,7 @@ int get_c_indent(void)
break;
}
- if (cin_nocode(l)) {
+ if (cin_nocode((char_u *)l)) {
continue;
}
}
@@ -2683,12 +2683,12 @@ int get_c_indent(void)
continue;
}
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
// If this is a switch() label, may line up relative to that.
// If this is a C++ scope declaration, do the same.
- bool iscase = cin_iscase(l, false);
- if (iscase || cin_isscopedecl(l)) {
+ bool iscase = cin_iscase((char_u *)l, false);
+ if (iscase || cin_isscopedecl((char_u *)l)) {
// we are only looking for cpp base class
// declaration/initialization any longer
if (lookfor == LOOKFOR_CPP_BASECLASS) {
@@ -2757,7 +2757,7 @@ int get_c_indent(void)
// -> y = y + 1;
if (n) {
amount = n;
- l = after_label((char_u *)get_cursor_line_ptr());
+ l = (char *)after_label((char_u *)get_cursor_line_ptr());
if (l != NULL && cin_is_cinword((char *)l)) {
if (theline[0] == '{') {
amount += curbuf->b_ind_open_extra;
@@ -2786,7 +2786,7 @@ int get_c_indent(void)
// Looking for a switch() label or C++ scope declaration,
// ignore other lines, skip {}-blocks.
if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL) {
- if (find_last_paren(l, '{', '}')
+ if (find_last_paren((char_u *)l, '{', '}')
&& (trypos = find_start_brace()) != NULL) {
curwin->w_cursor.lnum = trypos->lnum + 1;
curwin->w_cursor.col = 0;
@@ -2796,8 +2796,8 @@ int get_c_indent(void)
// Ignore jump labels with nothing after them.
if (!curbuf->b_ind_js && cin_islabel()) {
- l = after_label((char_u *)get_cursor_line_ptr());
- if (l == NULL || cin_nocode(l)) {
+ l = (char *)after_label((char_u *)get_cursor_line_ptr());
+ if (l == NULL || cin_nocode((char_u *)l)) {
continue;
}
}
@@ -2806,9 +2806,9 @@ int get_c_indent(void)
// Ignore comment and empty lines.
// (need to get the line again, cin_islabel() may have
// unlocked it)
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)
- || cin_nocode(l)) {
+ || cin_nocode((char_u *)l)) {
continue;
}
@@ -2818,7 +2818,7 @@ int get_c_indent(void)
n = 0;
if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) {
n = cin_is_cpp_baseclass(&cache_cpp_baseclass);
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
}
if (n) {
if (lookfor == LOOKFOR_UNTERM) {
@@ -2840,7 +2840,7 @@ int get_c_indent(void)
} else if (lookfor == LOOKFOR_CPP_BASECLASS) {
// only look, whether there is a cpp base class
// declaration or initialization before the opening brace.
- if (cin_isterminated(l, true, false)) {
+ if (cin_isterminated((char_u *)l, true, false)) {
break;
} else {
continue;
@@ -2856,7 +2856,7 @@ int get_c_indent(void)
// Otherwise check whether it is an enumeration or structure
// initialisation (not indented) or a variable declaration
// (indented).
- terminated = cin_isterminated(l, false, true);
+ terminated = cin_isterminated((char_u *)l, false, true);
if (js_cur_has_key) {
js_cur_has_key = false; // only check the first line
@@ -2871,7 +2871,7 @@ int get_c_indent(void)
lookfor = LOOKFOR_JS_KEY;
}
}
- if (lookfor == LOOKFOR_JS_KEY && cin_has_js_key(l)) {
+ if (lookfor == LOOKFOR_JS_KEY && cin_has_js_key((char_u *)l)) {
amount = get_indent();
break;
}
@@ -2908,7 +2908,7 @@ int get_c_indent(void)
// Position the cursor over the rightmost paren, so that
// matching it will take us back to the start of the line.
// Ignore a match before the start of the block.
- (void)find_last_paren(l, '(', ')');
+ (void)find_last_paren((char_u *)l, '(', ')');
trypos = find_match_paren(corr_ind_maxparen(&cur_curpos));
if (trypos != NULL && (trypos->lnum < tryposBrace->lnum
|| (trypos->lnum == tryposBrace->lnum
@@ -2919,7 +2919,7 @@ int get_c_indent(void)
// If we are looking for ',', we also look for matching
// braces.
if (trypos == NULL && terminated == ','
- && find_last_paren(l, '{', '}')) {
+ && find_last_paren((char_u *)l, '{', '}')) {
trypos = find_start_brace();
}
@@ -2929,8 +2929,8 @@ int get_c_indent(void)
// case xx: if ( asdf &&
// asdf)
curwin->w_cursor = *trypos;
- l = (char_u *)get_cursor_line_ptr();
- if (cin_iscase(l, false) || cin_isscopedecl(l)) {
+ l = get_cursor_line_ptr();
+ if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l)) {
curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0;
continue;
@@ -2944,7 +2944,7 @@ int get_c_indent(void)
// here;
if (terminated == ',') {
while (curwin->w_cursor.lnum > 1) {
- l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
+ l = ml_get(curwin->w_cursor.lnum - 1);
if (*l == NUL || l[strlen((char *)l) - 1] != '\\') {
break;
}
@@ -2988,7 +2988,7 @@ int get_c_indent(void)
// Check if we are after an "if", "while", etc.
// Also allow " } else".
- if (cin_is_cinword((char *)l) || cin_iselse((char_u *)skipwhite((char *)l))) {
+ if (cin_is_cinword((char *)l) || cin_iselse(skipwhite((char *)l))) {
// Found an unterminated line after an if (), line up
// with the last one.
// if (cond)
@@ -3030,8 +3030,8 @@ int get_c_indent(void)
// do
// x = 1;
// -> here
- l = (char_u *)skipwhite(get_cursor_line_ptr());
- if (cin_isdo(l)) {
+ l = skipwhite(get_cursor_line_ptr());
+ if (cin_isdo((char *)l)) {
if (whilelevel == 0) {
break;
}
@@ -3042,13 +3042,13 @@ int get_c_indent(void)
// one between the "if" and the matching "else".
// Need to use the scope of this "else". XXX
// If whilelevel != 0 continue looking for a "do {".
- if (cin_iselse(l) && whilelevel == 0) {
+ if (cin_iselse((char *)l) && whilelevel == 0) {
// If we're looking at "} else", let's make sure we
// find the opening brace of the enclosing scope,
// not the one from "if () {".
if (*l == '}') {
curwin->w_cursor.col =
- (colnr_T)(l - (char_u *)get_cursor_line_ptr()) + 1;
+ (colnr_T)(l - get_cursor_line_ptr()) + 1;
}
if ((trypos = find_start_brace()) == NULL
@@ -3101,7 +3101,7 @@ int get_c_indent(void)
// line up with this line, remember its indent
// 100 + // NOLINT(whitespace/tab)
// -> here; // NOLINT(whitespace/tab)
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
amount = cur_amount;
n = (int)strlen((char *)l);
@@ -3202,15 +3202,15 @@ int get_c_indent(void)
// Skip single break line, if before a switch label. It
// may be lined up with the case label.
if (lookfor == LOOKFOR_NOBREAK
- && cin_isbreak((char_u *)skipwhite(get_cursor_line_ptr()))) {
+ && cin_isbreak(skipwhite(get_cursor_line_ptr()))) {
lookfor = LOOKFOR_ANY;
continue;
}
// Handle "do {" line.
if (whilelevel > 0) {
- l = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (cin_isdo(l)) {
+ l = (char *)cin_skipcomment((char_u *)get_cursor_line_ptr());
+ if (cin_isdo((char *)l)) {
amount = get_indent(); // XXX
whilelevel--;
continue;
@@ -3259,16 +3259,16 @@ int get_c_indent(void)
// asdfasdf);
// here;
term_again:
- l = (char_u *)get_cursor_line_ptr();
- if (find_last_paren(l, '(', ')')
+ l = get_cursor_line_ptr();
+ if (find_last_paren((char_u *)l, '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
// Check if we are on a case label now. This is
// handled above.
// case xx: if ( asdf &&
// asdf)
curwin->w_cursor = *trypos;
- l = (char_u *)get_cursor_line_ptr();
- if (cin_iscase(l, false) || cin_isscopedecl(l)) {
+ l = get_cursor_line_ptr();
+ if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l)) {
curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0;
continue;
@@ -3283,7 +3283,7 @@ term_again:
// case 2:
// stat;
// }
- iscase = curbuf->b_ind_keep_case_label && cin_iscase(l, false);
+ iscase = curbuf->b_ind_keep_case_label && cin_iscase((char_u *)l, false);
// Get indent and pointer to text for current line,
// ignoring any jump label.
@@ -3293,7 +3293,7 @@ term_again:
amount += curbuf->b_ind_open_extra;
}
// See remark above: "Only add b_ind_open_extra.."
- l = (char_u *)skipwhite((char *)l);
+ l = skipwhite((char *)l);
if (*l == '{') {
amount -= curbuf->b_ind_open_extra;
}
@@ -3307,7 +3307,7 @@ term_again:
// If whilelevel != 0 continue looking for a "do {".
if (lookfor == LOOKFOR_TERM
&& *l != '}'
- && cin_iselse(l)
+ && cin_iselse((char *)l)
&& whilelevel == 0) {
if ((trypos = find_start_brace()) == NULL
|| find_match(LOOKFOR_IF, trypos->lnum)
@@ -3319,14 +3319,14 @@ term_again:
// If we're at the end of a block, skip to the start of
// that block.
- l = (char_u *)get_cursor_line_ptr();
- if (find_last_paren(l, '{', '}') // XXX
+ l = get_cursor_line_ptr();
+ if (find_last_paren((char_u *)l, '{', '}') // XXX
&& (trypos = find_start_brace()) != NULL) {
curwin->w_cursor = *trypos;
// if not "else {" check for terminated again
// but skip block for "} else {"
- l = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (*l == '}' || !cin_iselse(l)) {
+ l = (char *)cin_skipcomment((char_u *)get_cursor_line_ptr());
+ if (*l == '}' || !cin_iselse((char *)l)) {
goto term_again;
}
curwin->w_cursor.lnum++;
@@ -3339,7 +3339,7 @@ term_again:
}
// add extra indent for a comment
- if (cin_iscomment(theline)) {
+ if (cin_iscomment((char_u *)theline)) {
amount += curbuf->b_ind_comment;
}
// subtract extra left-shift for jump labels
@@ -3371,13 +3371,13 @@ term_again:
// current line is terminated, ie. ends in ';', or if the current line
// contains { or }: "void f() {\n if (1)"
if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
- && !cin_nocode(theline)
- && vim_strchr((char *)theline, '{') == NULL
- && vim_strchr((char *)theline, '}') == NULL
- && !cin_ends_in(theline, (char_u *)":", NULL)
- && !cin_ends_in(theline, (char_u *)",", NULL)
+ && !cin_nocode((char_u *)theline)
+ && vim_strchr(theline, '{') == NULL
+ && vim_strchr(theline, '}') == NULL
+ && !cin_ends_in(theline, ":", NULL)
+ && !cin_ends_in(theline, ",", NULL)
&& cin_isfuncdecl(NULL, cur_curpos.lnum + 1, cur_curpos.lnum + 1)
- && !cin_isterminated(theline, false, true)) {
+ && !cin_isterminated((char_u *)theline, false, true)) {
amount = curbuf->b_ind_func_type;
goto theend;
}
@@ -3389,7 +3389,7 @@ term_again:
curwin->w_cursor.lnum--;
curwin->w_cursor.col = 0;
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
// If we're in a comment or raw string now, skip to the start
// of it.
@@ -3405,7 +3405,7 @@ term_again:
n = 0;
if (curbuf->b_ind_cpp_baseclass != 0) {
n = cin_is_cpp_baseclass(&cache_cpp_baseclass);
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
}
if (n) {
// XXX
@@ -3420,7 +3420,7 @@ term_again:
continue;
}
- if (cin_nocode(l)) {
+ if (cin_nocode((char_u *)l)) {
continue;
}
@@ -3434,10 +3434,10 @@ term_again:
// ...
// } foo,
// bar;
- if (cin_ends_in(l, (char_u *)",", NULL)
- || (*l != NUL && (n = l[strlen((char *)l) - 1]) == '\\')) {
+ if (cin_ends_in(l, ",", NULL)
+ || (*l != NUL && (n = (uint8_t)l[strlen((char *)l) - 1]) == '\\')) {
// take us back to opening paren
- if (find_last_paren(l, '(', ')')
+ if (find_last_paren((char_u *)l, '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
curwin->w_cursor = *trypos;
}
@@ -3448,7 +3448,7 @@ term_again:
// bla",
// here;
while (n == 0 && curwin->w_cursor.lnum > 1) {
- l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
+ l = ml_get(curwin->w_cursor.lnum - 1);
if (*l == NUL || l[strlen((char *)l) - 1] != '\\') {
break;
}
@@ -3472,7 +3472,7 @@ term_again:
if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) { // XXX
break;
}
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
// Finding the closing '}' of a previous function. Put
// current line at the left margin. For when 'cino' has "fs".
@@ -3485,7 +3485,7 @@ term_again:
// comments) align at column 0. For example:
// char *string_array[] = { "foo",
// / * x * / "b};ar" }; / * foobar * /
- if (cin_ends_in(l, (char_u *)"};", NULL)) {
+ if (cin_ends_in(l, "};", NULL)) {
break;
}
@@ -3493,7 +3493,7 @@ term_again:
// array constant:
// something = [
// 234, <- extra indent
- if (cin_ends_in(l, (char_u *)"[", NULL)) {
+ if (cin_ends_in(l, "[", NULL)) {
amount = get_indent() + ind_continuation;
break;
}
@@ -3501,18 +3501,18 @@ term_again:
// Find a line only has a semicolon that belongs to a previous
// line ending in '}', e.g. before an #endif. Don't increase
// indent then.
- if (*(look = (char_u *)skipwhite((char *)l)) == ';' && cin_nocode(look + 1)) {
+ if (*(look = skipwhite((char *)l)) == ';' && cin_nocode((char_u *)look + 1)) {
pos_T curpos_save = curwin->w_cursor;
while (curwin->w_cursor.lnum > 1) {
- look = (char_u *)ml_get(--curwin->w_cursor.lnum);
- if (!(cin_nocode(look)
+ look = ml_get(--curwin->w_cursor.lnum);
+ if (!(cin_nocode((char_u *)look)
|| cin_ispreproc_cont(&look, &curwin->w_cursor.lnum, &amount))) {
break;
}
}
if (curwin->w_cursor.lnum > 0
- && cin_ends_in(look, (char_u *)"}", NULL)) {
+ && cin_ends_in(look, "}", NULL)) {
break;
}
@@ -3532,13 +3532,13 @@ term_again:
// int foo,
// bar;
// indent_to_0 here;
- if (cin_ends_in(l, (char_u *)";", NULL)) {
- l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
- if (cin_ends_in(l, (char_u *)",", NULL)
+ if (cin_ends_in(l, ";", NULL)) {
+ l = ml_get(curwin->w_cursor.lnum - 1);
+ if (cin_ends_in(l, ",", NULL)
|| (*l != NUL && l[strlen((char *)l) - 1] == '\\')) {
break;
}
- l = (char_u *)get_cursor_line_ptr();
+ l = get_cursor_line_ptr();
}
// Doesn't look like anything interesting -- so just
@@ -3546,7 +3546,7 @@ term_again:
//
// Position the cursor over the rightmost paren, so that
// matching it will take us back to the start of the line.
- (void)find_last_paren(l, '(', ')');
+ (void)find_last_paren((char_u *)l, '(', ')');
if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
curwin->w_cursor = *trypos;
@@ -3556,7 +3556,7 @@ term_again:
}
// add extra indent for a comment
- if (cin_iscomment(theline)) {
+ if (cin_iscomment((char_u *)theline)) {
amount += curbuf->b_ind_comment;
}
@@ -3566,7 +3566,7 @@ term_again:
// char *foo = "asdf{backslash}
// here";
if (cur_curpos.lnum > 1) {
- l = (char_u *)ml_get(cur_curpos.lnum - 1);
+ l = ml_get(cur_curpos.lnum - 1);
if (*l != NUL && l[strlen((char *)l) - 1] == '\\') {
cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1);
if (cur_amount > 0) {
@@ -3614,9 +3614,9 @@ static int find_match(int lookfor, linenr_T ourscope)
curwin->w_cursor.col = 0;
look = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (!cin_iselse(look)
- && !cin_isif(look)
- && !cin_isdo(look) // XXX
+ if (!cin_iselse((char *)look)
+ && !cin_isif((char *)look)
+ && !cin_isdo((char *)look) // XXX
&& !cin_iswhileofdo(look, curwin->w_cursor.lnum)) {
continue;
}
@@ -3646,9 +3646,9 @@ static int find_match(int lookfor, linenr_T ourscope)
// then we need to go back to another if, so
// increment elselevel
look = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (cin_iselse(look)) {
+ if (cin_iselse((char *)look)) {
mightbeif = cin_skipcomment(look + 4);
- if (!cin_isif(mightbeif)) {
+ if (!cin_isif((char *)mightbeif)) {
elselevel++; // NOLINT(readability/braces)
}
continue;
@@ -3663,7 +3663,7 @@ static int find_match(int lookfor, linenr_T ourscope)
// If it's an "if" decrement elselevel
look = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (cin_isif(look)) {
+ if (cin_isif((char *)look)) {
elselevel--; // NOLINT(readability/braces)
// When looking for an "if" ignore "while"s that
// get in the way.
@@ -3673,7 +3673,7 @@ static int find_match(int lookfor, linenr_T ourscope)
}
// If it's a "do" decrement whilelevel
- if (cin_isdo(look)) {
+ if (cin_isdo((char *)look)) {
whilelevel--;
}
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 0db05d482b..222d3228ba 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -893,7 +893,7 @@ static int ins_compl_add(char *const str, int len, char *const fname, char *cons
/// @param match completion match
/// @param str character string to check
/// @param len length of "str"
-static bool ins_compl_equal(compl_T *match, char_u *str, size_t len)
+static bool ins_compl_equal(compl_T *match, char *str, size_t len)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
if (match->cp_flags & CP_EQUAL) {
@@ -902,7 +902,7 @@ static bool ins_compl_equal(compl_T *match, char_u *str, size_t len)
if (match->cp_flags & CP_ICASE) {
return STRNICMP(match->cp_str, str, len) == 0;
}
- return STRNCMP(match->cp_str, str, len) == 0;
+ return strncmp(match->cp_str, str, len) == 0;
}
/// Reduce the longest common string for match "match".
@@ -1151,7 +1151,7 @@ static int ins_compl_build_pum(void)
do {
if (!match_at_original_text(compl)
&& (compl_leader == NULL
- || ins_compl_equal(compl, (char_u *)compl_leader, (size_t)lead_len))) {
+ || ins_compl_equal(compl, compl_leader, (size_t)lead_len))) {
compl_match_arraysize++;
}
compl = compl->cp_next;
@@ -1176,7 +1176,7 @@ static int ins_compl_build_pum(void)
do {
if (!match_at_original_text(compl)
&& (compl_leader == NULL
- || ins_compl_equal(compl, (char_u *)compl_leader, (size_t)lead_len))) {
+ || ins_compl_equal(compl, compl_leader, (size_t)lead_len))) {
if (!shown_match_ok) {
if (compl == compl_shown_match || did_find_shown_match) {
// This item is the shown match or this is the
@@ -1823,7 +1823,7 @@ void ins_compl_addfrommatch(void)
for (cp = compl_shown_match->cp_next; cp != NULL
&& !is_first_match(cp); cp = cp->cp_next) {
if (compl_leader == NULL
- || ins_compl_equal(cp, (char_u *)compl_leader, strlen(compl_leader))) {
+ || ins_compl_equal(cp, compl_leader, strlen(compl_leader))) {
p = cp->cp_str;
break;
}
@@ -3404,7 +3404,7 @@ static int ins_compl_get_exp(pos_T *ini)
static void ins_compl_update_shown_match(void)
{
while (!ins_compl_equal(compl_shown_match,
- (char_u *)compl_leader, strlen(compl_leader))
+ compl_leader, strlen(compl_leader))
&& compl_shown_match->cp_next != NULL
&& !is_first_match(compl_shown_match->cp_next)) {
compl_shown_match = compl_shown_match->cp_next;
@@ -3413,10 +3413,10 @@ static void ins_compl_update_shown_match(void)
// If we didn't find it searching forward, and compl_shows_dir is
// backward, find the last match.
if (compl_shows_dir_backward()
- && !ins_compl_equal(compl_shown_match, (char_u *)compl_leader, strlen(compl_leader))
+ && !ins_compl_equal(compl_shown_match, compl_leader, strlen(compl_leader))
&& (compl_shown_match->cp_next == NULL
|| is_first_match(compl_shown_match->cp_next))) {
- while (!ins_compl_equal(compl_shown_match, (char_u *)compl_leader, strlen(compl_leader))
+ while (!ins_compl_equal(compl_shown_match, compl_leader, strlen(compl_leader))
&& compl_shown_match->cp_prev != NULL
&& !is_first_match(compl_shown_match->cp_prev)) {
compl_shown_match = compl_shown_match->cp_prev;
@@ -3561,7 +3561,7 @@ static int find_next_completion_match(bool allow_get_expansion, int todo, bool a
if (!match_at_original_text(compl_shown_match)
&& compl_leader != NULL
&& !ins_compl_equal(compl_shown_match,
- (char_u *)compl_leader, strlen(compl_leader))) {
+ compl_leader, strlen(compl_leader))) {
todo++;
} else {
// Remember a matching item.
diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c
index 90539d5578..f3795ab276 100644
--- a/src/nvim/keycodes.c
+++ b/src/nvim/keycodes.c
@@ -570,7 +570,7 @@ char_u *get_special_key_name(int c, int modifiers)
/// @param[out] did_simplify found <C-H>, etc.
///
/// @return Number of characters added to dst, zero for no match.
-unsigned int trans_special(const char_u **const srcp, const size_t src_len, char_u *const dst,
+unsigned int trans_special(const char **const srcp, const size_t src_len, char_u *const dst,
const int flags, const bool escape_ks, bool *const did_simplify)
FUNC_ATTR_NONNULL_ARG(1, 3) FUNC_ATTR_WARN_UNUSED_RESULT
{
@@ -623,7 +623,7 @@ unsigned int special_to_buf(int key, int modifiers, bool escape_ks, char_u *dst)
/// @param[out] did_simplify FSK_SIMPLIFY and found <C-H>, etc.
///
/// @return Key and modifiers or 0 if there is no match.
-int find_special_key(const char_u **const srcp, const size_t src_len, int *const modp,
+int find_special_key(const char **const srcp, const size_t src_len, int *const modp,
const int flags, bool *const did_simplify)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1, 3)
{
@@ -631,7 +631,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
const char_u *end_of_name;
const char_u *src;
const char_u *bp;
- const char_u *const end = *srcp + src_len - 1;
+ const char_u *const end = (char_u *)(*srcp) + src_len - 1;
const bool in_string = flags & FSK_IN_STRING;
int modifiers;
int bit;
@@ -643,7 +643,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
return 0;
}
- src = *srcp;
+ src = (char_u *)(*srcp);
if (src[0] != '<') {
return 0;
}
@@ -751,7 +751,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
}
*modp = modifiers;
- *srcp = end_of_name;
+ *srcp = (char *)end_of_name;
return key;
} // else { ELOG("unknown key: '%s'", src); }
}
@@ -885,10 +885,10 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
{
ssize_t i;
size_t slen;
- char_u key;
+ char key;
size_t dlen = 0;
- const char_u *src;
- const char_u *const end = (char_u *)from + from_len - 1;
+ const char *src;
+ const char *const end = from + from_len - 1;
char *result; // buffer for resulting string
const bool do_backslash = !(cpo_flags & FLAG_CPO_BSLASH); // backslash is a special character
@@ -901,7 +901,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
const size_t buf_len = allocated ? from_len * 6 + 1 : 128;
result = allocated ? xmalloc(buf_len) : *bufp;
- src = (char_u *)from;
+ src = from;
// Check for #n at start only: function key n
if ((flags & REPTERM_FROM_PART) && from_len > 1 && src[0] == '#'
@@ -911,7 +911,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
if (src[1] == '0') {
result[dlen++] = ';'; // #0 is F10 is "k;"
} else {
- result[dlen++] = (char)src[1]; // #3 is F3 is "k3"
+ result[dlen++] = src[1]; // #3 is F3 is "k3"
}
src += 2;
}
@@ -923,7 +923,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
}
// Check for special <> keycodes, like "<C-S-LeftMouse>"
if (do_special && ((flags & REPTERM_DO_LT) || ((end - src) >= 3
- && STRNCMP(src, "<lt>", 4) != 0))) {
+ && strncmp(src, "<lt>", 4) != 0))) {
// Replace <SID> by K_SNR <script-nr> _.
// (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14)
if (end - src >= 4 && STRNICMP(src, "<SID>", 5) == 0) {
@@ -993,7 +993,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
src++; // skip CTRL-V or backslash
if (src > end) {
if (flags & REPTERM_FROM_PART) {
- result[dlen++] = (char)key;
+ result[dlen++] = key;
}
break;
}
@@ -1003,12 +1003,12 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
for (i = utfc_ptr2len_len((char *)src, (int)(end - src) + 1); i > 0; i--) {
// If the character is K_SPECIAL, replace it with K_SPECIAL
// KS_SPECIAL KE_FILLER.
- if (*src == K_SPECIAL) {
+ if (*src == (char)K_SPECIAL) {
result[dlen++] = (char)K_SPECIAL;
result[dlen++] = (char)KS_SPECIAL;
result[dlen++] = KE_FILLER;
} else {
- result[dlen++] = (char)(*src);
+ result[dlen++] = *src;
}
src++;
}
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index 07f6a211e4..3522e0de36 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -158,7 +158,7 @@ static void showmap(mapblock_T *mp, bool local)
{
size_t len = 1;
- if (message_filtered((char *)mp->m_keys) && message_filtered(mp->m_str)
+ if (message_filtered(mp->m_keys) && message_filtered(mp->m_str)
&& (mp->m_desc == NULL || message_filtered(mp->m_desc))) {
return;
}
@@ -182,7 +182,7 @@ static void showmap(mapblock_T *mp, bool local)
}
// Display the LHS. Get length of what we write.
- len = (size_t)msg_outtrans_special((char *)mp->m_keys, true, 0);
+ len = (size_t)msg_outtrans_special(mp->m_keys, true, 0);
do {
msg_putchar(' '); // pad with blanks
len++;
@@ -462,7 +462,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
}
}
- mp->m_keys = (uint8_t *)xstrdup(keys);
+ mp->m_keys = xstrdup(keys);
mp->m_str = args->rhs;
mp->m_orig_str = (char *)args->orig_rhs;
mp->m_luaref = args->rhs_lua;
@@ -471,7 +471,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
args->orig_rhs = NULL;
args->rhs_lua = LUA_NOREF;
}
- mp->m_keylen = (int)strlen((char *)mp->m_keys);
+ mp->m_keylen = (int)strlen(mp->m_keys);
mp->m_noremap = noremap;
mp->m_nowait = args->nowait;
mp->m_silent = args->silent;
@@ -497,7 +497,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
mp->m_next = *abbr_table;
*abbr_table = mp;
} else {
- const int n = MAP_HASH(mp->m_mode, mp->m_keys[0]);
+ const int n = MAP_HASH(mp->m_mode, (uint8_t)mp->m_keys[0]);
mp->m_next = map_table[n];
map_table[n] = mp;
}
@@ -516,7 +516,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T *buf)
{
mapblock_T *mp, **mpp;
- const char_u *p;
+ const char *p;
int n;
int retval = 0;
mapblock_T **abbr_table;
@@ -553,7 +553,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
goto theend;
}
- const char_u *lhs = (char_u *)&args->lhs;
+ const char *lhs = (char *)&args->lhs;
const bool did_simplify = args->alt_lhs_len != 0;
// The following is done twice if we have two versions of keys
@@ -567,11 +567,11 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
if (!did_simplify) {
break;
}
- lhs = (char_u *)&args->alt_lhs;
+ lhs = (char *)&args->alt_lhs;
len = (int)args->alt_lhs_len;
} else if (did_simplify && do_print) {
// when printing always use the not-simplified map
- lhs = (char_u *)&args->alt_lhs;
+ lhs = (char *)&args->alt_lhs;
len = (int)args->alt_lhs_len;
}
@@ -589,13 +589,13 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
// vi-compatible way.
int same = -1;
- const int first = vim_iswordp(lhs);
+ const int first = vim_iswordp((char_u *)lhs);
int last = first;
- p = lhs + utfc_ptr2len((char *)lhs);
+ p = (char *)lhs + utfc_ptr2len((char *)lhs);
n = 1;
- while (p < lhs + len) {
+ while (p < (char *)lhs + len) {
n++; // nr of (multi-byte) chars
- last = vim_iswordp(p); // type of last char
+ last = vim_iswordp((char_u *)p); // type of last char
if (same == -1 && last != first) {
same = n - 1; // count of same char type
}
@@ -640,7 +640,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
// check entries with the same mode
if ((mp->m_mode & mode) != 0
&& mp->m_keylen == len
- && STRNCMP(mp->m_keys, lhs, (size_t)len) == 0) {
+ && strncmp(mp->m_keys, lhs, (size_t)len) == 0) {
if (is_abbrev) {
semsg(_("E224: global abbreviation already exists for %s"),
mp->m_keys);
@@ -674,7 +674,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
did_local = true;
} else {
n = mp->m_keylen;
- if (STRNCMP(mp->m_keys, lhs, (size_t)(n < len ? n : len)) == 0) {
+ if (strncmp(mp->m_keys, lhs, (size_t)(n < len ? n : len)) == 0) {
showmap(mp, true);
did_local = true;
}
@@ -695,7 +695,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
int hash_start, hash_end;
if (has_lhs || is_abbrev) {
// just use one hash
- hash_start = is_abbrev ? 0 : MAP_HASH(mode, lhs[0]);
+ hash_start = is_abbrev ? 0 : MAP_HASH(mode, (uint8_t)lhs[0]);
hash_end = hash_start + 1;
} else {
// need to loop over all hash lists
@@ -718,12 +718,12 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
} else { // do we have a match?
if (round) { // second round: Try unmap "rhs" string
n = (int)strlen(mp->m_str);
- p = (char_u *)mp->m_str;
+ p = mp->m_str;
} else {
n = mp->m_keylen;
p = mp->m_keys;
}
- if (STRNCMP(p, lhs, (size_t)(n < len ? n : len)) == 0) {
+ if (strncmp(p, lhs, (size_t)(n < len ? n : len)) == 0) {
if (maptype == MAPTYPE_UNMAP) {
// Delete entry.
// Only accept a full match. For abbreviations
@@ -805,7 +805,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
}
// May need to put this entry into another hash list.
- int new_hash = MAP_HASH(mp->m_mode, mp->m_keys[0]);
+ int new_hash = MAP_HASH(mp->m_mode, (uint8_t)mp->m_keys[0]);
if (!is_abbrev && new_hash != hash) {
*mpp = mp->m_next;
mp->m_next = map_table[new_hash];
@@ -1032,7 +1032,7 @@ void map_clear_mode(buf_T *buf, int mode, bool local, bool abbr)
continue;
}
// May need to put this entry into another hash list.
- new_hash = MAP_HASH(mp->m_mode, mp->m_keys[0]);
+ new_hash = MAP_HASH(mp->m_mode, (uint8_t)mp->m_keys[0]);
if (!abbr && new_hash != hash) {
*mpp = mp->m_next;
if (local) {
@@ -1325,7 +1325,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char ***file)
}
for (; mp; mp = mp->m_next) {
if (mp->m_mode & expand_mapmodes) {
- p = (char *)translate_mapping(mp->m_keys, CPO_TO_CPO_FLAGS);
+ p = (char *)translate_mapping((char_u *)mp->m_keys, CPO_TO_CPO_FLAGS);
if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) {
if (round == 1) {
count++;
@@ -1387,7 +1387,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char ***file)
// Then there must be white space before the abbr.
//
// Return true if there is an abbreviation, false if not.
-bool check_abbr(int c, char_u *ptr, int col, int mincol)
+bool check_abbr(int c, char *ptr, int col, int mincol)
{
int len;
int scol; // starting column of the abbr.
@@ -1418,25 +1418,25 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
{
bool vim_abbr;
- char_u *p = mb_prevptr(ptr, ptr + col);
+ char_u *p = mb_prevptr((char_u *)ptr, (char_u *)ptr + col);
if (!vim_iswordp(p)) {
vim_abbr = true; // Vim added abbr.
} else {
vim_abbr = false; // vi compatible abbr.
- if (p > ptr) {
- is_id = vim_iswordp(mb_prevptr(ptr, p));
+ if (p > (char_u *)ptr) {
+ is_id = vim_iswordp(mb_prevptr((char_u *)ptr, p));
}
}
clen = 1;
- while (p > ptr + mincol) {
- p = mb_prevptr(ptr, p);
+ while (p > (char_u *)ptr + mincol) {
+ p = mb_prevptr((char_u *)ptr, p);
if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) {
p += utfc_ptr2len((char *)p);
break;
}
clen++;
}
- scol = (int)(p - ptr);
+ scol = (int)(p - (char_u *)ptr);
}
if (scol < mincol) {
@@ -1455,20 +1455,20 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
mp->m_next == NULL ? (mp = mp2, mp2 = NULL) :
(mp = mp->m_next)) {
int qlen = mp->m_keylen;
- char *q = (char *)mp->m_keys;
+ char *q = mp->m_keys;
int match;
if (strchr((const char *)mp->m_keys, K_SPECIAL) != NULL) {
// Might have K_SPECIAL escaped mp->m_keys.
- q = xstrdup((char *)mp->m_keys);
+ q = xstrdup(mp->m_keys);
vim_unescape_ks((char_u *)q);
qlen = (int)strlen(q);
}
// find entries with right mode and keys
match = (mp->m_mode & State)
&& qlen == len
- && !STRNCMP(q, ptr, (size_t)len);
- if (q != (char *)mp->m_keys) {
+ && !strncmp(q, ptr, (size_t)len);
+ if (q != mp->m_keys) {
xfree(q);
}
if (match) {
@@ -1797,7 +1797,7 @@ int makemap(FILE *fd, buf_T *buf)
}
if (putc(' ', fd) < 0
- || put_escstr(fd, mp->m_keys, 0) == FAIL
+ || put_escstr(fd, (char_u *)mp->m_keys, 0) == FAIL
|| putc(' ', fd) < 0
|| put_escstr(fd, (char_u *)mp->m_str, 1) == FAIL
|| put_eol(fd) < 0) {
@@ -1954,15 +1954,15 @@ char *check_map(char *keys, int mode, int exact, int ign_mod, int abbr, mapblock
for (; mp != NULL; mp = mp->m_next) {
// skip entries with wrong mode, wrong length and not matching ones
if ((mp->m_mode & mode) && (!exact || mp->m_keylen == len)) {
- char_u *s = mp->m_keys;
+ char *s = mp->m_keys;
int keylen = mp->m_keylen;
if (ign_mod && keylen >= 3
- && s[0] == K_SPECIAL && s[1] == KS_MODIFIER) {
+ && (uint8_t)s[0] == K_SPECIAL && (uint8_t)s[1] == KS_MODIFIER) {
s += 3;
keylen -= 3;
}
minlen = keylen < len ? keylen : len;
- if (STRNCMP(s, keys, minlen) == 0) {
+ if (strncmp(s, keys, (size_t)minlen) == 0) {
if (mp_ptr != NULL) {
*mp_ptr = mp;
}
@@ -2015,7 +2015,7 @@ static Dictionary mapblock_fill_dict(const mapblock_T *const mp, const char *lhs
FUNC_ATTR_NONNULL_ARG(1)
{
Dictionary dict = ARRAY_DICT_INIT;
- char *const lhs = str2special_save((const char *)mp->m_keys, compatible, !compatible);
+ char *const lhs = str2special_save(mp->m_keys, compatible, !compatible);
char *const mapmode = map_mode_to_chars(mp->m_mode);
varnumber_T noremap_value;
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index dac7e6f90b..d6fa1f5a16 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -2751,7 +2751,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar)
return FAIL;
}
assert(len <= INT_MAX);
- spell_add_word((char_u *)ptr, (int)len,
+ spell_add_word(ptr, (int)len,
nchar == 'w' || nchar == 'W' ? SPELL_ADD_BAD : SPELL_ADD_GOOD,
(nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1,
undo);
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 6cc919a1c6..1a6707f128 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -3108,12 +3108,12 @@ bool is_string_option(const char *name)
int find_key_option_len(const char_u *arg_arg, size_t len, bool has_lt)
{
int key = 0;
- const char_u *arg = arg_arg;
+ const char *arg = (char *)arg_arg;
// Don't use get_special_key_code() for t_xx, we don't want it to call
// add_termcap_entry().
if (len >= 4 && arg[0] == 't' && arg[1] == '_') {
- key = TERMCAP2KEY(arg[2], arg[3]);
+ key = TERMCAP2KEY((uint8_t)arg[2], (uint8_t)arg[3]);
} else if (has_lt) {
arg--; // put arg at the '<'
int modifiers = 0;
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index d6afb1b62a..5d2ac1e102 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -266,7 +266,7 @@ size_t input_enqueue(String keys)
uint8_t buf[19] = { 0 };
// Do not simplify the keys here. Simplification will be done later.
unsigned int new_size
- = trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, FSK_KEYCODE, true, NULL);
+ = trans_special((const char **)&ptr, (size_t)(end - ptr), buf, FSK_KEYCODE, true, NULL);
if (new_size) {
new_size = handle_mouse_event(&ptr, buf, new_size);
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index c1359d6ece..d647780847 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -144,7 +144,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
bool is_fish_shell =
#if defined(UNIX)
- STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
+ strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
#else
false;
#endif
diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c
index 1865d6789e..57dc2eb797 100644
--- a/src/nvim/os/users.c
+++ b/src/nvim/os/users.c
@@ -222,7 +222,7 @@ int match_user(char *name)
if (strcmp(((char **)ga_users.ga_data)[i], name) == 0) {
return 2; // full match
}
- if (STRNCMP(((char_u **)ga_users.ga_data)[i], name, n) == 0) {
+ if (strncmp(((char **)ga_users.ga_data)[i], name, (size_t)n) == 0) {
result = 1; // partial match
}
}
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 7335345161..aa5bcbc404 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -233,7 +233,7 @@ static int get_char_class(char **pp)
if ((*pp)[1] == ':') {
for (i = 0; i < (int)ARRAY_SIZE(class_names); i++) {
- if (STRNCMP(*pp + 2, class_names[i], strlen(class_names[i])) == 0) {
+ if (strncmp(*pp + 2, class_names[i], strlen(class_names[i])) == 0) {
*pp += strlen(class_names[i]) + 2;
return i;
}
@@ -1380,7 +1380,7 @@ static int cstrncmp(char *s1, char *s2, int *n)
int result;
if (!rex.reg_ic) {
- result = STRNCMP(s1, s2, *n);
+ result = strncmp(s1, s2, (size_t)(*n));
} else {
assert(*n >= 0);
result = mb_strnicmp(s1, s2, (size_t)(*n));
@@ -2303,12 +2303,12 @@ static char_u regname[][30] = {
regprog_T *vim_regcomp(char *expr_arg, int re_flags)
{
regprog_T *prog = NULL;
- char_u *expr = (char_u *)expr_arg;
+ char *expr = expr_arg;
regexp_engine = (int)p_re;
// Check for prefix "\%#=", that sets the regexp engine
- if (STRNCMP(expr, "\\%#=", 4) == 0) {
+ if (strncmp(expr, "\\%#=", 4) == 0) {
int newengine = expr[4] - '0';
if (newengine == AUTOMATIC_ENGINE
@@ -2338,10 +2338,10 @@ regprog_T *vim_regcomp(char *expr_arg, int re_flags)
//
const int called_emsg_before = called_emsg;
if (regexp_engine != BACKTRACKING_ENGINE) {
- prog = nfa_regengine.regcomp(expr,
+ prog = nfa_regengine.regcomp((char_u *)expr,
re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0));
} else {
- prog = bt_regengine.regcomp(expr, re_flags);
+ prog = bt_regengine.regcomp((char_u *)expr, re_flags);
}
// Check for error compiling regexp with initial engine.
@@ -2365,8 +2365,8 @@ regprog_T *vim_regcomp(char *expr_arg, int re_flags)
// But don't try if an error message was given.
if (regexp_engine == AUTOMATIC_ENGINE && called_emsg == called_emsg_before) {
regexp_engine = BACKTRACKING_ENGINE;
- report_re_switch(expr);
- prog = bt_regengine.regcomp(expr, re_flags);
+ report_re_switch((char_u *)expr);
+ prog = bt_regengine.regcomp((char_u *)expr, re_flags);
}
}
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 13a0526fd2..995522b51e 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -130,7 +130,7 @@ typedef struct matchinf_S {
langp_T *mi_lp; // info for language and region
// pointers to original text to be checked
- char_u *mi_word; // start of word being checked
+ char *mi_word; // start of word being checked
char_u *mi_end; // end of matching word so far
char_u *mi_fend; // next char to be added to mi_fword
char_u *mi_cend; // char after what was used for
@@ -173,7 +173,7 @@ typedef struct spelload_S {
#define SY_MAXLEN 30
typedef struct syl_item_S {
- char_u sy_chars[SY_MAXLEN]; // the sequence of chars
+ char sy_chars[SY_MAXLEN]; // the sequence of chars
int sy_len;
} syl_item_T;
@@ -252,7 +252,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
}
// Find the normal end of the word (until the next non-word character).
- mi.mi_word = ptr;
+ mi.mi_word = (char *)ptr;
mi.mi_fend = ptr;
if (spell_iswordp(mi.mi_fend, wp)) {
bool this_upper = false; // init for gcc
@@ -387,7 +387,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
// at which any word would be valid.
mi.mi_lp = LANGP_ENTRY(wp->w_s->b_langp, 0);
if (mi.mi_lp->lp_slang->sl_fidxs != NULL) {
- p = mi.mi_word;
+ p = (char_u *)mi.mi_word;
fp = (char_u *)mi.mi_fword;
for (;;) {
MB_PTR_ADV(p);
@@ -435,7 +435,7 @@ static void find_word(matchinf_T *mip, int mode)
{
int wlen = 0;
int flen;
- char_u *ptr;
+ char *ptr;
slang_T *slang = mip->mi_lp->lp_slang;
char_u *byts;
idx_T *idxs;
@@ -453,7 +453,7 @@ static void find_word(matchinf_T *mip, int mode)
}
} else {
// Check for case-folded in case-folded tree.
- ptr = (char_u *)mip->mi_fword;
+ ptr = mip->mi_fword;
flen = mip->mi_fwordlen; // available case-folded bytes
byts = slang->sl_fbyts;
idxs = slang->sl_fidxs;
@@ -518,7 +518,7 @@ static void find_word(matchinf_T *mip, int mode)
}
// Perform a binary search in the list of accepted bytes.
- c = ptr[wlen];
+ c = (uint8_t)ptr[wlen];
if (c == TAB) { // <Tab> is handled like <Space>
c = ' ';
}
@@ -562,7 +562,7 @@ static void find_word(matchinf_T *mip, int mode)
}
}
- char_u *p;
+ char *p;
bool word_ends;
// Verify that one of the possible endings is valid. Try the longest
@@ -572,10 +572,10 @@ static void find_word(matchinf_T *mip, int mode)
arridx = endidx[endidxcnt];
wlen = endlen[endidxcnt];
- if (utf_head_off((char *)ptr, (char *)ptr + wlen) > 0) {
+ if (utf_head_off(ptr, ptr + wlen) > 0) {
continue; // not at first byte of character
}
- if (spell_iswordp(ptr + wlen, mip->mi_win)) {
+ if (spell_iswordp((char_u *)ptr + wlen, mip->mi_win)) {
if (slang->sl_compprog == NULL && !slang->sl_nobreak) {
continue; // next char is a word character
}
@@ -592,8 +592,8 @@ static void find_word(matchinf_T *mip, int mode)
// when folding case. This can be slow, take a shortcut when the
// case-folded word is equal to the keep-case word.
p = mip->mi_word;
- if (STRNCMP(ptr, p, wlen) != 0) {
- for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
+ if (strncmp(ptr, p, (size_t)wlen) != 0) {
+ for (char *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
MB_PTR_ADV(p);
}
wlen = (int)(p - mip->mi_word);
@@ -612,11 +612,11 @@ static void find_word(matchinf_T *mip, int mode)
// For keep-case tree the case is always right. For prefixes we
// don't bother to check.
if (mode == FIND_FOLDWORD) {
- if (mip->mi_cend != mip->mi_word + wlen) {
+ if (mip->mi_cend != (char_u *)mip->mi_word + wlen) {
// mi_capflags was set for a different word length, need
// to do it again.
- mip->mi_cend = mip->mi_word + wlen;
- mip->mi_capflags = captype(mip->mi_word, mip->mi_cend);
+ mip->mi_cend = (char_u *)mip->mi_word + wlen;
+ mip->mi_capflags = captype((char_u *)mip->mi_word, mip->mi_cend);
}
if (mip->mi_capflags == WF_KEEPCAP
@@ -629,7 +629,7 @@ static void find_word(matchinf_T *mip, int mode)
// mip->mi_prefarridx that find_prefix() filled.
c = valid_word_prefix(mip->mi_prefcnt, mip->mi_prefarridx,
(int)flags,
- mip->mi_word + mip->mi_cprefixlen, slang,
+ (char_u *)mip->mi_word + mip->mi_cprefixlen, slang,
false);
if (c == 0) {
continue;
@@ -664,7 +664,7 @@ static void find_word(matchinf_T *mip, int mode)
// For multi-byte chars check character length against
// COMPOUNDMIN.
if (slang->sl_compminlen > 0
- && mb_charlen_len(mip->mi_word + mip->mi_compoff,
+ && mb_charlen_len((char_u *)mip->mi_word + mip->mi_compoff,
wlen - mip->mi_compoff) < slang->sl_compminlen) {
continue;
}
@@ -703,16 +703,16 @@ static void find_word(matchinf_T *mip, int mode)
// Need to check the caps type of the appended compound
// word.
- if (STRNCMP(ptr, mip->mi_word, mip->mi_compoff) != 0) {
+ if (strncmp(ptr, mip->mi_word, (size_t)mip->mi_compoff) != 0) {
// case folding may have changed the length
p = mip->mi_word;
- for (char_u *s = ptr; s < ptr + mip->mi_compoff; MB_PTR_ADV(s)) {
+ for (char *s = ptr; s < ptr + mip->mi_compoff; MB_PTR_ADV(s)) {
MB_PTR_ADV(p);
}
} else {
p = mip->mi_word + mip->mi_compoff;
}
- capflags = captype(p, mip->mi_word + wlen);
+ capflags = captype((char_u *)p, (char_u *)mip->mi_word + wlen);
if (capflags == WF_KEEPCAP || (capflags == WF_ALLCAP
&& (flags & WF_FIXCAP) != 0)) {
continue;
@@ -724,7 +724,7 @@ static void find_word(matchinf_T *mip, int mode)
// accept a no-caps word, even when the dictionary
// word specifies ONECAP.
MB_PTR_BACK(mip->mi_word, p);
- if (spell_iswordp_nmw(p, mip->mi_win)
+ if (spell_iswordp_nmw((char_u *)p, mip->mi_win)
? capflags == WF_ONECAP
: (flags & WF_ONECAP) != 0
&& capflags != WF_ONECAP) {
@@ -744,7 +744,7 @@ static void find_word(matchinf_T *mip, int mode)
if (slang->sl_compsylmax < MAXWLEN) {
// "fword" is only needed for checking syllables.
if (ptr == mip->mi_word) {
- (void)spell_casefold(mip->mi_win, ptr, wlen, fword, MAXWLEN);
+ (void)spell_casefold(mip->mi_win, (char_u *)ptr, wlen, fword, MAXWLEN);
} else {
STRLCPY(fword, ptr, endlen[endidxcnt] + 1);
}
@@ -786,12 +786,12 @@ static void find_word(matchinf_T *mip, int mode)
// byte length in keep-case word. Length may change when
// folding case. This can be slow, take a shortcut when
// the case-folded word is equal to the keep-case word.
- p = (char_u *)mip->mi_fword;
- if (STRNCMP(ptr, p, wlen) != 0) {
- for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
+ p = mip->mi_fword;
+ if (strncmp(ptr, p, (size_t)wlen) != 0) {
+ for (char *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
MB_PTR_ADV(p);
}
- mip->mi_compoff = (int)(p - (char_u *)mip->mi_fword);
+ mip->mi_compoff = (int)(p - mip->mi_fword);
}
}
#if 0
@@ -878,16 +878,16 @@ static void find_word(matchinf_T *mip, int mode)
if (nobreak_result == SP_BAD) {
if (mip->mi_result2 > res) {
mip->mi_result2 = res;
- mip->mi_end2 = mip->mi_word + wlen;
+ mip->mi_end2 = (char_u *)mip->mi_word + wlen;
} else if (mip->mi_result2 == res
- && mip->mi_end2 < mip->mi_word + wlen) {
- mip->mi_end2 = mip->mi_word + wlen;
+ && mip->mi_end2 < (char_u *)mip->mi_word + wlen) {
+ mip->mi_end2 = (char_u *)mip->mi_word + wlen;
}
} else if (mip->mi_result > res) {
mip->mi_result = res;
- mip->mi_end = mip->mi_word + wlen;
- } else if (mip->mi_result == res && mip->mi_end < mip->mi_word + wlen) {
- mip->mi_end = mip->mi_word + wlen;
+ mip->mi_end = (char_u *)mip->mi_word + wlen;
+ } else if (mip->mi_result == res && mip->mi_end < (char_u *)mip->mi_word + wlen) {
+ mip->mi_end = (char_u *)mip->mi_word + wlen;
}
if (mip->mi_result == SP_OK) {
@@ -908,16 +908,16 @@ static void find_word(matchinf_T *mip, int mode)
/// end of ptr[wlen] and the second part matches after it.
///
/// @param gap &sl_comppat
-bool match_checkcompoundpattern(char_u *ptr, int wlen, garray_T *gap)
+bool match_checkcompoundpattern(char *ptr, int wlen, garray_T *gap)
{
for (int i = 0; i + 1 < gap->ga_len; i += 2) {
char *p = ((char **)gap->ga_data)[i + 1];
- if (STRNCMP(ptr + wlen, p, strlen(p)) == 0) {
+ if (strncmp(ptr + wlen, p, strlen(p)) == 0) {
// Second part matches at start of following compound word, now
// check if first part matches at end of previous word.
p = ((char **)gap->ga_data)[i];
int len = (int)strlen(p);
- if (len <= wlen && STRNCMP(ptr + wlen - len, p, len) == 0) {
+ if (len <= wlen && strncmp(ptr + wlen - len, p, (size_t)len) == 0) {
return true;
}
}
@@ -1111,7 +1111,7 @@ static void find_prefix(matchinf_T *mip, int mode)
// Case-folded length may differ from original length.
mip->mi_cprefixlen = nofold_len((char_u *)mip->mi_fword, mip->mi_prefixlen,
- mip->mi_word);
+ (char_u *)mip->mi_word);
find_word(mip, FIND_PREFIX);
if (len == 0) {
@@ -1809,7 +1809,7 @@ static int count_syllables(slang_T *slang, const char_u *word)
return 0;
}
- for (const char_u *p = word; *p != NUL; p += len) {
+ for (const char *p = (char *)word; *p != NUL; p += len) {
// When running into a space reset counter.
if (*p == ' ') {
len = 1;
@@ -1822,7 +1822,7 @@ static int count_syllables(slang_T *slang, const char_u *word)
for (int i = 0; i < slang->sl_syl_items.ga_len; i++) {
syl_item_T *syl = ((syl_item_T *)slang->sl_syl_items.ga_data) + i;
if (syl->sy_len > len
- && STRNCMP(p, syl->sy_chars, syl->sy_len) == 0) {
+ && strncmp(p, syl->sy_chars, (size_t)syl->sy_len) == 0) {
len = syl->sy_len;
}
}
@@ -1831,8 +1831,8 @@ static int count_syllables(slang_T *slang, const char_u *word)
skip = false;
} else {
// No recognized syllable item, at least a syllable char then?
- int c = utf_ptr2char((char *)p);
- len = utfc_ptr2len((char *)p);
+ int c = utf_ptr2char(p);
+ len = utfc_ptr2len(p);
if (vim_strchr((char *)slang->sl_syllable, c) == NULL) {
skip = false; // No, search for next syllable
} else if (!skip) {
diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h
index 1484d8cef2..265e4b2819 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -72,8 +72,8 @@ typedef int idx_T;
// si_repsal, sl_rep, and si_sal. Not for sl_sal!
// One replacement: from "ft_from" to "ft_to".
typedef struct fromto_S {
- uint8_t *ft_from;
- uint8_t *ft_to;
+ char *ft_from;
+ char *ft_to;
} fromto_T;
// Info from "SAL" entries in ".aff" file used in sl_sal.
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 69847bfa10..f2c335c69a 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -899,7 +899,7 @@ void suggest_load_files(void)
slang_T *slang;
char *dotp;
FILE *fd;
- char_u buf[MAXWLEN];
+ char buf[MAXWLEN];
int i;
time_t timestamp;
int wcount;
@@ -929,9 +929,9 @@ void suggest_load_files(void)
// <SUGHEADER>: <fileID> <versionnr> <timestamp>
for (i = 0; i < VIMSUGMAGICL; i++) {
- buf[i] = (char_u)getc(fd); // <fileID>
+ buf[i] = (char)getc(fd); // <fileID>
}
- if (STRNCMP(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0) {
+ if (strncmp(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0) {
semsg(_("E778: This does not look like a .sug file: %s"),
slang->sl_fname);
goto nextone;
@@ -1147,14 +1147,14 @@ static int read_rep_section(FILE *fd, garray_T *gap, int16_t *first)
for (; gap->ga_len < cnt; ++gap->ga_len) {
int c;
ftp = &((fromto_T *)gap->ga_data)[gap->ga_len];
- ftp->ft_from = read_cnt_string(fd, 1, &c);
+ ftp->ft_from = (char *)read_cnt_string(fd, 1, &c);
if (c < 0) {
return c;
}
if (c == 0) {
return SP_FORMERROR;
}
- ftp->ft_to = read_cnt_string(fd, 1, &c);
+ ftp->ft_to = (char *)read_cnt_string(fd, 1, &c);
if (c <= 0) {
xfree(ftp->ft_from);
if (c < 0) {
@@ -1170,8 +1170,8 @@ static int read_rep_section(FILE *fd, garray_T *gap, int16_t *first)
}
for (int i = 0; i < gap->ga_len; i++) {
ftp = &((fromto_T *)gap->ga_data)[i];
- if (first[*ftp->ft_from] == -1) {
- first[*ftp->ft_from] = (int16_t)i;
+ if (first[(uint8_t)(*ftp->ft_from)] == -1) {
+ first[(uint8_t)(*ftp->ft_from)] = (int16_t)i;
}
}
return 0;
@@ -3057,9 +3057,9 @@ static void add_fromto(spellinfo_T *spin, garray_T *gap, char *from, char *to)
fromto_T *ftp = GA_APPEND_VIA_PTR(fromto_T, gap);
(void)spell_casefold(curwin, (char_u *)from, (int)strlen(from), word, MAXWLEN);
- ftp->ft_from = (char_u *)getroom_save(spin, (char *)word);
+ ftp->ft_from = getroom_save(spin, (char *)word);
(void)spell_casefold(curwin, (char_u *)to, (int)strlen(to), word, MAXWLEN);
- ftp->ft_to = (char_u *)getroom_save(spin, (char *)word);
+ ftp->ft_to = getroom_save(spin, (char *)word);
}
/// Converts a boolean argument in a SAL line to true or false;
@@ -4360,7 +4360,7 @@ static int rep_compare(const void *s1, const void *s2)
fromto_T *p1 = (fromto_T *)s1;
fromto_T *p2 = (fromto_T *)s2;
- return strcmp((char *)p1->ft_from, (char *)p2->ft_from);
+ return strcmp(p1->ft_from, p2->ft_from);
}
/// Write the Vim .spl file "fname".
@@ -4516,8 +4516,8 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
assert(gap->ga_len >= 0);
for (size_t i = 0; i < (size_t)gap->ga_len; i++) {
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
- l += 1 + strlen((char *)ftp->ft_from); // count <*fromlen> and <*from>
- l += 1 + strlen((char *)ftp->ft_to); // count <*tolen> and <*to>
+ l += 1 + strlen(ftp->ft_from); // count <*fromlen> and <*from>
+ l += 1 + strlen(ftp->ft_to); // count <*tolen> and <*to>
}
if (round == 2) {
l++; // count <salflags>
@@ -4544,7 +4544,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
// <sal> : <salfromlen> <salfrom> <saltolen> <salto>
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
for (unsigned int rr = 1; rr <= 2; rr++) {
- char *p = rr == 1 ? (char *)ftp->ft_from : (char *)ftp->ft_to;
+ char *p = rr == 1 ? ftp->ft_from : ftp->ft_to;
l = strlen(p);
assert(l < INT_MAX);
putc((int)l, fd);
@@ -5516,7 +5516,7 @@ static void spell_message(const spellinfo_T *spin, char *str)
// ":[count]spellrare {word}"
void ex_spell(exarg_T *eap)
{
- spell_add_word((char_u *)eap->arg, (int)strlen(eap->arg),
+ spell_add_word(eap->arg, (int)strlen(eap->arg),
eap->cmdidx == CMD_spellwrong ? SPELL_ADD_BAD :
eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD,
eap->forceit ? 0 : (int)eap->line2,
@@ -5528,19 +5528,19 @@ void ex_spell(exarg_T *eap)
/// @param what SPELL_ADD_ values
/// @param idx "zG" and "zW": zero, otherwise index in 'spellfile'
/// @param bool // true for "zug", "zuG", "zuw" and "zuW"
-void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo)
+void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo)
{
FILE *fd = NULL;
buf_T *buf = NULL;
bool new_spf = false;
char *fname;
char_u *fnamebuf = NULL;
- char_u line[MAXWLEN * 2];
+ char line[MAXWLEN * 2];
long fpos, fpos_next = 0;
int i;
char_u *spf;
- if (!valid_spell_word((char *)word, (char *)word + len)) {
+ if (!valid_spell_word(word, word + len)) {
emsg(_(e_illegal_character_in_word));
return;
}
@@ -5603,8 +5603,8 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo
if (fpos_next < 0) {
break; // should never happen
}
- if (STRNCMP(word, line, len) == 0
- && (line[len] == '/' || line[len] < ' ')) {
+ if (strncmp(word, line, (size_t)len) == 0
+ && (line[len] == '/' || (uint8_t)line[len] < ' ')) {
// Found duplicate word. Remove it by writing a '#' at
// the start of the line. Mixing reading and writing
// doesn't work for all systems, close the file first.
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 76410e5225..6bdcfe5ffe 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -75,7 +75,7 @@ typedef struct suginfo_S {
int su_badlen; ///< length of detected bad word in line
int su_badflags; ///< caps flags for bad word
char_u su_badword[MAXWLEN]; ///< bad word truncated at su_badlen
- char_u su_fbadword[MAXWLEN]; ///< su_badword case-folded
+ char su_fbadword[MAXWLEN]; ///< su_badword case-folded
char_u su_sal_badword[MAXWLEN]; ///< su_badword soundfolded
hashtab_T su_banned; ///< table with banned words
slang_T *su_sallang; ///< default language for sound folding
@@ -744,7 +744,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
su->su_badlen = MAXWLEN - 1; // just in case
}
STRLCPY(su->su_badword, su->su_badptr, su->su_badlen + 1);
- (void)spell_casefold(curwin, (char_u *)su->su_badptr, su->su_badlen, su->su_fbadword,
+ (void)spell_casefold(curwin, (char_u *)su->su_badptr, su->su_badlen, (char_u *)su->su_fbadword,
MAXWLEN);
// TODO(vim): make this work if the case-folded text is longer than the
@@ -1004,20 +1004,20 @@ static void spell_find_cleanup(suginfo_T *su)
/// Try finding suggestions by recognizing specific situations.
static void suggest_try_special(suginfo_T *su)
{
- int c;
+ char c;
char_u word[MAXWLEN];
// Recognize a word that is repeated: "the the".
char *p = skiptowhite((char *)su->su_fbadword);
size_t len = (size_t)(p - (char *)su->su_fbadword);
p = skipwhite(p);
- if (strlen(p) == len && STRNCMP(su->su_fbadword, p, len) == 0) {
+ if (strlen(p) == len && strncmp(su->su_fbadword, p, len) == 0) {
// Include badflags: if the badword is onecap or allcap
// use that for the goodword too: "The the" -> "The".
c = su->su_fbadword[len];
su->su_fbadword[len] = NUL;
- make_case_word(su->su_fbadword, word, su->su_badflags);
- su->su_fbadword[len] = (char_u)c;
+ make_case_word((char_u *)su->su_fbadword, word, su->su_badflags);
+ su->su_fbadword[len] = c;
// Give a soundalike score of 0, compute the score as if deleting one
// character.
@@ -1106,7 +1106,7 @@ static void suggest_try_change(suginfo_T *su)
#ifdef SUGGEST_PROFILE
prof_init();
#endif
- suggest_trie_walk(su, lp, (char_u *)fword, false);
+ suggest_trie_walk(su, lp, fword, false);
#ifdef SUGGEST_PROFILE
prof_report("try_change");
#endif
@@ -1146,9 +1146,9 @@ static void suggest_try_change(suginfo_T *su)
/// word splitting for now
/// "similar_chars()"
/// use "slang->sl_repsal" instead of "lp->lp_replang->sl_rep"
-static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool soundfold)
+static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soundfold)
{
- char_u tword[MAXWLEN]; // good word collected so far
+ char tword[MAXWLEN]; // good word collected so far
trystate_T stack[MAXWLEN];
char preword[MAXWLEN * 3] = { 0 }; // word found with proper case;
// concatenation of prefix compound
@@ -1168,7 +1168,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
garray_T *gap;
idx_T arridx;
int len;
- char_u *p;
+ char *p;
fromto_T *ftp;
int fl = 0, tl;
int repextra = 0; // extra bytes in fword[] from REP item
@@ -1258,7 +1258,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
if (depth < MAXWLEN - 1 && (byts[arridx] == 0 || n == STATE_NOPREFIX)) {
// Set su->su_badflags to the caps type at this position.
// Use the caps type until here for the prefix itself.
- n = nofold_len(fword, sp->ts_fidx, (char_u *)su->su_badptr);
+ n = nofold_len((char_u *)fword, sp->ts_fidx, (char_u *)su->su_badptr);
flags = badword_captype((char_u *)su->su_badptr, (char_u *)su->su_badptr + n);
su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
(char_u *)su->su_badptr + su->su_badlen);
@@ -1276,7 +1276,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Move the prefix to preword[] with the right case
// and make find_keepcap_word() works.
tword[sp->ts_twordlen] = NUL;
- make_case_word(tword + sp->ts_splitoff,
+ make_case_word((char_u *)tword + sp->ts_splitoff,
(char_u *)preword + sp->ts_prewordlen, flags);
sp->ts_prewordlen = (char_u)strlen(preword);
sp->ts_splitoff = sp->ts_twordlen;
@@ -1305,7 +1305,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
fword_ends = (fword[sp->ts_fidx] == NUL
|| (soundfold
? ascii_iswhite(fword[sp->ts_fidx])
- : !spell_iswordp(fword + sp->ts_fidx, curwin)));
+ : !spell_iswordp((char_u *)fword + sp->ts_fidx, curwin)));
tword[sp->ts_twordlen] = NUL;
if (sp->ts_prefixdepth <= PFD_NOTSPECIAL
@@ -1320,7 +1320,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
for (c = 0; c < len && pbyts[n + c] == 0; c++) {}
if (c > 0) {
c = valid_word_prefix(c, n, flags,
- tword + sp->ts_splitoff, slang, false);
+ (char_u *)tword + sp->ts_splitoff, slang, false);
if (c == 0) {
break;
}
@@ -1357,7 +1357,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// need to check if a correct word follows.
if (sp->ts_fidx - sp->ts_splitfidx
== sp->ts_twordlen - sp->ts_splitoff
- && STRNCMP(fword + sp->ts_splitfidx,
+ && strncmp(fword + sp->ts_splitfidx,
tword + sp->ts_splitoff,
sp->ts_fidx - sp->ts_splitfidx) == 0) {
preword[sp->ts_prewordlen] = NUL;
@@ -1386,7 +1386,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// For multi-byte chars check character length against
// COMPOUNDMIN.
if (slang->sl_compminlen > 0
- && mb_charlen(tword + sp->ts_splitoff)
+ && mb_charlen((char_u *)tword + sp->ts_splitoff)
< slang->sl_compminlen) {
break;
}
@@ -1398,17 +1398,17 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
sp->ts_twordlen - sp->ts_splitoff + 1);
// Verify CHECKCOMPOUNDPATTERN rules.
- if (match_checkcompoundpattern((char_u *)preword, sp->ts_prewordlen,
+ if (match_checkcompoundpattern(preword, sp->ts_prewordlen,
&slang->sl_comppat)) {
compound_ok = false;
}
if (compound_ok) {
- p = (char_u *)preword;
- while (*skiptowhite((char *)p) != NUL) {
- p = (char_u *)skipwhite(skiptowhite((char *)p));
+ p = preword;
+ while (*skiptowhite(p) != NUL) {
+ p = skipwhite(skiptowhite(p));
}
- if (fword_ends && !can_compound(slang, (char *)p, compflags + sp->ts_compsplit)) {
+ if (fword_ends && !can_compound(slang, p, compflags + sp->ts_compsplit)) {
// Compound is not allowed. But it may still be
// possible if we add another (short) word.
compound_ok = false;
@@ -1416,7 +1416,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
}
// Get pointer to last char of previous word.
- p = (char_u *)preword + sp->ts_prewordlen;
+ p = preword + sp->ts_prewordlen;
MB_PTR_BACK(preword, p);
}
}
@@ -1441,10 +1441,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// When appending a compound word after a word character don't
// use Onecap.
- if (p != NULL && spell_iswordp_nmw(p, curwin)) {
+ if (p != NULL && spell_iswordp_nmw((char_u *)p, curwin)) {
c &= ~WF_ONECAP;
}
- make_case_word(tword + sp->ts_splitoff,
+ make_case_word((char_u *)tword + sp->ts_splitoff,
(char_u *)preword + sp->ts_prewordlen, c);
}
@@ -1508,10 +1508,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// char, e.g., "thes," -> "these".
p = fword + sp->ts_fidx;
MB_PTR_BACK(fword, p);
- if (!spell_iswordp(p, curwin) && *preword != NUL) {
- p = (char_u *)preword + strlen(preword);
+ if (!spell_iswordp((char_u *)p, curwin) && *preword != NUL) {
+ p = preword + strlen(preword);
MB_PTR_BACK(preword, p);
- if (spell_iswordp(p, curwin)) {
+ if (spell_iswordp((char_u *)p, curwin)) {
newscore += SCORE_NONWORD;
}
}
@@ -1533,7 +1533,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// upper or lower case, add both.
c = captype((char_u *)preword, NULL);
if (c == 0 || c == WF_ALLCAP) {
- make_case_word(tword + sp->ts_splitoff,
+ make_case_word((char_u *)tword + sp->ts_splitoff,
(char_u *)preword + sp->ts_prewordlen,
c == 0 ? WF_ALLCAP : 0);
@@ -1582,7 +1582,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
&& sp->ts_twordlen - sp->ts_splitoff
>= slang->sl_compminlen
&& (slang->sl_compminlen == 0
- || mb_charlen(tword + sp->ts_splitoff)
+ || mb_charlen((char_u *)tword + sp->ts_splitoff)
>= slang->sl_compminlen)
&& (slang->sl_compsylmax < MAXWLEN
|| sp->ts_complen + 1 - sp->ts_compsplit
@@ -1621,12 +1621,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
&& (flags & WF_NEEDCOMP)) {
break;
}
- p = (char_u *)preword;
- while (*skiptowhite((char *)p) != NUL) {
- p = (char_u *)skipwhite(skiptowhite((char *)p));
+ p = preword;
+ while (*skiptowhite(p) != NUL) {
+ p = skipwhite(skiptowhite(p));
}
if (sp->ts_complen > sp->ts_compsplit
- && !can_compound(slang, (char *)p, compflags + sp->ts_compsplit)) {
+ && !can_compound(slang, p, compflags + sp->ts_compsplit)) {
break;
}
@@ -1673,7 +1673,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// non-word character with a space. Always skip a
// character when the word ends. But only when the
// good word can end.
- if (((!try_compound && !spell_iswordp_nmw(fword
+ if (((!try_compound && !spell_iswordp_nmw((char_u *)fword
+ sp->ts_fidx,
curwin))
|| fword_ends)
@@ -1681,7 +1681,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
&& goodword_ends) {
int l;
- l = utfc_ptr2len((char *)fword + sp->ts_fidx);
+ l = utfc_ptr2len(fword + sp->ts_fidx);
if (fword_ends) {
// Copy the skipped character to preword.
memmove(preword + sp->ts_prewordlen, fword + sp->ts_fidx, (size_t)l);
@@ -1705,7 +1705,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// set su->su_badflags to the caps type at this
// position
- n = nofold_len(fword, sp->ts_fidx, (char_u *)su->su_badptr);
+ n = nofold_len((char_u *)fword, sp->ts_fidx, (char_u *)su->su_badptr);
su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
(char_u *)su->su_badptr + su->su_badlen);
@@ -1774,7 +1774,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// when the byte was already changed. And don't try when we
// just deleted this byte, accepting it is always cheaper than
// delete + substitute.
- if (c == fword[sp->ts_fidx]
+ if (c == (uint8_t)fword[sp->ts_fidx]
|| (sp->ts_tcharlen > 0
&& sp->ts_isdiff != DIFF_NONE)) {
newscore = 0;
@@ -1784,7 +1784,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
if ((newscore == 0
|| (sp->ts_fidx >= sp->ts_fidxtry
&& ((sp->ts_flags & TSF_DIDDEL) == 0
- || c != fword[sp->ts_delidx])))
+ || c != (uint8_t)fword[sp->ts_delidx])))
&& TRY_DEEPER(su, stack, depth, newscore)) {
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
@@ -1803,7 +1803,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
if (fword[sp->ts_fidx] != NUL) {
sp->ts_fidx++;
}
- tword[sp->ts_twordlen++] = (char_u)c;
+ tword[sp->ts_twordlen++] = (char)c;
sp->ts_arridx = idxs[arridx];
if (newscore == SCORE_SUBST) {
sp->ts_isdiff = DIFF_YES;
@@ -1829,14 +1829,14 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Correct ts_fidx for the byte length of the
// character (we didn't check that before).
sp->ts_fidx = (char_u)(sp->ts_fcharstart
- + utfc_ptr2len((char *)fword + sp->ts_fcharstart));
+ + utfc_ptr2len(fword + sp->ts_fcharstart));
// For changing a composing character adjust
// the score from SCORE_SUBST to
// SCORE_SUBCOMP.
if (utf_iscomposing(utf_ptr2char((char *)tword + sp->ts_twordlen
- sp->ts_tcharlen))
- && utf_iscomposing(utf_ptr2char((char *)fword
+ && utf_iscomposing(utf_ptr2char(fword
+ sp->ts_fcharstart))) {
sp->ts_score -= SCORE_SUBST - SCORE_SUBCOMP;
} else if (!soundfold
@@ -1844,15 +1844,15 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
&& similar_chars(slang,
utf_ptr2char((char *)tword + sp->ts_twordlen -
sp->ts_tcharlen),
- utf_ptr2char((char *)fword + sp->ts_fcharstart))) {
+ utf_ptr2char(fword + sp->ts_fcharstart))) {
// For a similar character adjust score from
// SCORE_SUBST to SCORE_SIMILAR.
sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR;
}
} else if (sp->ts_isdiff == DIFF_INSERT
&& sp->ts_twordlen > sp->ts_tcharlen) {
- p = tword + sp->ts_twordlen - sp->ts_tcharlen;
- c = utf_ptr2char((char *)p);
+ p = (char *)tword + sp->ts_twordlen - sp->ts_tcharlen;
+ c = utf_ptr2char(p);
if (utf_iscomposing(c)) {
// Inserting a composing char doesn't
// count that much.
@@ -1864,7 +1864,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// tree (might seem illogical but does
// give better scores).
MB_PTR_BACK(tword, p);
- if (c == utf_ptr2char((char *)p)) {
+ if (c == utf_ptr2char(p)) {
sp->ts_score -= SCORE_INS - SCORE_INSDUP;
}
}
@@ -1915,12 +1915,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// score if the same character is following "nn" -> "n". It's
// a bit illogical for soundfold tree but it does give better
// results.
- c = utf_ptr2char((char *)fword + sp->ts_fidx);
+ c = utf_ptr2char(fword + sp->ts_fidx);
stack[depth].ts_fidx =
- (char_u)(stack[depth].ts_fidx + utfc_ptr2len((char *)fword + sp->ts_fidx));
+ (char_u)(stack[depth].ts_fidx + utfc_ptr2len(fword + sp->ts_fidx));
if (utf_iscomposing(c)) {
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
- } else if (c == utf_ptr2char((char *)fword + stack[depth].ts_fidx)) {
+ } else if (c == utf_ptr2char(fword + stack[depth].ts_fidx)) {
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
}
@@ -1980,7 +1980,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
} else {
newscore = SCORE_INS;
}
- if (c != fword[sp->ts_fidx]
+ if (c != (uint8_t)fword[sp->ts_fidx]
&& TRY_DEEPER(su, stack, depth, newscore)) {
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
@@ -1990,7 +1990,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
#endif
depth++;
sp = &stack[depth];
- tword[sp->ts_twordlen++] = (char_u)c;
+ tword[sp->ts_twordlen++] = (char)c;
sp->ts_arridx = idxs[n];
fl = MB_BYTE2LEN(c);
if (fl > 1) {
@@ -2007,7 +2007,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// soundfold words (illogical but does give a better
// score).
if (sp->ts_twordlen >= 2
- && tword[sp->ts_twordlen - 2] == c) {
+ && (uint8_t)tword[sp->ts_twordlen - 2] == c) {
sp->ts_score -= SCORE_INS - SCORE_INSDUP;
}
}
@@ -2019,7 +2019,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// We change "fword" here, it's changed back afterwards at
// STATE_UNSWAP.
p = fword + sp->ts_fidx;
- c = *p;
+ c = (uint8_t)(*p);
if (c == NUL) {
// End of word, can't swap or replace.
PROF_STORE(sp->ts_state)
@@ -2029,20 +2029,20 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Don't swap if the first character is not a word character.
// SWAP3 etc. also don't make sense then.
- if (!soundfold && !spell_iswordp(p, curwin)) {
+ if (!soundfold && !spell_iswordp((char_u *)p, curwin)) {
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
- n = utf_ptr2len((char *)p);
- c = utf_ptr2char((char *)p);
+ n = utf_ptr2len(p);
+ c = utf_ptr2char(p);
if (p[n] == NUL) {
c2 = NUL;
- } else if (!soundfold && !spell_iswordp(p + n, curwin)) {
+ } else if (!soundfold && !spell_iswordp((char_u *)p + n, curwin)) {
c2 = c; // don't swap non-word char
} else {
- c2 = utf_ptr2char((char *)p + n);
+ c2 = utf_ptr2char(p + n);
}
// When the second character is NUL we can't swap.
@@ -2072,7 +2072,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
depth++;
fl = utf_char2len(c2);
memmove(p, p + n, (size_t)fl);
- utf_char2bytes(c, (char *)p + fl);
+ utf_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl);
} else {
// If this swap doesn't work then SWAP3 won't either.
@@ -2084,10 +2084,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
case STATE_UNSWAP:
// Undo the STATE_SWAP swap: "21" -> "12".
p = fword + sp->ts_fidx;
- n = utfc_ptr2len((char *)p);
- c = utf_ptr2char((char *)p + n);
- memmove(p + utfc_ptr2len((char *)p + n), p, (size_t)n);
- utf_char2bytes(c, (char *)p);
+ n = utfc_ptr2len(p);
+ c = utf_ptr2char(p + n);
+ memmove(p + utfc_ptr2len(p + n), p, (size_t)n);
+ utf_char2bytes(c, p);
FALLTHROUGH;
@@ -2095,14 +2095,14 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Swap two bytes, skipping one: "123" -> "321". We change
// "fword" here, it's changed back afterwards at STATE_UNSWAP3.
p = fword + sp->ts_fidx;
- n = utf_ptr2len((char *)p);
- c = utf_ptr2char((char *)p);
- fl = utf_ptr2len((char *)p + n);
- c2 = utf_ptr2char((char *)p + n);
- if (!soundfold && !spell_iswordp(p + n + fl, curwin)) {
+ n = utf_ptr2len(p);
+ c = utf_ptr2char(p);
+ fl = utf_ptr2len(p + n);
+ c2 = utf_ptr2char(p + n);
+ if (!soundfold && !spell_iswordp((char_u *)p + n + fl, curwin)) {
c3 = c; // don't swap non-word char
} else {
- c3 = utf_ptr2char((char *)p + n + fl);
+ c3 = utf_ptr2char(p + n + fl);
}
// When characters are identical: "121" then SWAP3 result is
@@ -2128,8 +2128,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
depth++;
tl = utf_char2len(c3);
memmove(p, p + n + fl, (size_t)tl);
- utf_char2bytes(c2, (char *)p + tl);
- utf_char2bytes(c, (char *)p + fl + tl);
+ utf_char2bytes(c2, p + tl);
+ utf_char2bytes(c, p + fl + tl);
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl + tl);
} else {
PROF_STORE(sp->ts_state)
@@ -2140,17 +2140,17 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
case STATE_UNSWAP3:
// Undo STATE_SWAP3: "321" -> "123"
p = fword + sp->ts_fidx;
- n = utfc_ptr2len((char *)p);
- c2 = utf_ptr2char((char *)p + n);
- fl = utfc_ptr2len((char *)p + n);
- c = utf_ptr2char((char *)p + n + fl);
- tl = utfc_ptr2len((char *)p + n + fl);
+ n = utfc_ptr2len(p);
+ c2 = utf_ptr2char(p + n);
+ fl = utfc_ptr2len(p + n);
+ c = utf_ptr2char(p + n + fl);
+ tl = utfc_ptr2len(p + n + fl);
memmove(p + fl + tl, p, (size_t)n);
- utf_char2bytes(c, (char *)p);
- utf_char2bytes(c2, (char *)p + tl);
+ utf_char2bytes(c, p);
+ utf_char2bytes(c2, p + tl);
p = p + tl;
- if (!soundfold && !spell_iswordp(p, curwin)) {
+ if (!soundfold && !spell_iswordp((char_u *)p, curwin)) {
// Middle char is not a word char, skip the rotate. First and
// third char were already checked at swap and swap3.
PROF_STORE(sp->ts_state)
@@ -2172,12 +2172,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
sp->ts_state = STATE_UNROT3L;
depth++;
p = fword + sp->ts_fidx;
- n = utf_ptr2len((char *)p);
- c = utf_ptr2char((char *)p);
- fl = utf_ptr2len((char *)p + n);
- fl += utf_ptr2len((char *)p + n + fl);
+ n = utf_ptr2len(p);
+ c = utf_ptr2char(p);
+ fl = utf_ptr2len(p + n);
+ fl += utf_ptr2len(p + n + fl);
memmove(p, p + n, (size_t)fl);
- utf_char2bytes(c, (char *)p + fl);
+ utf_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl);
} else {
PROF_STORE(sp->ts_state)
@@ -2188,12 +2188,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
case STATE_UNROT3L:
// Undo ROT3L: "231" -> "123"
p = fword + sp->ts_fidx;
- n = utfc_ptr2len((char *)p);
- n += utfc_ptr2len((char *)p + n);
- c = utf_ptr2char((char *)p + n);
- tl = utfc_ptr2len((char *)p + n);
+ n = utfc_ptr2len(p);
+ n += utfc_ptr2len(p + n);
+ c = utf_ptr2char(p + n);
+ tl = utfc_ptr2len(p + n);
memmove(p + tl, p, (size_t)n);
- utf_char2bytes(c, (char *)p);
+ utf_char2bytes(c, p);
// Rotate three bytes right: "123" -> "312". We change "fword"
// here, it's changed back afterwards at STATE_UNROT3R.
@@ -2209,12 +2209,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
sp->ts_state = STATE_UNROT3R;
depth++;
p = fword + sp->ts_fidx;
- n = utf_ptr2len((char *)p);
- n += utf_ptr2len((char *)p + n);
- c = utf_ptr2char((char *)p + n);
- tl = utf_ptr2len((char *)p + n);
+ n = utf_ptr2len(p);
+ n += utf_ptr2len(p + n);
+ c = utf_ptr2char(p + n);
+ tl = utf_ptr2len(p + n);
memmove(p + tl, p, (size_t)n);
- utf_char2bytes(c, (char *)p);
+ utf_char2bytes(c, p);
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + tl);
} else {
PROF_STORE(sp->ts_state)
@@ -2225,12 +2225,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
case STATE_UNROT3R:
// Undo ROT3R: "312" -> "123"
p = fword + sp->ts_fidx;
- c = utf_ptr2char((char *)p);
- tl = utfc_ptr2len((char *)p);
- n = utfc_ptr2len((char *)p + tl);
- n += utfc_ptr2len((char *)p + tl + n);
+ c = utf_ptr2char(p);
+ tl = utfc_ptr2len(p);
+ n = utfc_ptr2len(p + tl);
+ n += utfc_ptr2len(p + tl + n);
memmove(p, p + tl, (size_t)n);
- utf_char2bytes(c, (char *)p + n);
+ utf_char2bytes(c, p + n);
FALLTHROUGH;
@@ -2251,9 +2251,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Use the first byte to quickly find the first entry that may
// match. If the index is -1 there is none.
if (soundfold) {
- sp->ts_curi = slang->sl_repsal_first[fword[sp->ts_fidx]];
+ sp->ts_curi = slang->sl_repsal_first[(uint8_t)fword[sp->ts_fidx]];
} else {
- sp->ts_curi = lp->lp_replang->sl_rep_first[fword[sp->ts_fidx]];
+ sp->ts_curi = lp->lp_replang->sl_rep_first[(uint8_t)fword[sp->ts_fidx]];
}
if (sp->ts_curi < 0) {
@@ -2284,7 +2284,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
sp->ts_curi = (int16_t)gap->ga_len;
break;
}
- if (STRNCMP(ftp->ft_from, p, strlen((char *)ftp->ft_from)) == 0
+ if (strncmp(ftp->ft_from, p, strlen(ftp->ft_from)) == 0
&& TRY_DEEPER(su, stack, depth, SCORE_REP)) {
go_deeper(stack, depth, SCORE_REP);
#ifdef DEBUG_TRIEWALK
@@ -2298,8 +2298,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Change the "from" to the "to" string.
depth++;
- fl = (int)strlen((char *)ftp->ft_from);
- tl = (int)strlen((char *)ftp->ft_to);
+ fl = (int)strlen(ftp->ft_from);
+ tl = (int)strlen(ftp->ft_to);
if (fl != tl) {
STRMOVE(p + tl, (char *)p + fl);
repextra += tl - fl;
@@ -2327,8 +2327,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
gap = &lp->lp_replang->sl_rep;
}
ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;
- fl = (int)strlen((char *)ftp->ft_from);
- tl = (int)strlen((char *)ftp->ft_to);
+ fl = (int)strlen(ftp->ft_from);
+ tl = (int)strlen(ftp->ft_to);
p = fword + sp->ts_fidx;
if (fl != tl) {
STRMOVE(p + fl, (char *)p + tl);
@@ -2747,7 +2747,7 @@ static void suggest_try_soundalike(suginfo_T *su)
#ifdef SUGGEST_PROFILE
prof_init();
#endif
- suggest_trie_walk(su, lp, salword, true);
+ suggest_trie_walk(su, lp, (char *)salword, true);
#ifdef SUGGEST_PROFILE
prof_report("soundalike");
#endif
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index cfe821715c..a96134be8f 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -185,7 +185,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
length++; // insert backslash
}
}
- if (do_special && find_cmdline_var(p, &l) >= 0) {
+ if (do_special && find_cmdline_var((char *)p, &l) >= 0) {
length++; // insert backslash
p += l - 1;
}
@@ -234,7 +234,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
*d++ = *p++;
continue;
}
- if (do_special && find_cmdline_var((char_u *)p, &l) >= 0) {
+ if (do_special && find_cmdline_var(p, &l) >= 0) {
*d++ = '\\'; // insert backslash
while (--l != SIZE_MAX) { // copy the var
*d++ = *p++;
diff --git a/src/nvim/vim.h b/src/nvim/vim.h
index 52af85ccc6..59b818fad7 100644
--- a/src/nvim/vim.h
+++ b/src/nvim/vim.h
@@ -201,7 +201,6 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
#define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) // NOLINT(runtime/printf)
#define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n))
-#define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
#ifdef HAVE_STRCASECMP
# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
#else
diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c
index 24dfb38ae0..0b19526fa0 100644
--- a/src/nvim/viml/parser/expressions.c
+++ b/src/nvim/viml/parser/expressions.c
@@ -1825,7 +1825,7 @@ static void parse_quoted_string(ParserState *const pstate, ExprASTNode *const no
if (p[1] != '*') {
flags |= FSK_SIMPLIFY;
}
- const size_t special_len = trans_special((const char_u **)&p, (size_t)(e - p),
+ const size_t special_len = trans_special(&p, (size_t)(e - p),
(char_u *)v_p, flags, false, NULL);
if (special_len != 0) {
v_p += special_len;