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
This commit is contained in:
dundargoc
2022-12-21 12:00:05 +01:00
committed by GitHub
parent c24605a5a0
commit ec1738a6ed
26 changed files with 533 additions and 533 deletions

View File

@@ -318,7 +318,7 @@ typedef struct {
typedef struct mapblock mapblock_T; typedef struct mapblock mapblock_T;
struct mapblock { struct mapblock {
mapblock_T *m_next; // next mapblock in list 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_str; // mapped to, rhs
char *m_orig_str; // rhs as entered by the user char *m_orig_str; // rhs as entered by the user
LuaRef m_luaref; // lua function reference as rhs LuaRef m_luaref; // lua function reference as rhs

View File

@@ -2960,7 +2960,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
if (xp->xp_context == EXPAND_FILES if (xp->xp_context == EXPAND_FILES
|| xp->xp_context == EXPAND_DIRECTORIES || xp->xp_context == EXPAND_DIRECTORIES
|| xp->xp_context == EXPAND_SHELLCMD) { || xp->xp_context == EXPAND_SHELLCMD) {
char_u upseg[5]; char upseg[5];
upseg[0] = PATHSEP; upseg[0] = PATHSEP;
upseg[1] = '.'; upseg[1] = '.';
@@ -2977,7 +2977,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
// go down a directory // go down a directory
c = (int)p_wc; c = (int)p_wc;
KeyTyped = true; // in case the key was mapped 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) { && c == K_DOWN) {
// If in a direct ancestor, strip off one ../ to go down // If in a direct ancestor, strip off one ../ to go down
int found = false; int found = false;
@@ -3024,9 +3024,9 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
if (!found) { if (!found) {
j = i; j = i;
} else if (STRNCMP(cclp->cmdbuff + j, upseg, 4) == 0) { } else if (strncmp(cclp->cmdbuff + j, upseg, 4) == 0) {
j += 4; 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 == i) {
j += 3; j += 3;
} else { } 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 // TODO(tarruda): this is only for DOS/Unix systems - need to put in
// machine-specific stuff here and in upseg init // machine-specific stuff here and in upseg init
cmdline_del(cclp, j); 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) { } else if (cclp->cmdpos > i) {
cmdline_del(cclp, i); cmdline_del(cclp, i);
} }

View File

@@ -2777,7 +2777,7 @@ static bool echeck_abbr(int c)
return false; 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); 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. /// @param line_is_empty when true, accept keys with '0' before them.
bool in_cinkeys(int keytyped, int when, bool line_is_empty) bool in_cinkeys(int keytyped, int when, bool line_is_empty)
{ {
uint8_t *look; char *look;
int try_match; int try_match;
int try_match_word; int try_match_word;
uint8_t *p; char *p;
uint8_t *line; char *line;
bool icase; bool icase;
if (keytyped == NUL) { if (keytyped == NUL) {
@@ -3031,9 +3031,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
} }
if (*curbuf->b_p_inde != NUL) { 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 { } else {
look = (uint8_t *)curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys' look = curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys'
} }
while (*look) { while (*look) {
// Find out if we want to try a match with this key, depending on // 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. // cursor.
} else if (*look == 'e') { } else if (*look == 'e') {
if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) { if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) {
p = (uint8_t *)get_cursor_line_ptr(); p = get_cursor_line_ptr();
if ((uint8_t *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4 if (skipwhite(p) == p + curwin->w_cursor.col - 4
&& STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) { && strncmp(p + curwin->w_cursor.col - 4, "else", 4) == 0) {
return true; return true;
} }
} }
@@ -3099,12 +3099,12 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
// class::method for C++). // class::method for C++).
} else if (*look == ':') { } else if (*look == ':') {
if (try_match && keytyped == ':') { 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()) { if (cin_iscase((char_u *)p, false) || cin_isscopedecl((char_u *)p) || cin_islabel()) {
return true; return true;
} }
// Need to get the line again after cin_islabel(). // 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 if (curwin->w_cursor.col > 2
&& p[curwin->w_cursor.col - 1] == ':' && p[curwin->w_cursor.col - 1] == ':'
&& p[curwin->w_cursor.col - 2] == ':') { && 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) const bool i = cin_iscase((char_u *)p, false)
|| cin_isscopedecl((char_u *)p) || cin_isscopedecl((char_u *)p)
|| cin_islabel(); || cin_islabel();
p = (uint8_t *)get_cursor_line_ptr(); p = get_cursor_line_ptr();
p[curwin->w_cursor.col - 1] = ':'; p[curwin->w_cursor.col - 1] = ':';
if (i) { if (i) {
return true; return true;
@@ -3151,22 +3151,22 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
} else { } else {
icase = false; icase = false;
} }
p = (uint8_t *)vim_strchr((char *)look, ','); p = vim_strchr(look, ',');
if (p == NULL) { if (p == NULL) {
p = look + strlen((char *)look); p = look + strlen(look);
} }
if ((try_match || try_match_word) if ((try_match || try_match_word)
&& curwin->w_cursor.col >= (colnr_T)(p - look)) { && curwin->w_cursor.col >= (colnr_T)(p - look)) {
bool match = false; bool match = false;
if (keytyped == KEY_COMPLETE) { if (keytyped == KEY_COMPLETE) {
uint8_t *n, *s; char *n, *s;
// Just completed a word, check if it starts with "look". // Just completed a word, check if it starts with "look".
// search back for the start of a word. // 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) { 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)) { if (!vim_iswordp((char_u *)n)) {
break; 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); assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);
if (s + (p - look) <= line + curwin->w_cursor.col if (s + (p - look) <= line + curwin->w_cursor.col
&& (icase && (icase
? mb_strnicmp((char *)s, (char *)look, (size_t)(p - look)) ? mb_strnicmp(s, look, (size_t)(p - look))
: STRNCMP(s, look, p - look)) == 0) { : strncmp(s, look, (size_t)(p - look))) == 0) {
match = true; match = true;
} }
} else { } else {
// TODO(@brammool): multi-byte // TODO(@brammool): multi-byte
if (keytyped == (int)p[-1] if (keytyped == (int)(uint8_t)p[-1]
|| (icase && keytyped < 256 || (icase && keytyped < 256
&& TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) { && 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); assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);
if ((curwin->w_cursor.col == (colnr_T)(p - look) if ((curwin->w_cursor.col == (colnr_T)(p - look)
|| !vim_iswordc(line[-(p - look) - 1])) || !vim_iswordc((uint8_t)line[-(p - look) - 1]))
&& (icase && (icase
? mb_strnicmp((char *)line - (p - look), (char *)look, (size_t)(p - look)) ? mb_strnicmp(line - (p - look), look, (size_t)(p - look))
: STRNCMP(line - (p - look), look, p - look)) == 0) { : strncmp(line - (p - look), look, (size_t)(p - look))) == 0) {
match = true; match = true;
} }
} }
@@ -3210,7 +3210,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
// Ok, it's a boring generic character. // Ok, it's a boring generic character.
} else { } else {
if (try_match && *look == keytyped) { if (try_match && (uint8_t)(*look) == keytyped) {
return true; return true;
} }
if (*look != NUL) { if (*look != NUL) {
@@ -3219,7 +3219,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
} }
// Skip over ", ". // Skip over ", ".
look = (uint8_t *)skip_to_option_part((char *)look); look = skip_to_option_part(look);
} }
return false; return false;
} }

View File

@@ -3838,7 +3838,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
if (p[1] != '*') { if (p[1] != '*') {
flags |= FSK_SIMPLIFY; 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) { if (extra != 0) {
name += extra; name += extra;
if (name >= rettv->vval.v_string + len) { if (name >= rettv->vval.v_string + len) {

View File

@@ -1367,12 +1367,13 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp)
{ {
bool is_fish_shell = bool is_fish_shell =
#if defined(UNIX) #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 #else
false; false;
#endif #endif
bool is_pwsh = STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0 bool is_pwsh = strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0
|| STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "powershell", 10) == 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. size_t len = strlen(cmd) + 1; // At least enough space for cmd + NULL.

View File

@@ -6631,7 +6631,7 @@ enum {
/// Check "str" for starting with a special cmdline variable. /// Check "str" for starting with a special cmdline variable.
/// If found return one of the SPEC_ values and set "*usedlen" to the length of /// If found return one of the SPEC_ values and set "*usedlen" to the length of
/// the variable. Otherwise return -1 and "*usedlen" is unchanged. /// 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 FUNC_ATTR_NONNULL_ALL
{ {
static char *(spec_str[]) = { 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++) { for (size_t i = 0; i < ARRAY_SIZE(spec_str); i++) {
size_t len = strlen(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; *usedlen = len;
assert(i <= SSIZE_MAX); assert(i <= SSIZE_MAX);
return (ssize_t)i; 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. // 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 if (spec_idx < 0) { // no match
*usedlen = 1; *usedlen = 1;
return NULL; return NULL;

View File

@@ -3929,7 +3929,7 @@ static int ccheck_abbr(int c)
spos = 0; 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": /// Escape special characters in "fname", depending on "what":

View File

@@ -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 // Only consider an entry if the first character matches and it is
// for the current state. // for the current state.
// Skip ":lmap" mappings if keys were mapped. // 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)) { && ((mp->m_mode & MODE_LANGMAP) == 0 || typebuf.tb_maplen == 0)) {
int nomap = nolmaplen; int nomap = nolmaplen;
int modifiers = 0; int modifiers = 0;
@@ -1994,7 +1994,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
} }
modifiers = 0; modifiers = 0;
} }
if (mp->m_keys[mlen] != c2) { if ((uint8_t)mp->m_keys[mlen] != c2) {
break; 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. // Don't allow mapping the first byte(s) of a multi-byte char.
// Happens when mapping <M-a> and then changing 'encoding'. // Happens when mapping <M-a> and then changing 'encoding'.
// Beware that 0x80 is escaped. // 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); char_u *p2 = (char_u *)mb_unescape((const char **)&p1);
if (p2 != NULL && MB_BYTE2LEN(tb_c1) > utfc_ptr2len((char *)p2)) { 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. // mapping starts with K_SNR.
uint8_t *s = typebuf.tb_noremap + typebuf.tb_off; uint8_t *s = typebuf.tb_noremap + typebuf.tb_off;
if (*s == RM_SCRIPT if (*s == RM_SCRIPT
&& (mp->m_keys[0] != K_SPECIAL && ((uint8_t)mp->m_keys[0] != K_SPECIAL
|| mp->m_keys[1] != KS_EXTRA || (uint8_t)mp->m_keys[1] != KS_EXTRA
|| mp->m_keys[2] != KE_SNR)) { || mp->m_keys[2] != KE_SNR)) {
continue; continue;
} }
@@ -2212,7 +2212,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
vgetc_busy = 0; vgetc_busy = 0;
may_garbage_collect = false; 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) { if (save_m_luaref == LUA_NOREF) {
save_m_str = xstrdup(mp->m_str); 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) { if (save_m_noremap != REMAP_YES) {
noremap = save_m_noremap; 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) { (size_t)keylen) != 0) {
noremap = REMAP_YES; noremap = REMAP_YES;
} else { } else {

View File

@@ -232,7 +232,7 @@ struct prt_ps_resource_S {
char_u filename[MAXPATHL + 1]; char_u filename[MAXPATHL + 1];
PrtResourceType type; PrtResourceType type;
char_u title[256]; char_u title[256];
char_u version[256]; char version[256];
}; };
struct prt_dsc_comment_S { struct prt_dsc_comment_S {
@@ -243,7 +243,7 @@ struct prt_dsc_comment_S {
struct prt_dsc_line_S { struct prt_dsc_line_S {
int type; int type;
char_u *string; char *string;
int len; int len;
}; };
@@ -251,7 +251,7 @@ struct prt_dsc_line_S {
// couple of KB of comments! // couple of KB of comments!
#define PRT_FILE_BUFFER_LEN (2048) #define PRT_FILE_BUFFER_LEN (2048)
struct prt_resfile_buffer_S { struct prt_resfile_buffer_S {
char_u buffer[PRT_FILE_BUFFER_LEN]; char buffer[PRT_FILE_BUFFER_LEN];
int len; int len;
int line_start; int line_start;
int line_end; 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))) { if (len > (prt_resfile.line_end - (prt_resfile.line_start + offset))) {
return 1; return 1;
} }
return STRNCMP(&prt_resfile.buffer[prt_resfile.line_start + offset], return strncmp(&prt_resfile.buffer[prt_resfile.line_start + offset],
string, len); string, (size_t)len);
} }
static int prt_resfile_skip_nonws(int offset) 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 FUNC_ATTR_NONNULL_ALL
{ {
// Version number m.n should match, the revision number does not matter // 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"), semsg(_("E621: \"%s\" resource file has wrong version"),
resource->name); resource->name);
return false; return false;

File diff suppressed because it is too large Load Diff

View File

@@ -893,7 +893,7 @@ static int ins_compl_add(char *const str, int len, char *const fname, char *cons
/// @param match completion match /// @param match completion match
/// @param str character string to check /// @param str character string to check
/// @param len length of "str" /// @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 FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{ {
if (match->cp_flags & CP_EQUAL) { 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) { if (match->cp_flags & CP_ICASE) {
return STRNICMP(match->cp_str, str, len) == 0; 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". /// Reduce the longest common string for match "match".
@@ -1151,7 +1151,7 @@ static int ins_compl_build_pum(void)
do { do {
if (!match_at_original_text(compl) if (!match_at_original_text(compl)
&& (compl_leader == NULL && (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_match_arraysize++;
} }
compl = compl->cp_next; compl = compl->cp_next;
@@ -1176,7 +1176,7 @@ static int ins_compl_build_pum(void)
do { do {
if (!match_at_original_text(compl) if (!match_at_original_text(compl)
&& (compl_leader == NULL && (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 (!shown_match_ok) {
if (compl == compl_shown_match || did_find_shown_match) { if (compl == compl_shown_match || did_find_shown_match) {
// This item is the shown match or this is the // 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 for (cp = compl_shown_match->cp_next; cp != NULL
&& !is_first_match(cp); cp = cp->cp_next) { && !is_first_match(cp); cp = cp->cp_next) {
if (compl_leader == NULL 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; p = cp->cp_str;
break; break;
} }
@@ -3404,7 +3404,7 @@ static int ins_compl_get_exp(pos_T *ini)
static void ins_compl_update_shown_match(void) static void ins_compl_update_shown_match(void)
{ {
while (!ins_compl_equal(compl_shown_match, 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 && compl_shown_match->cp_next != NULL
&& !is_first_match(compl_shown_match->cp_next)) { && !is_first_match(compl_shown_match->cp_next)) {
compl_shown_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 // If we didn't find it searching forward, and compl_shows_dir is
// backward, find the last match. // backward, find the last match.
if (compl_shows_dir_backward() 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 && (compl_shown_match->cp_next == NULL
|| is_first_match(compl_shown_match->cp_next))) { || 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 && compl_shown_match->cp_prev != NULL
&& !is_first_match(compl_shown_match->cp_prev)) { && !is_first_match(compl_shown_match->cp_prev)) {
compl_shown_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) if (!match_at_original_text(compl_shown_match)
&& compl_leader != NULL && compl_leader != NULL
&& !ins_compl_equal(compl_shown_match, && !ins_compl_equal(compl_shown_match,
(char_u *)compl_leader, strlen(compl_leader))) { compl_leader, strlen(compl_leader))) {
todo++; todo++;
} else { } else {
// Remember a matching item. // Remember a matching item.

View File

@@ -570,7 +570,7 @@ char_u *get_special_key_name(int c, int modifiers)
/// @param[out] did_simplify found <C-H>, etc. /// @param[out] did_simplify found <C-H>, etc.
/// ///
/// @return Number of characters added to dst, zero for no match. /// @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) const int flags, const bool escape_ks, bool *const did_simplify)
FUNC_ATTR_NONNULL_ARG(1, 3) FUNC_ATTR_WARN_UNUSED_RESULT 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. /// @param[out] did_simplify FSK_SIMPLIFY and found <C-H>, etc.
/// ///
/// @return Key and modifiers or 0 if there is no match. /// @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) const int flags, bool *const did_simplify)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1, 3) 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 *end_of_name;
const char_u *src; const char_u *src;
const char_u *bp; 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; const bool in_string = flags & FSK_IN_STRING;
int modifiers; int modifiers;
int bit; int bit;
@@ -643,7 +643,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
return 0; return 0;
} }
src = *srcp; src = (char_u *)(*srcp);
if (src[0] != '<') { if (src[0] != '<') {
return 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; *modp = modifiers;
*srcp = end_of_name; *srcp = (char *)end_of_name;
return key; return key;
} // else { ELOG("unknown key: '%s'", src); } } // 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; ssize_t i;
size_t slen; size_t slen;
char_u key; char key;
size_t dlen = 0; size_t dlen = 0;
const char_u *src; const char *src;
const char_u *const end = (char_u *)from + from_len - 1; const char *const end = from + from_len - 1;
char *result; // buffer for resulting string char *result; // buffer for resulting string
const bool do_backslash = !(cpo_flags & FLAG_CPO_BSLASH); // backslash is a special character 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; const size_t buf_len = allocated ? from_len * 6 + 1 : 128;
result = allocated ? xmalloc(buf_len) : *bufp; result = allocated ? xmalloc(buf_len) : *bufp;
src = (char_u *)from; src = from;
// Check for #n at start only: function key n // Check for #n at start only: function key n
if ((flags & REPTERM_FROM_PART) && from_len > 1 && src[0] == '#' 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') { if (src[1] == '0') {
result[dlen++] = ';'; // #0 is F10 is "k;" result[dlen++] = ';'; // #0 is F10 is "k;"
} else { } else {
result[dlen++] = (char)src[1]; // #3 is F3 is "k3" result[dlen++] = src[1]; // #3 is F3 is "k3"
} }
src += 2; 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>" // Check for special <> keycodes, like "<C-S-LeftMouse>"
if (do_special && ((flags & REPTERM_DO_LT) || ((end - src) >= 3 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> _. // Replace <SID> by K_SNR <script-nr> _.
// (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) // (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14)
if (end - src >= 4 && STRNICMP(src, "<SID>", 5) == 0) { 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 src++; // skip CTRL-V or backslash
if (src > end) { if (src > end) {
if (flags & REPTERM_FROM_PART) { if (flags & REPTERM_FROM_PART) {
result[dlen++] = (char)key; result[dlen++] = key;
} }
break; 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--) { 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 // If the character is K_SPECIAL, replace it with K_SPECIAL
// KS_SPECIAL KE_FILLER. // KS_SPECIAL KE_FILLER.
if (*src == K_SPECIAL) { if (*src == (char)K_SPECIAL) {
result[dlen++] = (char)K_SPECIAL; result[dlen++] = (char)K_SPECIAL;
result[dlen++] = (char)KS_SPECIAL; result[dlen++] = (char)KS_SPECIAL;
result[dlen++] = KE_FILLER; result[dlen++] = KE_FILLER;
} else { } else {
result[dlen++] = (char)(*src); result[dlen++] = *src;
} }
src++; src++;
} }

View File

@@ -158,7 +158,7 @@ static void showmap(mapblock_T *mp, bool local)
{ {
size_t len = 1; 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))) { && (mp->m_desc == NULL || message_filtered(mp->m_desc))) {
return; return;
} }
@@ -182,7 +182,7 @@ static void showmap(mapblock_T *mp, bool local)
} }
// Display the LHS. Get length of what we write. // 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 { do {
msg_putchar(' '); // pad with blanks msg_putchar(' '); // pad with blanks
len++; 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_str = args->rhs;
mp->m_orig_str = (char *)args->orig_rhs; mp->m_orig_str = (char *)args->orig_rhs;
mp->m_luaref = args->rhs_lua; 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->orig_rhs = NULL;
args->rhs_lua = LUA_NOREF; 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_noremap = noremap;
mp->m_nowait = args->nowait; mp->m_nowait = args->nowait;
mp->m_silent = args->silent; 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; mp->m_next = *abbr_table;
*abbr_table = mp; *abbr_table = mp;
} else { } 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]; mp->m_next = map_table[n];
map_table[n] = mp; 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) static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T *buf)
{ {
mapblock_T *mp, **mpp; mapblock_T *mp, **mpp;
const char_u *p; const char *p;
int n; int n;
int retval = 0; int retval = 0;
mapblock_T **abbr_table; mapblock_T **abbr_table;
@@ -553,7 +553,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
goto theend; 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; const bool did_simplify = args->alt_lhs_len != 0;
// The following is done twice if we have two versions of keys // 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) { if (!did_simplify) {
break; break;
} }
lhs = (char_u *)&args->alt_lhs; lhs = (char *)&args->alt_lhs;
len = (int)args->alt_lhs_len; len = (int)args->alt_lhs_len;
} else if (did_simplify && do_print) { } else if (did_simplify && do_print) {
// when printing always use the not-simplified map // 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; 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. // vi-compatible way.
int same = -1; int same = -1;
const int first = vim_iswordp(lhs); const int first = vim_iswordp((char_u *)lhs);
int last = first; int last = first;
p = lhs + utfc_ptr2len((char *)lhs); p = (char *)lhs + utfc_ptr2len((char *)lhs);
n = 1; n = 1;
while (p < lhs + len) { while (p < (char *)lhs + len) {
n++; // nr of (multi-byte) chars 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) { if (same == -1 && last != first) {
same = n - 1; // count of same char type 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 // check entries with the same mode
if ((mp->m_mode & mode) != 0 if ((mp->m_mode & mode) != 0
&& mp->m_keylen == len && 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) { if (is_abbrev) {
semsg(_("E224: global abbreviation already exists for %s"), semsg(_("E224: global abbreviation already exists for %s"),
mp->m_keys); mp->m_keys);
@@ -674,7 +674,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
did_local = true; did_local = true;
} else { } else {
n = mp->m_keylen; 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); showmap(mp, true);
did_local = 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; int hash_start, hash_end;
if (has_lhs || is_abbrev) { if (has_lhs || is_abbrev) {
// just use one hash // 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; hash_end = hash_start + 1;
} else { } else {
// need to loop over all hash lists // 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? } else { // do we have a match?
if (round) { // second round: Try unmap "rhs" string if (round) { // second round: Try unmap "rhs" string
n = (int)strlen(mp->m_str); n = (int)strlen(mp->m_str);
p = (char_u *)mp->m_str; p = mp->m_str;
} else { } else {
n = mp->m_keylen; n = mp->m_keylen;
p = mp->m_keys; 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) { if (maptype == MAPTYPE_UNMAP) {
// Delete entry. // Delete entry.
// Only accept a full match. For abbreviations // 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. // 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) { if (!is_abbrev && new_hash != hash) {
*mpp = mp->m_next; *mpp = mp->m_next;
mp->m_next = map_table[new_hash]; 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; continue;
} }
// May need to put this entry into another hash list. // 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) { if (!abbr && new_hash != hash) {
*mpp = mp->m_next; *mpp = mp->m_next;
if (local) { if (local) {
@@ -1325,7 +1325,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char ***file)
} }
for (; mp; mp = mp->m_next) { for (; mp; mp = mp->m_next) {
if (mp->m_mode & expand_mapmodes) { 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 (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) {
if (round == 1) { if (round == 1) {
count++; count++;
@@ -1387,7 +1387,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char ***file)
// Then there must be white space before the abbr. // Then there must be white space before the abbr.
// //
// Return true if there is an abbreviation, false if not. // 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 len;
int scol; // starting column of the abbr. 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; 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)) { if (!vim_iswordp(p)) {
vim_abbr = true; // Vim added abbr. vim_abbr = true; // Vim added abbr.
} else { } else {
vim_abbr = false; // vi compatible abbr. vim_abbr = false; // vi compatible abbr.
if (p > ptr) { if (p > (char_u *)ptr) {
is_id = vim_iswordp(mb_prevptr(ptr, p)); is_id = vim_iswordp(mb_prevptr((char_u *)ptr, p));
} }
} }
clen = 1; clen = 1;
while (p > ptr + mincol) { while (p > (char_u *)ptr + mincol) {
p = mb_prevptr(ptr, p); p = mb_prevptr((char_u *)ptr, p);
if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) { if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) {
p += utfc_ptr2len((char *)p); p += utfc_ptr2len((char *)p);
break; break;
} }
clen++; clen++;
} }
scol = (int)(p - ptr); scol = (int)(p - (char_u *)ptr);
} }
if (scol < mincol) { 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->m_next == NULL ? (mp = mp2, mp2 = NULL) :
(mp = mp->m_next)) { (mp = mp->m_next)) {
int qlen = mp->m_keylen; int qlen = mp->m_keylen;
char *q = (char *)mp->m_keys; char *q = mp->m_keys;
int match; int match;
if (strchr((const char *)mp->m_keys, K_SPECIAL) != NULL) { if (strchr((const char *)mp->m_keys, K_SPECIAL) != NULL) {
// Might have K_SPECIAL escaped mp->m_keys. // 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); vim_unescape_ks((char_u *)q);
qlen = (int)strlen(q); qlen = (int)strlen(q);
} }
// find entries with right mode and keys // find entries with right mode and keys
match = (mp->m_mode & State) match = (mp->m_mode & State)
&& qlen == len && qlen == len
&& !STRNCMP(q, ptr, (size_t)len); && !strncmp(q, ptr, (size_t)len);
if (q != (char *)mp->m_keys) { if (q != mp->m_keys) {
xfree(q); xfree(q);
} }
if (match) { if (match) {
@@ -1797,7 +1797,7 @@ int makemap(FILE *fd, buf_T *buf)
} }
if (putc(' ', fd) < 0 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 || putc(' ', fd) < 0
|| put_escstr(fd, (char_u *)mp->m_str, 1) == FAIL || put_escstr(fd, (char_u *)mp->m_str, 1) == FAIL
|| put_eol(fd) < 0) { || 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) { for (; mp != NULL; mp = mp->m_next) {
// skip entries with wrong mode, wrong length and not matching ones // skip entries with wrong mode, wrong length and not matching ones
if ((mp->m_mode & mode) && (!exact || mp->m_keylen == len)) { 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; int keylen = mp->m_keylen;
if (ign_mod && keylen >= 3 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; s += 3;
keylen -= 3; keylen -= 3;
} }
minlen = keylen < len ? keylen : len; minlen = keylen < len ? keylen : len;
if (STRNCMP(s, keys, minlen) == 0) { if (strncmp(s, keys, (size_t)minlen) == 0) {
if (mp_ptr != NULL) { if (mp_ptr != NULL) {
*mp_ptr = mp; *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) FUNC_ATTR_NONNULL_ARG(1)
{ {
Dictionary dict = ARRAY_DICT_INIT; 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); char *const mapmode = map_mode_to_chars(mp->m_mode);
varnumber_T noremap_value; varnumber_T noremap_value;

View File

@@ -2751,7 +2751,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar)
return FAIL; return FAIL;
} }
assert(len <= INT_MAX); 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 == 'w' || nchar == 'W' ? SPELL_ADD_BAD : SPELL_ADD_GOOD,
(nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1, (nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1,
undo); undo);

View File

@@ -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 find_key_option_len(const char_u *arg_arg, size_t len, bool has_lt)
{ {
int key = 0; 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 // Don't use get_special_key_code() for t_xx, we don't want it to call
// add_termcap_entry(). // add_termcap_entry().
if (len >= 4 && arg[0] == 't' && arg[1] == '_') { 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) { } else if (has_lt) {
arg--; // put arg at the '<' arg--; // put arg at the '<'
int modifiers = 0; int modifiers = 0;

View File

@@ -266,7 +266,7 @@ size_t input_enqueue(String keys)
uint8_t buf[19] = { 0 }; uint8_t buf[19] = { 0 };
// Do not simplify the keys here. Simplification will be done later. // Do not simplify the keys here. Simplification will be done later.
unsigned int new_size 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) { if (new_size) {
new_size = handle_mouse_event(&ptr, buf, new_size); new_size = handle_mouse_event(&ptr, buf, new_size);

View File

@@ -144,7 +144,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
bool is_fish_shell = bool is_fish_shell =
#if defined(UNIX) #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 #else
false; false;
#endif #endif

View File

@@ -222,7 +222,7 @@ int match_user(char *name)
if (strcmp(((char **)ga_users.ga_data)[i], name) == 0) { if (strcmp(((char **)ga_users.ga_data)[i], name) == 0) {
return 2; // full match 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 result = 1; // partial match
} }
} }

View File

@@ -233,7 +233,7 @@ static int get_char_class(char **pp)
if ((*pp)[1] == ':') { if ((*pp)[1] == ':') {
for (i = 0; i < (int)ARRAY_SIZE(class_names); i++) { 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; *pp += strlen(class_names[i]) + 2;
return i; return i;
} }
@@ -1380,7 +1380,7 @@ static int cstrncmp(char *s1, char *s2, int *n)
int result; int result;
if (!rex.reg_ic) { if (!rex.reg_ic) {
result = STRNCMP(s1, s2, *n); result = strncmp(s1, s2, (size_t)(*n));
} else { } else {
assert(*n >= 0); assert(*n >= 0);
result = mb_strnicmp(s1, s2, (size_t)(*n)); 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 *vim_regcomp(char *expr_arg, int re_flags)
{ {
regprog_T *prog = NULL; regprog_T *prog = NULL;
char_u *expr = (char_u *)expr_arg; char *expr = expr_arg;
regexp_engine = (int)p_re; regexp_engine = (int)p_re;
// Check for prefix "\%#=", that sets the regexp engine // Check for prefix "\%#=", that sets the regexp engine
if (STRNCMP(expr, "\\%#=", 4) == 0) { if (strncmp(expr, "\\%#=", 4) == 0) {
int newengine = expr[4] - '0'; int newengine = expr[4] - '0';
if (newengine == AUTOMATIC_ENGINE 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; const int called_emsg_before = called_emsg;
if (regexp_engine != BACKTRACKING_ENGINE) { 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)); re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0));
} else { } 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. // 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. // But don't try if an error message was given.
if (regexp_engine == AUTOMATIC_ENGINE && called_emsg == called_emsg_before) { if (regexp_engine == AUTOMATIC_ENGINE && called_emsg == called_emsg_before) {
regexp_engine = BACKTRACKING_ENGINE; regexp_engine = BACKTRACKING_ENGINE;
report_re_switch(expr); report_re_switch((char_u *)expr);
prog = bt_regengine.regcomp(expr, re_flags); prog = bt_regengine.regcomp((char_u *)expr, re_flags);
} }
} }

View File

@@ -130,7 +130,7 @@ typedef struct matchinf_S {
langp_T *mi_lp; // info for language and region langp_T *mi_lp; // info for language and region
// pointers to original text to be checked // 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_end; // end of matching word so far
char_u *mi_fend; // next char to be added to mi_fword char_u *mi_fend; // next char to be added to mi_fword
char_u *mi_cend; // char after what was used for char_u *mi_cend; // char after what was used for
@@ -173,7 +173,7 @@ typedef struct spelload_S {
#define SY_MAXLEN 30 #define SY_MAXLEN 30
typedef struct syl_item_S { 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; int sy_len;
} syl_item_T; } 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). // 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; mi.mi_fend = ptr;
if (spell_iswordp(mi.mi_fend, wp)) { if (spell_iswordp(mi.mi_fend, wp)) {
bool this_upper = false; // init for gcc 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. // at which any word would be valid.
mi.mi_lp = LANGP_ENTRY(wp->w_s->b_langp, 0); mi.mi_lp = LANGP_ENTRY(wp->w_s->b_langp, 0);
if (mi.mi_lp->lp_slang->sl_fidxs != NULL) { 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; fp = (char_u *)mi.mi_fword;
for (;;) { for (;;) {
MB_PTR_ADV(p); MB_PTR_ADV(p);
@@ -435,7 +435,7 @@ static void find_word(matchinf_T *mip, int mode)
{ {
int wlen = 0; int wlen = 0;
int flen; int flen;
char_u *ptr; char *ptr;
slang_T *slang = mip->mi_lp->lp_slang; slang_T *slang = mip->mi_lp->lp_slang;
char_u *byts; char_u *byts;
idx_T *idxs; idx_T *idxs;
@@ -453,7 +453,7 @@ static void find_word(matchinf_T *mip, int mode)
} }
} else { } else {
// Check for case-folded in case-folded tree. // 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 flen = mip->mi_fwordlen; // available case-folded bytes
byts = slang->sl_fbyts; byts = slang->sl_fbyts;
idxs = slang->sl_fidxs; 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. // 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> if (c == TAB) { // <Tab> is handled like <Space>
c = ' '; c = ' ';
} }
@@ -562,7 +562,7 @@ static void find_word(matchinf_T *mip, int mode)
} }
} }
char_u *p; char *p;
bool word_ends; bool word_ends;
// Verify that one of the possible endings is valid. Try the longest // 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]; arridx = endidx[endidxcnt];
wlen = endlen[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 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) { if (slang->sl_compprog == NULL && !slang->sl_nobreak) {
continue; // next char is a word character 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 // when folding case. This can be slow, take a shortcut when the
// case-folded word is equal to the keep-case word. // case-folded word is equal to the keep-case word.
p = mip->mi_word; p = mip->mi_word;
if (STRNCMP(ptr, p, wlen) != 0) { if (strncmp(ptr, p, (size_t)wlen) != 0) {
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) { for (char *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
MB_PTR_ADV(p); MB_PTR_ADV(p);
} }
wlen = (int)(p - mip->mi_word); 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 // For keep-case tree the case is always right. For prefixes we
// don't bother to check. // don't bother to check.
if (mode == FIND_FOLDWORD) { 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 // mi_capflags was set for a different word length, need
// to do it again. // to do it again.
mip->mi_cend = mip->mi_word + wlen; mip->mi_cend = (char_u *)mip->mi_word + wlen;
mip->mi_capflags = captype(mip->mi_word, mip->mi_cend); mip->mi_capflags = captype((char_u *)mip->mi_word, mip->mi_cend);
} }
if (mip->mi_capflags == WF_KEEPCAP 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. // mip->mi_prefarridx that find_prefix() filled.
c = valid_word_prefix(mip->mi_prefcnt, mip->mi_prefarridx, c = valid_word_prefix(mip->mi_prefcnt, mip->mi_prefarridx,
(int)flags, (int)flags,
mip->mi_word + mip->mi_cprefixlen, slang, (char_u *)mip->mi_word + mip->mi_cprefixlen, slang,
false); false);
if (c == 0) { if (c == 0) {
continue; continue;
@@ -664,7 +664,7 @@ static void find_word(matchinf_T *mip, int mode)
// For multi-byte chars check character length against // For multi-byte chars check character length against
// COMPOUNDMIN. // COMPOUNDMIN.
if (slang->sl_compminlen > 0 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) { wlen - mip->mi_compoff) < slang->sl_compminlen) {
continue; continue;
} }
@@ -703,16 +703,16 @@ static void find_word(matchinf_T *mip, int mode)
// Need to check the caps type of the appended compound // Need to check the caps type of the appended compound
// word. // 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 // case folding may have changed the length
p = mip->mi_word; 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); MB_PTR_ADV(p);
} }
} else { } else {
p = mip->mi_word + mip->mi_compoff; 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 if (capflags == WF_KEEPCAP || (capflags == WF_ALLCAP
&& (flags & WF_FIXCAP) != 0)) { && (flags & WF_FIXCAP) != 0)) {
continue; continue;
@@ -724,7 +724,7 @@ static void find_word(matchinf_T *mip, int mode)
// accept a no-caps word, even when the dictionary // accept a no-caps word, even when the dictionary
// word specifies ONECAP. // word specifies ONECAP.
MB_PTR_BACK(mip->mi_word, p); 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 ? capflags == WF_ONECAP
: (flags & WF_ONECAP) != 0 : (flags & WF_ONECAP) != 0
&& capflags != WF_ONECAP) { && capflags != WF_ONECAP) {
@@ -744,7 +744,7 @@ static void find_word(matchinf_T *mip, int mode)
if (slang->sl_compsylmax < MAXWLEN) { if (slang->sl_compsylmax < MAXWLEN) {
// "fword" is only needed for checking syllables. // "fword" is only needed for checking syllables.
if (ptr == mip->mi_word) { 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 { } else {
STRLCPY(fword, ptr, endlen[endidxcnt] + 1); 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 // byte length in keep-case word. Length may change when
// folding case. This can be slow, take a shortcut when // folding case. This can be slow, take a shortcut when
// the case-folded word is equal to the keep-case word. // the case-folded word is equal to the keep-case word.
p = (char_u *)mip->mi_fword; p = mip->mi_fword;
if (STRNCMP(ptr, p, wlen) != 0) { if (strncmp(ptr, p, (size_t)wlen) != 0) {
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) { for (char *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
MB_PTR_ADV(p); MB_PTR_ADV(p);
} }
mip->mi_compoff = (int)(p - (char_u *)mip->mi_fword); mip->mi_compoff = (int)(p - mip->mi_fword);
} }
} }
#if 0 #if 0
@@ -878,16 +878,16 @@ static void find_word(matchinf_T *mip, int mode)
if (nobreak_result == SP_BAD) { if (nobreak_result == SP_BAD) {
if (mip->mi_result2 > res) { if (mip->mi_result2 > res) {
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 } else if (mip->mi_result2 == res
&& mip->mi_end2 < mip->mi_word + wlen) { && mip->mi_end2 < (char_u *)mip->mi_word + wlen) {
mip->mi_end2 = mip->mi_word + wlen; mip->mi_end2 = (char_u *)mip->mi_word + wlen;
} }
} else if (mip->mi_result > res) { } else if (mip->mi_result > res) {
mip->mi_result = res; mip->mi_result = res;
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 < mip->mi_word + wlen) { } else if (mip->mi_result == res && mip->mi_end < (char_u *)mip->mi_word + wlen) {
mip->mi_end = mip->mi_word + wlen; mip->mi_end = (char_u *)mip->mi_word + wlen;
} }
if (mip->mi_result == SP_OK) { 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. /// end of ptr[wlen] and the second part matches after it.
/// ///
/// @param gap &sl_comppat /// @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) { for (int i = 0; i + 1 < gap->ga_len; i += 2) {
char *p = ((char **)gap->ga_data)[i + 1]; 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 // Second part matches at start of following compound word, now
// check if first part matches at end of previous word. // check if first part matches at end of previous word.
p = ((char **)gap->ga_data)[i]; p = ((char **)gap->ga_data)[i];
int len = (int)strlen(p); 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; return true;
} }
} }
@@ -1111,7 +1111,7 @@ static void find_prefix(matchinf_T *mip, int mode)
// Case-folded length may differ from original length. // Case-folded length may differ from original length.
mip->mi_cprefixlen = nofold_len((char_u *)mip->mi_fword, mip->mi_prefixlen, 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); find_word(mip, FIND_PREFIX);
if (len == 0) { if (len == 0) {
@@ -1809,7 +1809,7 @@ static int count_syllables(slang_T *slang, const char_u *word)
return 0; 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. // When running into a space reset counter.
if (*p == ' ') { if (*p == ' ') {
len = 1; 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++) { 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; syl_item_T *syl = ((syl_item_T *)slang->sl_syl_items.ga_data) + i;
if (syl->sy_len > len 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; len = syl->sy_len;
} }
} }
@@ -1831,8 +1831,8 @@ static int count_syllables(slang_T *slang, const char_u *word)
skip = false; skip = false;
} else { } else {
// No recognized syllable item, at least a syllable char then? // No recognized syllable item, at least a syllable char then?
int c = utf_ptr2char((char *)p); int c = utf_ptr2char(p);
len = utfc_ptr2len((char *)p); len = utfc_ptr2len(p);
if (vim_strchr((char *)slang->sl_syllable, c) == NULL) { if (vim_strchr((char *)slang->sl_syllable, c) == NULL) {
skip = false; // No, search for next syllable skip = false; // No, search for next syllable
} else if (!skip) { } else if (!skip) {

View File

@@ -72,8 +72,8 @@ typedef int idx_T;
// si_repsal, sl_rep, and si_sal. Not for sl_sal! // si_repsal, sl_rep, and si_sal. Not for sl_sal!
// One replacement: from "ft_from" to "ft_to". // One replacement: from "ft_from" to "ft_to".
typedef struct fromto_S { typedef struct fromto_S {
uint8_t *ft_from; char *ft_from;
uint8_t *ft_to; char *ft_to;
} fromto_T; } fromto_T;
// Info from "SAL" entries in ".aff" file used in sl_sal. // Info from "SAL" entries in ".aff" file used in sl_sal.

View File

@@ -899,7 +899,7 @@ void suggest_load_files(void)
slang_T *slang; slang_T *slang;
char *dotp; char *dotp;
FILE *fd; FILE *fd;
char_u buf[MAXWLEN]; char buf[MAXWLEN];
int i; int i;
time_t timestamp; time_t timestamp;
int wcount; int wcount;
@@ -929,9 +929,9 @@ void suggest_load_files(void)
// <SUGHEADER>: <fileID> <versionnr> <timestamp> // <SUGHEADER>: <fileID> <versionnr> <timestamp>
for (i = 0; i < VIMSUGMAGICL; i++) { 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"), semsg(_("E778: This does not look like a .sug file: %s"),
slang->sl_fname); slang->sl_fname);
goto nextone; 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) { for (; gap->ga_len < cnt; ++gap->ga_len) {
int c; int c;
ftp = &((fromto_T *)gap->ga_data)[gap->ga_len]; 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) { if (c < 0) {
return c; return c;
} }
if (c == 0) { if (c == 0) {
return SP_FORMERROR; 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) { if (c <= 0) {
xfree(ftp->ft_from); xfree(ftp->ft_from);
if (c < 0) { 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++) { for (int i = 0; i < gap->ga_len; i++) {
ftp = &((fromto_T *)gap->ga_data)[i]; ftp = &((fromto_T *)gap->ga_data)[i];
if (first[*ftp->ft_from] == -1) { if (first[(uint8_t)(*ftp->ft_from)] == -1) {
first[*ftp->ft_from] = (int16_t)i; first[(uint8_t)(*ftp->ft_from)] = (int16_t)i;
} }
} }
return 0; 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); fromto_T *ftp = GA_APPEND_VIA_PTR(fromto_T, gap);
(void)spell_casefold(curwin, (char_u *)from, (int)strlen(from), word, MAXWLEN); (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); (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; /// 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 *p1 = (fromto_T *)s1;
fromto_T *p2 = (fromto_T *)s2; 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". /// 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); assert(gap->ga_len >= 0);
for (size_t i = 0; i < (size_t)gap->ga_len; i++) { for (size_t i = 0; i < (size_t)gap->ga_len; i++) {
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i]; fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
l += 1 + strlen((char *)ftp->ft_from); // count <*fromlen> and <*from> l += 1 + strlen(ftp->ft_from); // count <*fromlen> and <*from>
l += 1 + strlen((char *)ftp->ft_to); // count <*tolen> and <*to> l += 1 + strlen(ftp->ft_to); // count <*tolen> and <*to>
} }
if (round == 2) { if (round == 2) {
l++; // count <salflags> l++; // count <salflags>
@@ -4544,7 +4544,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
// <sal> : <salfromlen> <salfrom> <saltolen> <salto> // <sal> : <salfromlen> <salfrom> <saltolen> <salto>
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i]; fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
for (unsigned int rr = 1; rr <= 2; rr++) { 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); l = strlen(p);
assert(l < INT_MAX); assert(l < INT_MAX);
putc((int)l, fd); putc((int)l, fd);
@@ -5516,7 +5516,7 @@ static void spell_message(const spellinfo_T *spin, char *str)
// ":[count]spellrare {word}" // ":[count]spellrare {word}"
void ex_spell(exarg_T *eap) 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_spellwrong ? SPELL_ADD_BAD :
eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD, eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD,
eap->forceit ? 0 : (int)eap->line2, eap->forceit ? 0 : (int)eap->line2,
@@ -5528,19 +5528,19 @@ void ex_spell(exarg_T *eap)
/// @param what SPELL_ADD_ values /// @param what SPELL_ADD_ values
/// @param idx "zG" and "zW": zero, otherwise index in 'spellfile' /// @param idx "zG" and "zW": zero, otherwise index in 'spellfile'
/// @param bool // true for "zug", "zuG", "zuw" and "zuW" /// @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; FILE *fd = NULL;
buf_T *buf = NULL; buf_T *buf = NULL;
bool new_spf = false; bool new_spf = false;
char *fname; char *fname;
char_u *fnamebuf = NULL; char_u *fnamebuf = NULL;
char_u line[MAXWLEN * 2]; char line[MAXWLEN * 2];
long fpos, fpos_next = 0; long fpos, fpos_next = 0;
int i; int i;
char_u *spf; 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)); emsg(_(e_illegal_character_in_word));
return; return;
} }
@@ -5603,8 +5603,8 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo
if (fpos_next < 0) { if (fpos_next < 0) {
break; // should never happen break; // should never happen
} }
if (STRNCMP(word, line, len) == 0 if (strncmp(word, line, (size_t)len) == 0
&& (line[len] == '/' || line[len] < ' ')) { && (line[len] == '/' || (uint8_t)line[len] < ' ')) {
// Found duplicate word. Remove it by writing a '#' at // Found duplicate word. Remove it by writing a '#' at
// the start of the line. Mixing reading and writing // the start of the line. Mixing reading and writing
// doesn't work for all systems, close the file first. // doesn't work for all systems, close the file first.

View File

@@ -75,7 +75,7 @@ typedef struct suginfo_S {
int su_badlen; ///< length of detected bad word in line int su_badlen; ///< length of detected bad word in line
int su_badflags; ///< caps flags for bad word int su_badflags; ///< caps flags for bad word
char_u su_badword[MAXWLEN]; ///< bad word truncated at su_badlen 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 char_u su_sal_badword[MAXWLEN]; ///< su_badword soundfolded
hashtab_T su_banned; ///< table with banned words hashtab_T su_banned; ///< table with banned words
slang_T *su_sallang; ///< default language for sound folding 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 su->su_badlen = MAXWLEN - 1; // just in case
} }
STRLCPY(su->su_badword, su->su_badptr, su->su_badlen + 1); 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); MAXWLEN);
// TODO(vim): make this work if the case-folded text is longer than the // 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. /// Try finding suggestions by recognizing specific situations.
static void suggest_try_special(suginfo_T *su) static void suggest_try_special(suginfo_T *su)
{ {
int c; char c;
char_u word[MAXWLEN]; char_u word[MAXWLEN];
// Recognize a word that is repeated: "the the". // Recognize a word that is repeated: "the the".
char *p = skiptowhite((char *)su->su_fbadword); char *p = skiptowhite((char *)su->su_fbadword);
size_t len = (size_t)(p - (char *)su->su_fbadword); size_t len = (size_t)(p - (char *)su->su_fbadword);
p = skipwhite(p); 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 // Include badflags: if the badword is onecap or allcap
// use that for the goodword too: "The the" -> "The". // use that for the goodword too: "The the" -> "The".
c = su->su_fbadword[len]; c = su->su_fbadword[len];
su->su_fbadword[len] = NUL; su->su_fbadword[len] = NUL;
make_case_word(su->su_fbadword, word, su->su_badflags); make_case_word((char_u *)su->su_fbadword, word, su->su_badflags);
su->su_fbadword[len] = (char_u)c; su->su_fbadword[len] = c;
// Give a soundalike score of 0, compute the score as if deleting one // Give a soundalike score of 0, compute the score as if deleting one
// character. // character.
@@ -1106,7 +1106,7 @@ static void suggest_try_change(suginfo_T *su)
#ifdef SUGGEST_PROFILE #ifdef SUGGEST_PROFILE
prof_init(); prof_init();
#endif #endif
suggest_trie_walk(su, lp, (char_u *)fword, false); suggest_trie_walk(su, lp, fword, false);
#ifdef SUGGEST_PROFILE #ifdef SUGGEST_PROFILE
prof_report("try_change"); prof_report("try_change");
#endif #endif
@@ -1146,9 +1146,9 @@ static void suggest_try_change(suginfo_T *su)
/// word splitting for now /// word splitting for now
/// "similar_chars()" /// "similar_chars()"
/// use "slang->sl_repsal" instead of "lp->lp_replang->sl_rep" /// 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]; trystate_T stack[MAXWLEN];
char preword[MAXWLEN * 3] = { 0 }; // word found with proper case; char preword[MAXWLEN * 3] = { 0 }; // word found with proper case;
// concatenation of prefix compound // 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; garray_T *gap;
idx_T arridx; idx_T arridx;
int len; int len;
char_u *p; char *p;
fromto_T *ftp; fromto_T *ftp;
int fl = 0, tl; int fl = 0, tl;
int repextra = 0; // extra bytes in fword[] from REP item 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)) { if (depth < MAXWLEN - 1 && (byts[arridx] == 0 || n == STATE_NOPREFIX)) {
// Set su->su_badflags to the caps type at this position. // Set su->su_badflags to the caps type at this position.
// Use the caps type until here for the prefix itself. // 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); 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, su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
(char_u *)su->su_badptr + su->su_badlen); (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 // Move the prefix to preword[] with the right case
// and make find_keepcap_word() works. // and make find_keepcap_word() works.
tword[sp->ts_twordlen] = NUL; 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); (char_u *)preword + sp->ts_prewordlen, flags);
sp->ts_prewordlen = (char_u)strlen(preword); sp->ts_prewordlen = (char_u)strlen(preword);
sp->ts_splitoff = sp->ts_twordlen; 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 fword_ends = (fword[sp->ts_fidx] == NUL
|| (soundfold || (soundfold
? ascii_iswhite(fword[sp->ts_fidx]) ? 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; tword[sp->ts_twordlen] = NUL;
if (sp->ts_prefixdepth <= PFD_NOTSPECIAL 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++) {} for (c = 0; c < len && pbyts[n + c] == 0; c++) {}
if (c > 0) { if (c > 0) {
c = valid_word_prefix(c, n, flags, c = valid_word_prefix(c, n, flags,
tword + sp->ts_splitoff, slang, false); (char_u *)tword + sp->ts_splitoff, slang, false);
if (c == 0) { if (c == 0) {
break; 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. // need to check if a correct word follows.
if (sp->ts_fidx - sp->ts_splitfidx if (sp->ts_fidx - sp->ts_splitfidx
== sp->ts_twordlen - sp->ts_splitoff == sp->ts_twordlen - sp->ts_splitoff
&& STRNCMP(fword + sp->ts_splitfidx, && strncmp(fword + sp->ts_splitfidx,
tword + sp->ts_splitoff, tword + sp->ts_splitoff,
sp->ts_fidx - sp->ts_splitfidx) == 0) { sp->ts_fidx - sp->ts_splitfidx) == 0) {
preword[sp->ts_prewordlen] = NUL; 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 // For multi-byte chars check character length against
// COMPOUNDMIN. // COMPOUNDMIN.
if (slang->sl_compminlen > 0 if (slang->sl_compminlen > 0
&& mb_charlen(tword + sp->ts_splitoff) && mb_charlen((char_u *)tword + sp->ts_splitoff)
< slang->sl_compminlen) { < slang->sl_compminlen) {
break; 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); sp->ts_twordlen - sp->ts_splitoff + 1);
// Verify CHECKCOMPOUNDPATTERN rules. // Verify CHECKCOMPOUNDPATTERN rules.
if (match_checkcompoundpattern((char_u *)preword, sp->ts_prewordlen, if (match_checkcompoundpattern(preword, sp->ts_prewordlen,
&slang->sl_comppat)) { &slang->sl_comppat)) {
compound_ok = false; compound_ok = false;
} }
if (compound_ok) { if (compound_ok) {
p = (char_u *)preword; p = preword;
while (*skiptowhite((char *)p) != NUL) { while (*skiptowhite(p) != NUL) {
p = (char_u *)skipwhite(skiptowhite((char *)p)); 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 // Compound is not allowed. But it may still be
// possible if we add another (short) word. // possible if we add another (short) word.
compound_ok = false; 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. // 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); 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 // When appending a compound word after a word character don't
// use Onecap. // use Onecap.
if (p != NULL && spell_iswordp_nmw(p, curwin)) { if (p != NULL && spell_iswordp_nmw((char_u *)p, curwin)) {
c &= ~WF_ONECAP; 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); (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". // char, e.g., "thes," -> "these".
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
MB_PTR_BACK(fword, p); MB_PTR_BACK(fword, p);
if (!spell_iswordp(p, curwin) && *preword != NUL) { if (!spell_iswordp((char_u *)p, curwin) && *preword != NUL) {
p = (char_u *)preword + strlen(preword); p = preword + strlen(preword);
MB_PTR_BACK(preword, p); MB_PTR_BACK(preword, p);
if (spell_iswordp(p, curwin)) { if (spell_iswordp((char_u *)p, curwin)) {
newscore += SCORE_NONWORD; 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. // upper or lower case, add both.
c = captype((char_u *)preword, NULL); c = captype((char_u *)preword, NULL);
if (c == 0 || c == WF_ALLCAP) { 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, (char_u *)preword + sp->ts_prewordlen,
c == 0 ? WF_ALLCAP : 0); 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 && sp->ts_twordlen - sp->ts_splitoff
>= slang->sl_compminlen >= slang->sl_compminlen
&& (slang->sl_compminlen == 0 && (slang->sl_compminlen == 0
|| mb_charlen(tword + sp->ts_splitoff) || mb_charlen((char_u *)tword + sp->ts_splitoff)
>= slang->sl_compminlen) >= slang->sl_compminlen)
&& (slang->sl_compsylmax < MAXWLEN && (slang->sl_compsylmax < MAXWLEN
|| sp->ts_complen + 1 - sp->ts_compsplit || 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)) { && (flags & WF_NEEDCOMP)) {
break; break;
} }
p = (char_u *)preword; p = preword;
while (*skiptowhite((char *)p) != NUL) { while (*skiptowhite(p) != NUL) {
p = (char_u *)skipwhite(skiptowhite((char *)p)); p = skipwhite(skiptowhite(p));
} }
if (sp->ts_complen > sp->ts_compsplit 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; 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 // non-word character with a space. Always skip a
// character when the word ends. But only when the // character when the word ends. But only when the
// good word can end. // good word can end.
if (((!try_compound && !spell_iswordp_nmw(fword if (((!try_compound && !spell_iswordp_nmw((char_u *)fword
+ sp->ts_fidx, + sp->ts_fidx,
curwin)) curwin))
|| fword_ends) || fword_ends)
@@ -1681,7 +1681,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
&& goodword_ends) { && goodword_ends) {
int l; int l;
l = utfc_ptr2len((char *)fword + sp->ts_fidx); l = utfc_ptr2len(fword + sp->ts_fidx);
if (fword_ends) { if (fword_ends) {
// Copy the skipped character to preword. // Copy the skipped character to preword.
memmove(preword + sp->ts_prewordlen, fword + sp->ts_fidx, (size_t)l); 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 // set su->su_badflags to the caps type at this
// position // 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, su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
(char_u *)su->su_badptr + su->su_badlen); (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 // when the byte was already changed. And don't try when we
// just deleted this byte, accepting it is always cheaper than // just deleted this byte, accepting it is always cheaper than
// delete + substitute. // delete + substitute.
if (c == fword[sp->ts_fidx] if (c == (uint8_t)fword[sp->ts_fidx]
|| (sp->ts_tcharlen > 0 || (sp->ts_tcharlen > 0
&& sp->ts_isdiff != DIFF_NONE)) { && sp->ts_isdiff != DIFF_NONE)) {
newscore = 0; 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 if ((newscore == 0
|| (sp->ts_fidx >= sp->ts_fidxtry || (sp->ts_fidx >= sp->ts_fidxtry
&& ((sp->ts_flags & TSF_DIDDEL) == 0 && ((sp->ts_flags & TSF_DIDDEL) == 0
|| c != fword[sp->ts_delidx]))) || c != (uint8_t)fword[sp->ts_delidx])))
&& TRY_DEEPER(su, stack, depth, newscore)) { && TRY_DEEPER(su, stack, depth, newscore)) {
go_deeper(stack, depth, newscore); go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK #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) { if (fword[sp->ts_fidx] != NUL) {
sp->ts_fidx++; sp->ts_fidx++;
} }
tword[sp->ts_twordlen++] = (char_u)c; tword[sp->ts_twordlen++] = (char)c;
sp->ts_arridx = idxs[arridx]; sp->ts_arridx = idxs[arridx];
if (newscore == SCORE_SUBST) { if (newscore == SCORE_SUBST) {
sp->ts_isdiff = DIFF_YES; 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 // Correct ts_fidx for the byte length of the
// character (we didn't check that before). // character (we didn't check that before).
sp->ts_fidx = (char_u)(sp->ts_fcharstart 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 // For changing a composing character adjust
// the score from SCORE_SUBST to // the score from SCORE_SUBST to
// SCORE_SUBCOMP. // SCORE_SUBCOMP.
if (utf_iscomposing(utf_ptr2char((char *)tword + sp->ts_twordlen if (utf_iscomposing(utf_ptr2char((char *)tword + sp->ts_twordlen
- sp->ts_tcharlen)) - sp->ts_tcharlen))
&& utf_iscomposing(utf_ptr2char((char *)fword && utf_iscomposing(utf_ptr2char(fword
+ sp->ts_fcharstart))) { + sp->ts_fcharstart))) {
sp->ts_score -= SCORE_SUBST - SCORE_SUBCOMP; sp->ts_score -= SCORE_SUBST - SCORE_SUBCOMP;
} else if (!soundfold } 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, && similar_chars(slang,
utf_ptr2char((char *)tword + sp->ts_twordlen - utf_ptr2char((char *)tword + sp->ts_twordlen -
sp->ts_tcharlen), sp->ts_tcharlen),
utf_ptr2char((char *)fword + sp->ts_fcharstart))) { utf_ptr2char(fword + sp->ts_fcharstart))) {
// For a similar character adjust score from // For a similar character adjust score from
// SCORE_SUBST to SCORE_SIMILAR. // SCORE_SUBST to SCORE_SIMILAR.
sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR; sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR;
} }
} else if (sp->ts_isdiff == DIFF_INSERT } else if (sp->ts_isdiff == DIFF_INSERT
&& sp->ts_twordlen > sp->ts_tcharlen) { && sp->ts_twordlen > sp->ts_tcharlen) {
p = tword + sp->ts_twordlen - sp->ts_tcharlen; p = (char *)tword + sp->ts_twordlen - sp->ts_tcharlen;
c = utf_ptr2char((char *)p); c = utf_ptr2char(p);
if (utf_iscomposing(c)) { if (utf_iscomposing(c)) {
// Inserting a composing char doesn't // Inserting a composing char doesn't
// count that much. // 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 // tree (might seem illogical but does
// give better scores). // give better scores).
MB_PTR_BACK(tword, p); MB_PTR_BACK(tword, p);
if (c == utf_ptr2char((char *)p)) { if (c == utf_ptr2char(p)) {
sp->ts_score -= SCORE_INS - SCORE_INSDUP; 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 // score if the same character is following "nn" -> "n". It's
// a bit illogical for soundfold tree but it does give better // a bit illogical for soundfold tree but it does give better
// results. // results.
c = utf_ptr2char((char *)fword + sp->ts_fidx); c = utf_ptr2char(fword + sp->ts_fidx);
stack[depth].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)) { if (utf_iscomposing(c)) {
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP; 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; 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 { } else {
newscore = SCORE_INS; newscore = SCORE_INS;
} }
if (c != fword[sp->ts_fidx] if (c != (uint8_t)fword[sp->ts_fidx]
&& TRY_DEEPER(su, stack, depth, newscore)) { && TRY_DEEPER(su, stack, depth, newscore)) {
go_deeper(stack, depth, newscore); go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK #ifdef DEBUG_TRIEWALK
@@ -1990,7 +1990,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
#endif #endif
depth++; depth++;
sp = &stack[depth]; sp = &stack[depth];
tword[sp->ts_twordlen++] = (char_u)c; tword[sp->ts_twordlen++] = (char)c;
sp->ts_arridx = idxs[n]; sp->ts_arridx = idxs[n];
fl = MB_BYTE2LEN(c); fl = MB_BYTE2LEN(c);
if (fl > 1) { 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 // soundfold words (illogical but does give a better
// score). // score).
if (sp->ts_twordlen >= 2 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; 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 // We change "fword" here, it's changed back afterwards at
// STATE_UNSWAP. // STATE_UNSWAP.
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
c = *p; c = (uint8_t)(*p);
if (c == NUL) { if (c == NUL) {
// End of word, can't swap or replace. // End of word, can't swap or replace.
PROF_STORE(sp->ts_state) 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. // Don't swap if the first character is not a word character.
// SWAP3 etc. also don't make sense then. // 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) PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI; sp->ts_state = STATE_REP_INI;
break; break;
} }
n = utf_ptr2len((char *)p); n = utf_ptr2len(p);
c = utf_ptr2char((char *)p); c = utf_ptr2char(p);
if (p[n] == NUL) { if (p[n] == NUL) {
c2 = 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 c2 = c; // don't swap non-word char
} else { } else {
c2 = utf_ptr2char((char *)p + n); c2 = utf_ptr2char(p + n);
} }
// When the second character is NUL we can't swap. // 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++; depth++;
fl = utf_char2len(c2); fl = utf_char2len(c2);
memmove(p, p + n, (size_t)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); stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl);
} else { } else {
// If this swap doesn't work then SWAP3 won't either. // 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: case STATE_UNSWAP:
// Undo the STATE_SWAP swap: "21" -> "12". // Undo the STATE_SWAP swap: "21" -> "12".
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = utfc_ptr2len((char *)p); n = utfc_ptr2len(p);
c = utf_ptr2char((char *)p + n); c = utf_ptr2char(p + n);
memmove(p + utfc_ptr2len((char *)p + n), p, (size_t)n); memmove(p + utfc_ptr2len(p + n), p, (size_t)n);
utf_char2bytes(c, (char *)p); utf_char2bytes(c, p);
FALLTHROUGH; 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 // Swap two bytes, skipping one: "123" -> "321". We change
// "fword" here, it's changed back afterwards at STATE_UNSWAP3. // "fword" here, it's changed back afterwards at STATE_UNSWAP3.
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = utf_ptr2len((char *)p); n = utf_ptr2len(p);
c = utf_ptr2char((char *)p); c = utf_ptr2char(p);
fl = utf_ptr2len((char *)p + n); fl = utf_ptr2len(p + n);
c2 = utf_ptr2char((char *)p + n); c2 = utf_ptr2char(p + n);
if (!soundfold && !spell_iswordp(p + n + fl, curwin)) { if (!soundfold && !spell_iswordp((char_u *)p + n + fl, curwin)) {
c3 = c; // don't swap non-word char c3 = c; // don't swap non-word char
} else { } else {
c3 = utf_ptr2char((char *)p + n + fl); c3 = utf_ptr2char(p + n + fl);
} }
// When characters are identical: "121" then SWAP3 result is // 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++; depth++;
tl = utf_char2len(c3); tl = utf_char2len(c3);
memmove(p, p + n + fl, (size_t)tl); memmove(p, p + n + fl, (size_t)tl);
utf_char2bytes(c2, (char *)p + tl); utf_char2bytes(c2, p + tl);
utf_char2bytes(c, (char *)p + fl + tl); utf_char2bytes(c, p + fl + tl);
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl + tl); stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl + tl);
} else { } else {
PROF_STORE(sp->ts_state) 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: case STATE_UNSWAP3:
// Undo STATE_SWAP3: "321" -> "123" // Undo STATE_SWAP3: "321" -> "123"
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = utfc_ptr2len((char *)p); n = utfc_ptr2len(p);
c2 = utf_ptr2char((char *)p + n); c2 = utf_ptr2char(p + n);
fl = utfc_ptr2len((char *)p + n); fl = utfc_ptr2len(p + n);
c = utf_ptr2char((char *)p + n + fl); c = utf_ptr2char(p + n + fl);
tl = utfc_ptr2len((char *)p + n + fl); tl = utfc_ptr2len(p + n + fl);
memmove(p + fl + tl, p, (size_t)n); memmove(p + fl + tl, p, (size_t)n);
utf_char2bytes(c, (char *)p); utf_char2bytes(c, p);
utf_char2bytes(c2, (char *)p + tl); utf_char2bytes(c2, p + tl);
p = 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 // Middle char is not a word char, skip the rotate. First and
// third char were already checked at swap and swap3. // third char were already checked at swap and swap3.
PROF_STORE(sp->ts_state) 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; sp->ts_state = STATE_UNROT3L;
depth++; depth++;
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = utf_ptr2len((char *)p); n = utf_ptr2len(p);
c = utf_ptr2char((char *)p); c = utf_ptr2char(p);
fl = utf_ptr2len((char *)p + n); fl = utf_ptr2len(p + n);
fl += utf_ptr2len((char *)p + n + fl); fl += utf_ptr2len(p + n + fl);
memmove(p, p + n, (size_t)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); stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl);
} else { } else {
PROF_STORE(sp->ts_state) 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: case STATE_UNROT3L:
// Undo ROT3L: "231" -> "123" // Undo ROT3L: "231" -> "123"
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = utfc_ptr2len((char *)p); n = utfc_ptr2len(p);
n += utfc_ptr2len((char *)p + n); n += utfc_ptr2len(p + n);
c = utf_ptr2char((char *)p + n); c = utf_ptr2char(p + n);
tl = utfc_ptr2len((char *)p + n); tl = utfc_ptr2len(p + n);
memmove(p + tl, p, (size_t)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" // Rotate three bytes right: "123" -> "312". We change "fword"
// here, it's changed back afterwards at STATE_UNROT3R. // 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; sp->ts_state = STATE_UNROT3R;
depth++; depth++;
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
n = utf_ptr2len((char *)p); n = utf_ptr2len(p);
n += utf_ptr2len((char *)p + n); n += utf_ptr2len(p + n);
c = utf_ptr2char((char *)p + n); c = utf_ptr2char(p + n);
tl = utf_ptr2len((char *)p + n); tl = utf_ptr2len(p + n);
memmove(p + tl, p, (size_t)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); stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + tl);
} else { } else {
PROF_STORE(sp->ts_state) 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: case STATE_UNROT3R:
// Undo ROT3R: "312" -> "123" // Undo ROT3R: "312" -> "123"
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
c = utf_ptr2char((char *)p); c = utf_ptr2char(p);
tl = utfc_ptr2len((char *)p); tl = utfc_ptr2len(p);
n = utfc_ptr2len((char *)p + tl); n = utfc_ptr2len(p + tl);
n += utfc_ptr2len((char *)p + tl + n); n += utfc_ptr2len(p + tl + n);
memmove(p, p + tl, (size_t)n); memmove(p, p + tl, (size_t)n);
utf_char2bytes(c, (char *)p + n); utf_char2bytes(c, p + n);
FALLTHROUGH; 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 // Use the first byte to quickly find the first entry that may
// match. If the index is -1 there is none. // match. If the index is -1 there is none.
if (soundfold) { 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 { } 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) { 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; sp->ts_curi = (int16_t)gap->ga_len;
break; 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)) { && TRY_DEEPER(su, stack, depth, SCORE_REP)) {
go_deeper(stack, depth, SCORE_REP); go_deeper(stack, depth, SCORE_REP);
#ifdef DEBUG_TRIEWALK #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. // Change the "from" to the "to" string.
depth++; depth++;
fl = (int)strlen((char *)ftp->ft_from); fl = (int)strlen(ftp->ft_from);
tl = (int)strlen((char *)ftp->ft_to); tl = (int)strlen(ftp->ft_to);
if (fl != tl) { if (fl != tl) {
STRMOVE(p + tl, (char *)p + fl); STRMOVE(p + tl, (char *)p + fl);
repextra += tl - 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; gap = &lp->lp_replang->sl_rep;
} }
ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1; ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;
fl = (int)strlen((char *)ftp->ft_from); fl = (int)strlen(ftp->ft_from);
tl = (int)strlen((char *)ftp->ft_to); tl = (int)strlen(ftp->ft_to);
p = fword + sp->ts_fidx; p = fword + sp->ts_fidx;
if (fl != tl) { if (fl != tl) {
STRMOVE(p + fl, (char *)p + tl); STRMOVE(p + fl, (char *)p + tl);
@@ -2747,7 +2747,7 @@ static void suggest_try_soundalike(suginfo_T *su)
#ifdef SUGGEST_PROFILE #ifdef SUGGEST_PROFILE
prof_init(); prof_init();
#endif #endif
suggest_trie_walk(su, lp, salword, true); suggest_trie_walk(su, lp, (char *)salword, true);
#ifdef SUGGEST_PROFILE #ifdef SUGGEST_PROFILE
prof_report("soundalike"); prof_report("soundalike");
#endif #endif

View File

@@ -185,7 +185,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
length++; // insert backslash 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 length++; // insert backslash
p += l - 1; p += l - 1;
} }
@@ -234,7 +234,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
*d++ = *p++; *d++ = *p++;
continue; continue;
} }
if (do_special && find_cmdline_var((char_u *)p, &l) >= 0) { if (do_special && find_cmdline_var(p, &l) >= 0) {
*d++ = '\\'; // insert backslash *d++ = '\\'; // insert backslash
while (--l != SIZE_MAX) { // copy the var while (--l != SIZE_MAX) { // copy the var
*d++ = *p++; *d++ = *p++;

View File

@@ -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 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 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 #ifdef HAVE_STRCASECMP
# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s)) # define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
#else #else

View File

@@ -1825,7 +1825,7 @@ static void parse_quoted_string(ParserState *const pstate, ExprASTNode *const no
if (p[1] != '*') { if (p[1] != '*') {
flags |= FSK_SIMPLIFY; 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); (char_u *)v_p, flags, false, NULL);
if (special_len != 0) { if (special_len != 0) {
v_p += special_len; v_p += special_len;