mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 04:18:18 +00:00
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:
@@ -318,7 +318,7 @@ typedef struct {
|
||||
typedef struct mapblock mapblock_T;
|
||||
struct mapblock {
|
||||
mapblock_T *m_next; // next mapblock in list
|
||||
uint8_t *m_keys; // mapped from, lhs
|
||||
char *m_keys; // mapped from, lhs
|
||||
char *m_str; // mapped to, rhs
|
||||
char *m_orig_str; // rhs as entered by the user
|
||||
LuaRef m_luaref; // lua function reference as rhs
|
||||
|
@@ -2960,7 +2960,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
|
||||
if (xp->xp_context == EXPAND_FILES
|
||||
|| xp->xp_context == EXPAND_DIRECTORIES
|
||||
|| xp->xp_context == EXPAND_SHELLCMD) {
|
||||
char_u upseg[5];
|
||||
char upseg[5];
|
||||
|
||||
upseg[0] = PATHSEP;
|
||||
upseg[1] = '.';
|
||||
@@ -2977,7 +2977,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
|
||||
// go down a directory
|
||||
c = (int)p_wc;
|
||||
KeyTyped = true; // in case the key was mapped
|
||||
} else if (STRNCMP(xp->xp_pattern, upseg + 1, 3) == 0
|
||||
} else if (strncmp(xp->xp_pattern, upseg + 1, 3) == 0
|
||||
&& c == K_DOWN) {
|
||||
// If in a direct ancestor, strip off one ../ to go down
|
||||
int found = false;
|
||||
@@ -3024,9 +3024,9 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
|
||||
|
||||
if (!found) {
|
||||
j = i;
|
||||
} else if (STRNCMP(cclp->cmdbuff + j, upseg, 4) == 0) {
|
||||
} else if (strncmp(cclp->cmdbuff + j, upseg, 4) == 0) {
|
||||
j += 4;
|
||||
} else if (STRNCMP(cclp->cmdbuff + j, upseg + 1, 3) == 0
|
||||
} else if (strncmp(cclp->cmdbuff + j, upseg + 1, 3) == 0
|
||||
&& j == i) {
|
||||
j += 3;
|
||||
} else {
|
||||
@@ -3037,7 +3037,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
|
||||
// TODO(tarruda): this is only for DOS/Unix systems - need to put in
|
||||
// machine-specific stuff here and in upseg init
|
||||
cmdline_del(cclp, j);
|
||||
put_on_cmdline(upseg + 1, 3, false);
|
||||
put_on_cmdline((char_u *)upseg + 1, 3, false);
|
||||
} else if (cclp->cmdpos > i) {
|
||||
cmdline_del(cclp, i);
|
||||
}
|
||||
|
@@ -2777,7 +2777,7 @@ static bool echeck_abbr(int c)
|
||||
return false;
|
||||
}
|
||||
|
||||
return check_abbr(c, (char_u *)get_cursor_line_ptr(), curwin->w_cursor.col,
|
||||
return check_abbr(c, get_cursor_line_ptr(), curwin->w_cursor.col,
|
||||
curwin->w_cursor.lnum == Insstart.lnum ? Insstart.col : 0);
|
||||
}
|
||||
|
||||
@@ -3018,11 +3018,11 @@ bool cindent_on(void)
|
||||
/// @param line_is_empty when true, accept keys with '0' before them.
|
||||
bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
{
|
||||
uint8_t *look;
|
||||
char *look;
|
||||
int try_match;
|
||||
int try_match_word;
|
||||
uint8_t *p;
|
||||
uint8_t *line;
|
||||
char *p;
|
||||
char *line;
|
||||
bool icase;
|
||||
|
||||
if (keytyped == NUL) {
|
||||
@@ -3031,9 +3031,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
}
|
||||
|
||||
if (*curbuf->b_p_inde != NUL) {
|
||||
look = (uint8_t *)curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys'
|
||||
look = curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys'
|
||||
} else {
|
||||
look = (uint8_t *)curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys'
|
||||
look = curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys'
|
||||
}
|
||||
while (*look) {
|
||||
// Find out if we want to try a match with this key, depending on
|
||||
@@ -3086,9 +3086,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
// cursor.
|
||||
} else if (*look == 'e') {
|
||||
if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) {
|
||||
p = (uint8_t *)get_cursor_line_ptr();
|
||||
if ((uint8_t *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4
|
||||
&& STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) {
|
||||
p = get_cursor_line_ptr();
|
||||
if (skipwhite(p) == p + curwin->w_cursor.col - 4
|
||||
&& strncmp(p + curwin->w_cursor.col - 4, "else", 4) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3099,12 +3099,12 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
// class::method for C++).
|
||||
} else if (*look == ':') {
|
||||
if (try_match && keytyped == ':') {
|
||||
p = (uint8_t *)get_cursor_line_ptr();
|
||||
p = get_cursor_line_ptr();
|
||||
if (cin_iscase((char_u *)p, false) || cin_isscopedecl((char_u *)p) || cin_islabel()) {
|
||||
return true;
|
||||
}
|
||||
// Need to get the line again after cin_islabel().
|
||||
p = (uint8_t *)get_cursor_line_ptr();
|
||||
p = get_cursor_line_ptr();
|
||||
if (curwin->w_cursor.col > 2
|
||||
&& p[curwin->w_cursor.col - 1] == ':'
|
||||
&& p[curwin->w_cursor.col - 2] == ':') {
|
||||
@@ -3112,7 +3112,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
const bool i = cin_iscase((char_u *)p, false)
|
||||
|| cin_isscopedecl((char_u *)p)
|
||||
|| cin_islabel();
|
||||
p = (uint8_t *)get_cursor_line_ptr();
|
||||
p = get_cursor_line_ptr();
|
||||
p[curwin->w_cursor.col - 1] = ':';
|
||||
if (i) {
|
||||
return true;
|
||||
@@ -3151,22 +3151,22 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
} else {
|
||||
icase = false;
|
||||
}
|
||||
p = (uint8_t *)vim_strchr((char *)look, ',');
|
||||
p = vim_strchr(look, ',');
|
||||
if (p == NULL) {
|
||||
p = look + strlen((char *)look);
|
||||
p = look + strlen(look);
|
||||
}
|
||||
if ((try_match || try_match_word)
|
||||
&& curwin->w_cursor.col >= (colnr_T)(p - look)) {
|
||||
bool match = false;
|
||||
|
||||
if (keytyped == KEY_COMPLETE) {
|
||||
uint8_t *n, *s;
|
||||
char *n, *s;
|
||||
|
||||
// Just completed a word, check if it starts with "look".
|
||||
// search back for the start of a word.
|
||||
line = (uint8_t *)get_cursor_line_ptr();
|
||||
line = get_cursor_line_ptr();
|
||||
for (s = line + curwin->w_cursor.col; s > line; s = n) {
|
||||
n = mb_prevptr((char_u *)line, (char_u *)s);
|
||||
n = (char *)mb_prevptr((char_u *)line, (char_u *)s);
|
||||
if (!vim_iswordp((char_u *)n)) {
|
||||
break;
|
||||
}
|
||||
@@ -3174,22 +3174,22 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);
|
||||
if (s + (p - look) <= line + curwin->w_cursor.col
|
||||
&& (icase
|
||||
? mb_strnicmp((char *)s, (char *)look, (size_t)(p - look))
|
||||
: STRNCMP(s, look, p - look)) == 0) {
|
||||
? mb_strnicmp(s, look, (size_t)(p - look))
|
||||
: strncmp(s, look, (size_t)(p - look))) == 0) {
|
||||
match = true;
|
||||
}
|
||||
} else {
|
||||
// TODO(@brammool): multi-byte
|
||||
if (keytyped == (int)p[-1]
|
||||
if (keytyped == (int)(uint8_t)p[-1]
|
||||
|| (icase && keytyped < 256
|
||||
&& TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) {
|
||||
line = (uint8_t *)get_cursor_pos_ptr();
|
||||
line = get_cursor_pos_ptr();
|
||||
assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);
|
||||
if ((curwin->w_cursor.col == (colnr_T)(p - look)
|
||||
|| !vim_iswordc(line[-(p - look) - 1]))
|
||||
|| !vim_iswordc((uint8_t)line[-(p - look) - 1]))
|
||||
&& (icase
|
||||
? mb_strnicmp((char *)line - (p - look), (char *)look, (size_t)(p - look))
|
||||
: STRNCMP(line - (p - look), look, p - look)) == 0) {
|
||||
? mb_strnicmp(line - (p - look), look, (size_t)(p - look))
|
||||
: strncmp(line - (p - look), look, (size_t)(p - look))) == 0) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
@@ -3210,7 +3210,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
|
||||
// Ok, it's a boring generic character.
|
||||
} else {
|
||||
if (try_match && *look == keytyped) {
|
||||
if (try_match && (uint8_t)(*look) == keytyped) {
|
||||
return true;
|
||||
}
|
||||
if (*look != NUL) {
|
||||
@@ -3219,7 +3219,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
}
|
||||
|
||||
// Skip over ", ".
|
||||
look = (uint8_t *)skip_to_option_part((char *)look);
|
||||
look = skip_to_option_part(look);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -3838,7 +3838,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
|
||||
if (p[1] != '*') {
|
||||
flags |= FSK_SIMPLIFY;
|
||||
}
|
||||
extra = trans_special((const char_u **)&p, strlen(p), (char_u *)name, flags, false, NULL);
|
||||
extra = trans_special((const char **)&p, strlen(p), (char_u *)name, flags, false, NULL);
|
||||
if (extra != 0) {
|
||||
name += extra;
|
||||
if (name >= rettv->vval.v_string + len) {
|
||||
|
@@ -1367,12 +1367,13 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp)
|
||||
{
|
||||
bool is_fish_shell =
|
||||
#if defined(UNIX)
|
||||
STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
|
||||
strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
bool is_pwsh = STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0
|
||||
|| STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "powershell", 10) == 0;
|
||||
bool is_pwsh = strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "pwsh", 4) == 0
|
||||
|| strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "powershell",
|
||||
10) == 0;
|
||||
|
||||
size_t len = strlen(cmd) + 1; // At least enough space for cmd + NULL.
|
||||
|
||||
|
@@ -6631,7 +6631,7 @@ enum {
|
||||
/// Check "str" for starting with a special cmdline variable.
|
||||
/// If found return one of the SPEC_ values and set "*usedlen" to the length of
|
||||
/// the variable. Otherwise return -1 and "*usedlen" is unchanged.
|
||||
ssize_t find_cmdline_var(const char_u *src, size_t *usedlen)
|
||||
ssize_t find_cmdline_var(const char *src, size_t *usedlen)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
static char *(spec_str[]) = {
|
||||
@@ -6655,7 +6655,7 @@ ssize_t find_cmdline_var(const char_u *src, size_t *usedlen)
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(spec_str); i++) {
|
||||
size_t len = strlen(spec_str[i]);
|
||||
if (STRNCMP(src, spec_str[i], len) == 0) {
|
||||
if (strncmp(src, spec_str[i], len) == 0) {
|
||||
*usedlen = len;
|
||||
assert(i <= SSIZE_MAX);
|
||||
return (ssize_t)i;
|
||||
@@ -6711,7 +6711,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T
|
||||
}
|
||||
|
||||
// Check if there is something to do.
|
||||
ssize_t spec_idx = find_cmdline_var(src, usedlen);
|
||||
ssize_t spec_idx = find_cmdline_var((char *)src, usedlen);
|
||||
if (spec_idx < 0) { // no match
|
||||
*usedlen = 1;
|
||||
return NULL;
|
||||
|
@@ -3929,7 +3929,7 @@ static int ccheck_abbr(int c)
|
||||
spos = 0;
|
||||
}
|
||||
|
||||
return check_abbr(c, (char_u *)ccline.cmdbuff, ccline.cmdpos, spos);
|
||||
return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos);
|
||||
}
|
||||
|
||||
/// Escape special characters in "fname", depending on "what":
|
||||
|
@@ -1968,7 +1968,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
// Only consider an entry if the first character matches and it is
|
||||
// for the current state.
|
||||
// Skip ":lmap" mappings if keys were mapped.
|
||||
if (mp->m_keys[0] == tb_c1 && (mp->m_mode & local_State)
|
||||
if ((uint8_t)mp->m_keys[0] == tb_c1 && (mp->m_mode & local_State)
|
||||
&& ((mp->m_mode & MODE_LANGMAP) == 0 || typebuf.tb_maplen == 0)) {
|
||||
int nomap = nolmaplen;
|
||||
int modifiers = 0;
|
||||
@@ -1994,7 +1994,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
}
|
||||
modifiers = 0;
|
||||
}
|
||||
if (mp->m_keys[mlen] != c2) {
|
||||
if ((uint8_t)mp->m_keys[mlen] != c2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2002,7 +2002,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
// Don't allow mapping the first byte(s) of a multi-byte char.
|
||||
// Happens when mapping <M-a> and then changing 'encoding'.
|
||||
// Beware that 0x80 is escaped.
|
||||
char_u *p1 = mp->m_keys;
|
||||
char_u *p1 = (char_u *)mp->m_keys;
|
||||
char_u *p2 = (char_u *)mb_unescape((const char **)&p1);
|
||||
|
||||
if (p2 != NULL && MB_BYTE2LEN(tb_c1) > utfc_ptr2len((char *)p2)) {
|
||||
@@ -2020,8 +2020,8 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
// mapping starts with K_SNR.
|
||||
uint8_t *s = typebuf.tb_noremap + typebuf.tb_off;
|
||||
if (*s == RM_SCRIPT
|
||||
&& (mp->m_keys[0] != K_SPECIAL
|
||||
|| mp->m_keys[1] != KS_EXTRA
|
||||
&& ((uint8_t)mp->m_keys[0] != K_SPECIAL
|
||||
|| (uint8_t)mp->m_keys[1] != KS_EXTRA
|
||||
|| mp->m_keys[2] != KE_SNR)) {
|
||||
continue;
|
||||
}
|
||||
@@ -2212,7 +2212,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
vgetc_busy = 0;
|
||||
may_garbage_collect = false;
|
||||
|
||||
save_m_keys = xstrdup((char *)mp->m_keys);
|
||||
save_m_keys = xstrdup(mp->m_keys);
|
||||
if (save_m_luaref == LUA_NOREF) {
|
||||
save_m_str = xstrdup(mp->m_str);
|
||||
}
|
||||
@@ -2266,7 +2266,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
|
||||
if (save_m_noremap != REMAP_YES) {
|
||||
noremap = save_m_noremap;
|
||||
} else if (strncmp(map_str, save_m_keys != NULL ? save_m_keys : (char *)mp->m_keys,
|
||||
} else if (strncmp(map_str, save_m_keys != NULL ? save_m_keys : mp->m_keys,
|
||||
(size_t)keylen) != 0) {
|
||||
noremap = REMAP_YES;
|
||||
} else {
|
||||
|
@@ -232,7 +232,7 @@ struct prt_ps_resource_S {
|
||||
char_u filename[MAXPATHL + 1];
|
||||
PrtResourceType type;
|
||||
char_u title[256];
|
||||
char_u version[256];
|
||||
char version[256];
|
||||
};
|
||||
|
||||
struct prt_dsc_comment_S {
|
||||
@@ -243,7 +243,7 @@ struct prt_dsc_comment_S {
|
||||
|
||||
struct prt_dsc_line_S {
|
||||
int type;
|
||||
char_u *string;
|
||||
char *string;
|
||||
int len;
|
||||
};
|
||||
|
||||
@@ -251,7 +251,7 @@ struct prt_dsc_line_S {
|
||||
// couple of KB of comments!
|
||||
#define PRT_FILE_BUFFER_LEN (2048)
|
||||
struct prt_resfile_buffer_S {
|
||||
char_u buffer[PRT_FILE_BUFFER_LEN];
|
||||
char buffer[PRT_FILE_BUFFER_LEN];
|
||||
int len;
|
||||
int line_start;
|
||||
int line_end;
|
||||
@@ -1550,8 +1550,8 @@ static int prt_resfile_strncmp(int offset, const char *string, int len)
|
||||
if (len > (prt_resfile.line_end - (prt_resfile.line_start + offset))) {
|
||||
return 1;
|
||||
}
|
||||
return STRNCMP(&prt_resfile.buffer[prt_resfile.line_start + offset],
|
||||
string, len);
|
||||
return strncmp(&prt_resfile.buffer[prt_resfile.line_start + offset],
|
||||
string, (size_t)len);
|
||||
}
|
||||
|
||||
static int prt_resfile_skip_nonws(int offset)
|
||||
@@ -1751,7 +1751,7 @@ static bool prt_check_resource(const struct prt_ps_resource_S *resource, const c
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
// Version number m.n should match, the revision number does not matter
|
||||
if (STRNCMP(resource->version, version, strlen(version)) != 0) {
|
||||
if (strncmp(resource->version, version, strlen(version)) != 0) {
|
||||
semsg(_("E621: \"%s\" resource file has wrong version"),
|
||||
resource->name);
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -893,7 +893,7 @@ static int ins_compl_add(char *const str, int len, char *const fname, char *cons
|
||||
/// @param match completion match
|
||||
/// @param str character string to check
|
||||
/// @param len length of "str"
|
||||
static bool ins_compl_equal(compl_T *match, char_u *str, size_t len)
|
||||
static bool ins_compl_equal(compl_T *match, char *str, size_t len)
|
||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (match->cp_flags & CP_EQUAL) {
|
||||
@@ -902,7 +902,7 @@ static bool ins_compl_equal(compl_T *match, char_u *str, size_t len)
|
||||
if (match->cp_flags & CP_ICASE) {
|
||||
return STRNICMP(match->cp_str, str, len) == 0;
|
||||
}
|
||||
return STRNCMP(match->cp_str, str, len) == 0;
|
||||
return strncmp(match->cp_str, str, len) == 0;
|
||||
}
|
||||
|
||||
/// Reduce the longest common string for match "match".
|
||||
@@ -1151,7 +1151,7 @@ static int ins_compl_build_pum(void)
|
||||
do {
|
||||
if (!match_at_original_text(compl)
|
||||
&& (compl_leader == NULL
|
||||
|| ins_compl_equal(compl, (char_u *)compl_leader, (size_t)lead_len))) {
|
||||
|| ins_compl_equal(compl, compl_leader, (size_t)lead_len))) {
|
||||
compl_match_arraysize++;
|
||||
}
|
||||
compl = compl->cp_next;
|
||||
@@ -1176,7 +1176,7 @@ static int ins_compl_build_pum(void)
|
||||
do {
|
||||
if (!match_at_original_text(compl)
|
||||
&& (compl_leader == NULL
|
||||
|| ins_compl_equal(compl, (char_u *)compl_leader, (size_t)lead_len))) {
|
||||
|| ins_compl_equal(compl, compl_leader, (size_t)lead_len))) {
|
||||
if (!shown_match_ok) {
|
||||
if (compl == compl_shown_match || did_find_shown_match) {
|
||||
// This item is the shown match or this is the
|
||||
@@ -1823,7 +1823,7 @@ void ins_compl_addfrommatch(void)
|
||||
for (cp = compl_shown_match->cp_next; cp != NULL
|
||||
&& !is_first_match(cp); cp = cp->cp_next) {
|
||||
if (compl_leader == NULL
|
||||
|| ins_compl_equal(cp, (char_u *)compl_leader, strlen(compl_leader))) {
|
||||
|| ins_compl_equal(cp, compl_leader, strlen(compl_leader))) {
|
||||
p = cp->cp_str;
|
||||
break;
|
||||
}
|
||||
@@ -3404,7 +3404,7 @@ static int ins_compl_get_exp(pos_T *ini)
|
||||
static void ins_compl_update_shown_match(void)
|
||||
{
|
||||
while (!ins_compl_equal(compl_shown_match,
|
||||
(char_u *)compl_leader, strlen(compl_leader))
|
||||
compl_leader, strlen(compl_leader))
|
||||
&& compl_shown_match->cp_next != NULL
|
||||
&& !is_first_match(compl_shown_match->cp_next)) {
|
||||
compl_shown_match = compl_shown_match->cp_next;
|
||||
@@ -3413,10 +3413,10 @@ static void ins_compl_update_shown_match(void)
|
||||
// If we didn't find it searching forward, and compl_shows_dir is
|
||||
// backward, find the last match.
|
||||
if (compl_shows_dir_backward()
|
||||
&& !ins_compl_equal(compl_shown_match, (char_u *)compl_leader, strlen(compl_leader))
|
||||
&& !ins_compl_equal(compl_shown_match, compl_leader, strlen(compl_leader))
|
||||
&& (compl_shown_match->cp_next == NULL
|
||||
|| is_first_match(compl_shown_match->cp_next))) {
|
||||
while (!ins_compl_equal(compl_shown_match, (char_u *)compl_leader, strlen(compl_leader))
|
||||
while (!ins_compl_equal(compl_shown_match, compl_leader, strlen(compl_leader))
|
||||
&& compl_shown_match->cp_prev != NULL
|
||||
&& !is_first_match(compl_shown_match->cp_prev)) {
|
||||
compl_shown_match = compl_shown_match->cp_prev;
|
||||
@@ -3561,7 +3561,7 @@ static int find_next_completion_match(bool allow_get_expansion, int todo, bool a
|
||||
if (!match_at_original_text(compl_shown_match)
|
||||
&& compl_leader != NULL
|
||||
&& !ins_compl_equal(compl_shown_match,
|
||||
(char_u *)compl_leader, strlen(compl_leader))) {
|
||||
compl_leader, strlen(compl_leader))) {
|
||||
todo++;
|
||||
} else {
|
||||
// Remember a matching item.
|
||||
|
@@ -570,7 +570,7 @@ char_u *get_special_key_name(int c, int modifiers)
|
||||
/// @param[out] did_simplify found <C-H>, etc.
|
||||
///
|
||||
/// @return Number of characters added to dst, zero for no match.
|
||||
unsigned int trans_special(const char_u **const srcp, const size_t src_len, char_u *const dst,
|
||||
unsigned int trans_special(const char **const srcp, const size_t src_len, char_u *const dst,
|
||||
const int flags, const bool escape_ks, bool *const did_simplify)
|
||||
FUNC_ATTR_NONNULL_ARG(1, 3) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
@@ -623,7 +623,7 @@ unsigned int special_to_buf(int key, int modifiers, bool escape_ks, char_u *dst)
|
||||
/// @param[out] did_simplify FSK_SIMPLIFY and found <C-H>, etc.
|
||||
///
|
||||
/// @return Key and modifiers or 0 if there is no match.
|
||||
int find_special_key(const char_u **const srcp, const size_t src_len, int *const modp,
|
||||
int find_special_key(const char **const srcp, const size_t src_len, int *const modp,
|
||||
const int flags, bool *const did_simplify)
|
||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1, 3)
|
||||
{
|
||||
@@ -631,7 +631,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
|
||||
const char_u *end_of_name;
|
||||
const char_u *src;
|
||||
const char_u *bp;
|
||||
const char_u *const end = *srcp + src_len - 1;
|
||||
const char_u *const end = (char_u *)(*srcp) + src_len - 1;
|
||||
const bool in_string = flags & FSK_IN_STRING;
|
||||
int modifiers;
|
||||
int bit;
|
||||
@@ -643,7 +643,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
|
||||
return 0;
|
||||
}
|
||||
|
||||
src = *srcp;
|
||||
src = (char_u *)(*srcp);
|
||||
if (src[0] != '<') {
|
||||
return 0;
|
||||
}
|
||||
@@ -751,7 +751,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
|
||||
}
|
||||
|
||||
*modp = modifiers;
|
||||
*srcp = end_of_name;
|
||||
*srcp = (char *)end_of_name;
|
||||
return key;
|
||||
} // else { ELOG("unknown key: '%s'", src); }
|
||||
}
|
||||
@@ -885,10 +885,10 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
||||
{
|
||||
ssize_t i;
|
||||
size_t slen;
|
||||
char_u key;
|
||||
char key;
|
||||
size_t dlen = 0;
|
||||
const char_u *src;
|
||||
const char_u *const end = (char_u *)from + from_len - 1;
|
||||
const char *src;
|
||||
const char *const end = from + from_len - 1;
|
||||
char *result; // buffer for resulting string
|
||||
|
||||
const bool do_backslash = !(cpo_flags & FLAG_CPO_BSLASH); // backslash is a special character
|
||||
@@ -901,7 +901,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
||||
const size_t buf_len = allocated ? from_len * 6 + 1 : 128;
|
||||
result = allocated ? xmalloc(buf_len) : *bufp;
|
||||
|
||||
src = (char_u *)from;
|
||||
src = from;
|
||||
|
||||
// Check for #n at start only: function key n
|
||||
if ((flags & REPTERM_FROM_PART) && from_len > 1 && src[0] == '#'
|
||||
@@ -911,7 +911,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
||||
if (src[1] == '0') {
|
||||
result[dlen++] = ';'; // #0 is F10 is "k;"
|
||||
} else {
|
||||
result[dlen++] = (char)src[1]; // #3 is F3 is "k3"
|
||||
result[dlen++] = src[1]; // #3 is F3 is "k3"
|
||||
}
|
||||
src += 2;
|
||||
}
|
||||
@@ -923,7 +923,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
||||
}
|
||||
// Check for special <> keycodes, like "<C-S-LeftMouse>"
|
||||
if (do_special && ((flags & REPTERM_DO_LT) || ((end - src) >= 3
|
||||
&& STRNCMP(src, "<lt>", 4) != 0))) {
|
||||
&& strncmp(src, "<lt>", 4) != 0))) {
|
||||
// Replace <SID> by K_SNR <script-nr> _.
|
||||
// (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14)
|
||||
if (end - src >= 4 && STRNICMP(src, "<SID>", 5) == 0) {
|
||||
@@ -993,7 +993,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
||||
src++; // skip CTRL-V or backslash
|
||||
if (src > end) {
|
||||
if (flags & REPTERM_FROM_PART) {
|
||||
result[dlen++] = (char)key;
|
||||
result[dlen++] = key;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1003,12 +1003,12 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
||||
for (i = utfc_ptr2len_len((char *)src, (int)(end - src) + 1); i > 0; i--) {
|
||||
// If the character is K_SPECIAL, replace it with K_SPECIAL
|
||||
// KS_SPECIAL KE_FILLER.
|
||||
if (*src == K_SPECIAL) {
|
||||
if (*src == (char)K_SPECIAL) {
|
||||
result[dlen++] = (char)K_SPECIAL;
|
||||
result[dlen++] = (char)KS_SPECIAL;
|
||||
result[dlen++] = KE_FILLER;
|
||||
} else {
|
||||
result[dlen++] = (char)(*src);
|
||||
result[dlen++] = *src;
|
||||
}
|
||||
src++;
|
||||
}
|
||||
|
@@ -158,7 +158,7 @@ static void showmap(mapblock_T *mp, bool local)
|
||||
{
|
||||
size_t len = 1;
|
||||
|
||||
if (message_filtered((char *)mp->m_keys) && message_filtered(mp->m_str)
|
||||
if (message_filtered(mp->m_keys) && message_filtered(mp->m_str)
|
||||
&& (mp->m_desc == NULL || message_filtered(mp->m_desc))) {
|
||||
return;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ static void showmap(mapblock_T *mp, bool local)
|
||||
}
|
||||
|
||||
// Display the LHS. Get length of what we write.
|
||||
len = (size_t)msg_outtrans_special((char *)mp->m_keys, true, 0);
|
||||
len = (size_t)msg_outtrans_special(mp->m_keys, true, 0);
|
||||
do {
|
||||
msg_putchar(' '); // pad with blanks
|
||||
len++;
|
||||
@@ -462,7 +462,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
|
||||
}
|
||||
}
|
||||
|
||||
mp->m_keys = (uint8_t *)xstrdup(keys);
|
||||
mp->m_keys = xstrdup(keys);
|
||||
mp->m_str = args->rhs;
|
||||
mp->m_orig_str = (char *)args->orig_rhs;
|
||||
mp->m_luaref = args->rhs_lua;
|
||||
@@ -471,7 +471,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
|
||||
args->orig_rhs = NULL;
|
||||
args->rhs_lua = LUA_NOREF;
|
||||
}
|
||||
mp->m_keylen = (int)strlen((char *)mp->m_keys);
|
||||
mp->m_keylen = (int)strlen(mp->m_keys);
|
||||
mp->m_noremap = noremap;
|
||||
mp->m_nowait = args->nowait;
|
||||
mp->m_silent = args->silent;
|
||||
@@ -497,7 +497,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
|
||||
mp->m_next = *abbr_table;
|
||||
*abbr_table = mp;
|
||||
} else {
|
||||
const int n = MAP_HASH(mp->m_mode, mp->m_keys[0]);
|
||||
const int n = MAP_HASH(mp->m_mode, (uint8_t)mp->m_keys[0]);
|
||||
mp->m_next = map_table[n];
|
||||
map_table[n] = mp;
|
||||
}
|
||||
@@ -516,7 +516,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
|
||||
static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T *buf)
|
||||
{
|
||||
mapblock_T *mp, **mpp;
|
||||
const char_u *p;
|
||||
const char *p;
|
||||
int n;
|
||||
int retval = 0;
|
||||
mapblock_T **abbr_table;
|
||||
@@ -553,7 +553,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
goto theend;
|
||||
}
|
||||
|
||||
const char_u *lhs = (char_u *)&args->lhs;
|
||||
const char *lhs = (char *)&args->lhs;
|
||||
const bool did_simplify = args->alt_lhs_len != 0;
|
||||
|
||||
// The following is done twice if we have two versions of keys
|
||||
@@ -567,11 +567,11 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
if (!did_simplify) {
|
||||
break;
|
||||
}
|
||||
lhs = (char_u *)&args->alt_lhs;
|
||||
lhs = (char *)&args->alt_lhs;
|
||||
len = (int)args->alt_lhs_len;
|
||||
} else if (did_simplify && do_print) {
|
||||
// when printing always use the not-simplified map
|
||||
lhs = (char_u *)&args->alt_lhs;
|
||||
lhs = (char *)&args->alt_lhs;
|
||||
len = (int)args->alt_lhs_len;
|
||||
}
|
||||
|
||||
@@ -589,13 +589,13 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
// vi-compatible way.
|
||||
int same = -1;
|
||||
|
||||
const int first = vim_iswordp(lhs);
|
||||
const int first = vim_iswordp((char_u *)lhs);
|
||||
int last = first;
|
||||
p = lhs + utfc_ptr2len((char *)lhs);
|
||||
p = (char *)lhs + utfc_ptr2len((char *)lhs);
|
||||
n = 1;
|
||||
while (p < lhs + len) {
|
||||
while (p < (char *)lhs + len) {
|
||||
n++; // nr of (multi-byte) chars
|
||||
last = vim_iswordp(p); // type of last char
|
||||
last = vim_iswordp((char_u *)p); // type of last char
|
||||
if (same == -1 && last != first) {
|
||||
same = n - 1; // count of same char type
|
||||
}
|
||||
@@ -640,7 +640,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
// check entries with the same mode
|
||||
if ((mp->m_mode & mode) != 0
|
||||
&& mp->m_keylen == len
|
||||
&& STRNCMP(mp->m_keys, lhs, (size_t)len) == 0) {
|
||||
&& strncmp(mp->m_keys, lhs, (size_t)len) == 0) {
|
||||
if (is_abbrev) {
|
||||
semsg(_("E224: global abbreviation already exists for %s"),
|
||||
mp->m_keys);
|
||||
@@ -674,7 +674,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
did_local = true;
|
||||
} else {
|
||||
n = mp->m_keylen;
|
||||
if (STRNCMP(mp->m_keys, lhs, (size_t)(n < len ? n : len)) == 0) {
|
||||
if (strncmp(mp->m_keys, lhs, (size_t)(n < len ? n : len)) == 0) {
|
||||
showmap(mp, true);
|
||||
did_local = true;
|
||||
}
|
||||
@@ -695,7 +695,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
int hash_start, hash_end;
|
||||
if (has_lhs || is_abbrev) {
|
||||
// just use one hash
|
||||
hash_start = is_abbrev ? 0 : MAP_HASH(mode, lhs[0]);
|
||||
hash_start = is_abbrev ? 0 : MAP_HASH(mode, (uint8_t)lhs[0]);
|
||||
hash_end = hash_start + 1;
|
||||
} else {
|
||||
// need to loop over all hash lists
|
||||
@@ -718,12 +718,12 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
} else { // do we have a match?
|
||||
if (round) { // second round: Try unmap "rhs" string
|
||||
n = (int)strlen(mp->m_str);
|
||||
p = (char_u *)mp->m_str;
|
||||
p = mp->m_str;
|
||||
} else {
|
||||
n = mp->m_keylen;
|
||||
p = mp->m_keys;
|
||||
}
|
||||
if (STRNCMP(p, lhs, (size_t)(n < len ? n : len)) == 0) {
|
||||
if (strncmp(p, lhs, (size_t)(n < len ? n : len)) == 0) {
|
||||
if (maptype == MAPTYPE_UNMAP) {
|
||||
// Delete entry.
|
||||
// Only accept a full match. For abbreviations
|
||||
@@ -805,7 +805,7 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
}
|
||||
|
||||
// May need to put this entry into another hash list.
|
||||
int new_hash = MAP_HASH(mp->m_mode, mp->m_keys[0]);
|
||||
int new_hash = MAP_HASH(mp->m_mode, (uint8_t)mp->m_keys[0]);
|
||||
if (!is_abbrev && new_hash != hash) {
|
||||
*mpp = mp->m_next;
|
||||
mp->m_next = map_table[new_hash];
|
||||
@@ -1032,7 +1032,7 @@ void map_clear_mode(buf_T *buf, int mode, bool local, bool abbr)
|
||||
continue;
|
||||
}
|
||||
// May need to put this entry into another hash list.
|
||||
new_hash = MAP_HASH(mp->m_mode, mp->m_keys[0]);
|
||||
new_hash = MAP_HASH(mp->m_mode, (uint8_t)mp->m_keys[0]);
|
||||
if (!abbr && new_hash != hash) {
|
||||
*mpp = mp->m_next;
|
||||
if (local) {
|
||||
@@ -1325,7 +1325,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char ***file)
|
||||
}
|
||||
for (; mp; mp = mp->m_next) {
|
||||
if (mp->m_mode & expand_mapmodes) {
|
||||
p = (char *)translate_mapping(mp->m_keys, CPO_TO_CPO_FLAGS);
|
||||
p = (char *)translate_mapping((char_u *)mp->m_keys, CPO_TO_CPO_FLAGS);
|
||||
if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) {
|
||||
if (round == 1) {
|
||||
count++;
|
||||
@@ -1387,7 +1387,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char ***file)
|
||||
// Then there must be white space before the abbr.
|
||||
//
|
||||
// Return true if there is an abbreviation, false if not.
|
||||
bool check_abbr(int c, char_u *ptr, int col, int mincol)
|
||||
bool check_abbr(int c, char *ptr, int col, int mincol)
|
||||
{
|
||||
int len;
|
||||
int scol; // starting column of the abbr.
|
||||
@@ -1418,25 +1418,25 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
|
||||
|
||||
{
|
||||
bool vim_abbr;
|
||||
char_u *p = mb_prevptr(ptr, ptr + col);
|
||||
char_u *p = mb_prevptr((char_u *)ptr, (char_u *)ptr + col);
|
||||
if (!vim_iswordp(p)) {
|
||||
vim_abbr = true; // Vim added abbr.
|
||||
} else {
|
||||
vim_abbr = false; // vi compatible abbr.
|
||||
if (p > ptr) {
|
||||
is_id = vim_iswordp(mb_prevptr(ptr, p));
|
||||
if (p > (char_u *)ptr) {
|
||||
is_id = vim_iswordp(mb_prevptr((char_u *)ptr, p));
|
||||
}
|
||||
}
|
||||
clen = 1;
|
||||
while (p > ptr + mincol) {
|
||||
p = mb_prevptr(ptr, p);
|
||||
while (p > (char_u *)ptr + mincol) {
|
||||
p = mb_prevptr((char_u *)ptr, p);
|
||||
if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) {
|
||||
p += utfc_ptr2len((char *)p);
|
||||
break;
|
||||
}
|
||||
clen++;
|
||||
}
|
||||
scol = (int)(p - ptr);
|
||||
scol = (int)(p - (char_u *)ptr);
|
||||
}
|
||||
|
||||
if (scol < mincol) {
|
||||
@@ -1455,20 +1455,20 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
|
||||
mp->m_next == NULL ? (mp = mp2, mp2 = NULL) :
|
||||
(mp = mp->m_next)) {
|
||||
int qlen = mp->m_keylen;
|
||||
char *q = (char *)mp->m_keys;
|
||||
char *q = mp->m_keys;
|
||||
int match;
|
||||
|
||||
if (strchr((const char *)mp->m_keys, K_SPECIAL) != NULL) {
|
||||
// Might have K_SPECIAL escaped mp->m_keys.
|
||||
q = xstrdup((char *)mp->m_keys);
|
||||
q = xstrdup(mp->m_keys);
|
||||
vim_unescape_ks((char_u *)q);
|
||||
qlen = (int)strlen(q);
|
||||
}
|
||||
// find entries with right mode and keys
|
||||
match = (mp->m_mode & State)
|
||||
&& qlen == len
|
||||
&& !STRNCMP(q, ptr, (size_t)len);
|
||||
if (q != (char *)mp->m_keys) {
|
||||
&& !strncmp(q, ptr, (size_t)len);
|
||||
if (q != mp->m_keys) {
|
||||
xfree(q);
|
||||
}
|
||||
if (match) {
|
||||
@@ -1797,7 +1797,7 @@ int makemap(FILE *fd, buf_T *buf)
|
||||
}
|
||||
|
||||
if (putc(' ', fd) < 0
|
||||
|| put_escstr(fd, mp->m_keys, 0) == FAIL
|
||||
|| put_escstr(fd, (char_u *)mp->m_keys, 0) == FAIL
|
||||
|| putc(' ', fd) < 0
|
||||
|| put_escstr(fd, (char_u *)mp->m_str, 1) == FAIL
|
||||
|| put_eol(fd) < 0) {
|
||||
@@ -1954,15 +1954,15 @@ char *check_map(char *keys, int mode, int exact, int ign_mod, int abbr, mapblock
|
||||
for (; mp != NULL; mp = mp->m_next) {
|
||||
// skip entries with wrong mode, wrong length and not matching ones
|
||||
if ((mp->m_mode & mode) && (!exact || mp->m_keylen == len)) {
|
||||
char_u *s = mp->m_keys;
|
||||
char *s = mp->m_keys;
|
||||
int keylen = mp->m_keylen;
|
||||
if (ign_mod && keylen >= 3
|
||||
&& s[0] == K_SPECIAL && s[1] == KS_MODIFIER) {
|
||||
&& (uint8_t)s[0] == K_SPECIAL && (uint8_t)s[1] == KS_MODIFIER) {
|
||||
s += 3;
|
||||
keylen -= 3;
|
||||
}
|
||||
minlen = keylen < len ? keylen : len;
|
||||
if (STRNCMP(s, keys, minlen) == 0) {
|
||||
if (strncmp(s, keys, (size_t)minlen) == 0) {
|
||||
if (mp_ptr != NULL) {
|
||||
*mp_ptr = mp;
|
||||
}
|
||||
@@ -2015,7 +2015,7 @@ static Dictionary mapblock_fill_dict(const mapblock_T *const mp, const char *lhs
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
Dictionary dict = ARRAY_DICT_INIT;
|
||||
char *const lhs = str2special_save((const char *)mp->m_keys, compatible, !compatible);
|
||||
char *const lhs = str2special_save(mp->m_keys, compatible, !compatible);
|
||||
char *const mapmode = map_mode_to_chars(mp->m_mode);
|
||||
varnumber_T noremap_value;
|
||||
|
||||
|
@@ -2751,7 +2751,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar)
|
||||
return FAIL;
|
||||
}
|
||||
assert(len <= INT_MAX);
|
||||
spell_add_word((char_u *)ptr, (int)len,
|
||||
spell_add_word(ptr, (int)len,
|
||||
nchar == 'w' || nchar == 'W' ? SPELL_ADD_BAD : SPELL_ADD_GOOD,
|
||||
(nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1,
|
||||
undo);
|
||||
|
@@ -3108,12 +3108,12 @@ bool is_string_option(const char *name)
|
||||
int find_key_option_len(const char_u *arg_arg, size_t len, bool has_lt)
|
||||
{
|
||||
int key = 0;
|
||||
const char_u *arg = arg_arg;
|
||||
const char *arg = (char *)arg_arg;
|
||||
|
||||
// Don't use get_special_key_code() for t_xx, we don't want it to call
|
||||
// add_termcap_entry().
|
||||
if (len >= 4 && arg[0] == 't' && arg[1] == '_') {
|
||||
key = TERMCAP2KEY(arg[2], arg[3]);
|
||||
key = TERMCAP2KEY((uint8_t)arg[2], (uint8_t)arg[3]);
|
||||
} else if (has_lt) {
|
||||
arg--; // put arg at the '<'
|
||||
int modifiers = 0;
|
||||
|
@@ -266,7 +266,7 @@ size_t input_enqueue(String keys)
|
||||
uint8_t buf[19] = { 0 };
|
||||
// Do not simplify the keys here. Simplification will be done later.
|
||||
unsigned int new_size
|
||||
= trans_special((const uint8_t **)&ptr, (size_t)(end - ptr), buf, FSK_KEYCODE, true, NULL);
|
||||
= trans_special((const char **)&ptr, (size_t)(end - ptr), buf, FSK_KEYCODE, true, NULL);
|
||||
|
||||
if (new_size) {
|
||||
new_size = handle_mouse_event(&ptr, buf, new_size);
|
||||
|
@@ -144,7 +144,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
|
||||
|
||||
bool is_fish_shell =
|
||||
#if defined(UNIX)
|
||||
STRNCMP(invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
|
||||
strncmp((char *)invocation_path_tail((char_u *)p_sh, NULL), "fish", 4) == 0;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
|
@@ -222,7 +222,7 @@ int match_user(char *name)
|
||||
if (strcmp(((char **)ga_users.ga_data)[i], name) == 0) {
|
||||
return 2; // full match
|
||||
}
|
||||
if (STRNCMP(((char_u **)ga_users.ga_data)[i], name, n) == 0) {
|
||||
if (strncmp(((char **)ga_users.ga_data)[i], name, (size_t)n) == 0) {
|
||||
result = 1; // partial match
|
||||
}
|
||||
}
|
||||
|
@@ -233,7 +233,7 @@ static int get_char_class(char **pp)
|
||||
|
||||
if ((*pp)[1] == ':') {
|
||||
for (i = 0; i < (int)ARRAY_SIZE(class_names); i++) {
|
||||
if (STRNCMP(*pp + 2, class_names[i], strlen(class_names[i])) == 0) {
|
||||
if (strncmp(*pp + 2, class_names[i], strlen(class_names[i])) == 0) {
|
||||
*pp += strlen(class_names[i]) + 2;
|
||||
return i;
|
||||
}
|
||||
@@ -1380,7 +1380,7 @@ static int cstrncmp(char *s1, char *s2, int *n)
|
||||
int result;
|
||||
|
||||
if (!rex.reg_ic) {
|
||||
result = STRNCMP(s1, s2, *n);
|
||||
result = strncmp(s1, s2, (size_t)(*n));
|
||||
} else {
|
||||
assert(*n >= 0);
|
||||
result = mb_strnicmp(s1, s2, (size_t)(*n));
|
||||
@@ -2303,12 +2303,12 @@ static char_u regname[][30] = {
|
||||
regprog_T *vim_regcomp(char *expr_arg, int re_flags)
|
||||
{
|
||||
regprog_T *prog = NULL;
|
||||
char_u *expr = (char_u *)expr_arg;
|
||||
char *expr = expr_arg;
|
||||
|
||||
regexp_engine = (int)p_re;
|
||||
|
||||
// Check for prefix "\%#=", that sets the regexp engine
|
||||
if (STRNCMP(expr, "\\%#=", 4) == 0) {
|
||||
if (strncmp(expr, "\\%#=", 4) == 0) {
|
||||
int newengine = expr[4] - '0';
|
||||
|
||||
if (newengine == AUTOMATIC_ENGINE
|
||||
@@ -2338,10 +2338,10 @@ regprog_T *vim_regcomp(char *expr_arg, int re_flags)
|
||||
//
|
||||
const int called_emsg_before = called_emsg;
|
||||
if (regexp_engine != BACKTRACKING_ENGINE) {
|
||||
prog = nfa_regengine.regcomp(expr,
|
||||
prog = nfa_regengine.regcomp((char_u *)expr,
|
||||
re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0));
|
||||
} else {
|
||||
prog = bt_regengine.regcomp(expr, re_flags);
|
||||
prog = bt_regengine.regcomp((char_u *)expr, re_flags);
|
||||
}
|
||||
|
||||
// Check for error compiling regexp with initial engine.
|
||||
@@ -2365,8 +2365,8 @@ regprog_T *vim_regcomp(char *expr_arg, int re_flags)
|
||||
// But don't try if an error message was given.
|
||||
if (regexp_engine == AUTOMATIC_ENGINE && called_emsg == called_emsg_before) {
|
||||
regexp_engine = BACKTRACKING_ENGINE;
|
||||
report_re_switch(expr);
|
||||
prog = bt_regengine.regcomp(expr, re_flags);
|
||||
report_re_switch((char_u *)expr);
|
||||
prog = bt_regengine.regcomp((char_u *)expr, re_flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -130,7 +130,7 @@ typedef struct matchinf_S {
|
||||
langp_T *mi_lp; // info for language and region
|
||||
|
||||
// pointers to original text to be checked
|
||||
char_u *mi_word; // start of word being checked
|
||||
char *mi_word; // start of word being checked
|
||||
char_u *mi_end; // end of matching word so far
|
||||
char_u *mi_fend; // next char to be added to mi_fword
|
||||
char_u *mi_cend; // char after what was used for
|
||||
@@ -173,7 +173,7 @@ typedef struct spelload_S {
|
||||
|
||||
#define SY_MAXLEN 30
|
||||
typedef struct syl_item_S {
|
||||
char_u sy_chars[SY_MAXLEN]; // the sequence of chars
|
||||
char sy_chars[SY_MAXLEN]; // the sequence of chars
|
||||
int sy_len;
|
||||
} syl_item_T;
|
||||
|
||||
@@ -252,7 +252,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
|
||||
}
|
||||
|
||||
// Find the normal end of the word (until the next non-word character).
|
||||
mi.mi_word = ptr;
|
||||
mi.mi_word = (char *)ptr;
|
||||
mi.mi_fend = ptr;
|
||||
if (spell_iswordp(mi.mi_fend, wp)) {
|
||||
bool this_upper = false; // init for gcc
|
||||
@@ -387,7 +387,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
|
||||
// at which any word would be valid.
|
||||
mi.mi_lp = LANGP_ENTRY(wp->w_s->b_langp, 0);
|
||||
if (mi.mi_lp->lp_slang->sl_fidxs != NULL) {
|
||||
p = mi.mi_word;
|
||||
p = (char_u *)mi.mi_word;
|
||||
fp = (char_u *)mi.mi_fword;
|
||||
for (;;) {
|
||||
MB_PTR_ADV(p);
|
||||
@@ -435,7 +435,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
{
|
||||
int wlen = 0;
|
||||
int flen;
|
||||
char_u *ptr;
|
||||
char *ptr;
|
||||
slang_T *slang = mip->mi_lp->lp_slang;
|
||||
char_u *byts;
|
||||
idx_T *idxs;
|
||||
@@ -453,7 +453,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
}
|
||||
} else {
|
||||
// Check for case-folded in case-folded tree.
|
||||
ptr = (char_u *)mip->mi_fword;
|
||||
ptr = mip->mi_fword;
|
||||
flen = mip->mi_fwordlen; // available case-folded bytes
|
||||
byts = slang->sl_fbyts;
|
||||
idxs = slang->sl_fidxs;
|
||||
@@ -518,7 +518,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
}
|
||||
|
||||
// Perform a binary search in the list of accepted bytes.
|
||||
c = ptr[wlen];
|
||||
c = (uint8_t)ptr[wlen];
|
||||
if (c == TAB) { // <Tab> is handled like <Space>
|
||||
c = ' ';
|
||||
}
|
||||
@@ -562,7 +562,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
}
|
||||
}
|
||||
|
||||
char_u *p;
|
||||
char *p;
|
||||
bool word_ends;
|
||||
|
||||
// Verify that one of the possible endings is valid. Try the longest
|
||||
@@ -572,10 +572,10 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
arridx = endidx[endidxcnt];
|
||||
wlen = endlen[endidxcnt];
|
||||
|
||||
if (utf_head_off((char *)ptr, (char *)ptr + wlen) > 0) {
|
||||
if (utf_head_off(ptr, ptr + wlen) > 0) {
|
||||
continue; // not at first byte of character
|
||||
}
|
||||
if (spell_iswordp(ptr + wlen, mip->mi_win)) {
|
||||
if (spell_iswordp((char_u *)ptr + wlen, mip->mi_win)) {
|
||||
if (slang->sl_compprog == NULL && !slang->sl_nobreak) {
|
||||
continue; // next char is a word character
|
||||
}
|
||||
@@ -592,8 +592,8 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
// when folding case. This can be slow, take a shortcut when the
|
||||
// case-folded word is equal to the keep-case word.
|
||||
p = mip->mi_word;
|
||||
if (STRNCMP(ptr, p, wlen) != 0) {
|
||||
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
|
||||
if (strncmp(ptr, p, (size_t)wlen) != 0) {
|
||||
for (char *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
wlen = (int)(p - mip->mi_word);
|
||||
@@ -612,11 +612,11 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
// For keep-case tree the case is always right. For prefixes we
|
||||
// don't bother to check.
|
||||
if (mode == FIND_FOLDWORD) {
|
||||
if (mip->mi_cend != mip->mi_word + wlen) {
|
||||
if (mip->mi_cend != (char_u *)mip->mi_word + wlen) {
|
||||
// mi_capflags was set for a different word length, need
|
||||
// to do it again.
|
||||
mip->mi_cend = mip->mi_word + wlen;
|
||||
mip->mi_capflags = captype(mip->mi_word, mip->mi_cend);
|
||||
mip->mi_cend = (char_u *)mip->mi_word + wlen;
|
||||
mip->mi_capflags = captype((char_u *)mip->mi_word, mip->mi_cend);
|
||||
}
|
||||
|
||||
if (mip->mi_capflags == WF_KEEPCAP
|
||||
@@ -629,7 +629,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
// mip->mi_prefarridx that find_prefix() filled.
|
||||
c = valid_word_prefix(mip->mi_prefcnt, mip->mi_prefarridx,
|
||||
(int)flags,
|
||||
mip->mi_word + mip->mi_cprefixlen, slang,
|
||||
(char_u *)mip->mi_word + mip->mi_cprefixlen, slang,
|
||||
false);
|
||||
if (c == 0) {
|
||||
continue;
|
||||
@@ -664,7 +664,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
// For multi-byte chars check character length against
|
||||
// COMPOUNDMIN.
|
||||
if (slang->sl_compminlen > 0
|
||||
&& mb_charlen_len(mip->mi_word + mip->mi_compoff,
|
||||
&& mb_charlen_len((char_u *)mip->mi_word + mip->mi_compoff,
|
||||
wlen - mip->mi_compoff) < slang->sl_compminlen) {
|
||||
continue;
|
||||
}
|
||||
@@ -703,16 +703,16 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
|
||||
// Need to check the caps type of the appended compound
|
||||
// word.
|
||||
if (STRNCMP(ptr, mip->mi_word, mip->mi_compoff) != 0) {
|
||||
if (strncmp(ptr, mip->mi_word, (size_t)mip->mi_compoff) != 0) {
|
||||
// case folding may have changed the length
|
||||
p = mip->mi_word;
|
||||
for (char_u *s = ptr; s < ptr + mip->mi_compoff; MB_PTR_ADV(s)) {
|
||||
for (char *s = ptr; s < ptr + mip->mi_compoff; MB_PTR_ADV(s)) {
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
} else {
|
||||
p = mip->mi_word + mip->mi_compoff;
|
||||
}
|
||||
capflags = captype(p, mip->mi_word + wlen);
|
||||
capflags = captype((char_u *)p, (char_u *)mip->mi_word + wlen);
|
||||
if (capflags == WF_KEEPCAP || (capflags == WF_ALLCAP
|
||||
&& (flags & WF_FIXCAP) != 0)) {
|
||||
continue;
|
||||
@@ -724,7 +724,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
// accept a no-caps word, even when the dictionary
|
||||
// word specifies ONECAP.
|
||||
MB_PTR_BACK(mip->mi_word, p);
|
||||
if (spell_iswordp_nmw(p, mip->mi_win)
|
||||
if (spell_iswordp_nmw((char_u *)p, mip->mi_win)
|
||||
? capflags == WF_ONECAP
|
||||
: (flags & WF_ONECAP) != 0
|
||||
&& capflags != WF_ONECAP) {
|
||||
@@ -744,7 +744,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
if (slang->sl_compsylmax < MAXWLEN) {
|
||||
// "fword" is only needed for checking syllables.
|
||||
if (ptr == mip->mi_word) {
|
||||
(void)spell_casefold(mip->mi_win, ptr, wlen, fword, MAXWLEN);
|
||||
(void)spell_casefold(mip->mi_win, (char_u *)ptr, wlen, fword, MAXWLEN);
|
||||
} else {
|
||||
STRLCPY(fword, ptr, endlen[endidxcnt] + 1);
|
||||
}
|
||||
@@ -786,12 +786,12 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
// byte length in keep-case word. Length may change when
|
||||
// folding case. This can be slow, take a shortcut when
|
||||
// the case-folded word is equal to the keep-case word.
|
||||
p = (char_u *)mip->mi_fword;
|
||||
if (STRNCMP(ptr, p, wlen) != 0) {
|
||||
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
|
||||
p = mip->mi_fword;
|
||||
if (strncmp(ptr, p, (size_t)wlen) != 0) {
|
||||
for (char *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
mip->mi_compoff = (int)(p - (char_u *)mip->mi_fword);
|
||||
mip->mi_compoff = (int)(p - mip->mi_fword);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
@@ -878,16 +878,16 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
if (nobreak_result == SP_BAD) {
|
||||
if (mip->mi_result2 > res) {
|
||||
mip->mi_result2 = res;
|
||||
mip->mi_end2 = mip->mi_word + wlen;
|
||||
mip->mi_end2 = (char_u *)mip->mi_word + wlen;
|
||||
} else if (mip->mi_result2 == res
|
||||
&& mip->mi_end2 < mip->mi_word + wlen) {
|
||||
mip->mi_end2 = mip->mi_word + wlen;
|
||||
&& mip->mi_end2 < (char_u *)mip->mi_word + wlen) {
|
||||
mip->mi_end2 = (char_u *)mip->mi_word + wlen;
|
||||
}
|
||||
} else if (mip->mi_result > res) {
|
||||
mip->mi_result = res;
|
||||
mip->mi_end = mip->mi_word + wlen;
|
||||
} else if (mip->mi_result == res && mip->mi_end < mip->mi_word + wlen) {
|
||||
mip->mi_end = mip->mi_word + wlen;
|
||||
mip->mi_end = (char_u *)mip->mi_word + wlen;
|
||||
} else if (mip->mi_result == res && mip->mi_end < (char_u *)mip->mi_word + wlen) {
|
||||
mip->mi_end = (char_u *)mip->mi_word + wlen;
|
||||
}
|
||||
|
||||
if (mip->mi_result == SP_OK) {
|
||||
@@ -908,16 +908,16 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
/// end of ptr[wlen] and the second part matches after it.
|
||||
///
|
||||
/// @param gap &sl_comppat
|
||||
bool match_checkcompoundpattern(char_u *ptr, int wlen, garray_T *gap)
|
||||
bool match_checkcompoundpattern(char *ptr, int wlen, garray_T *gap)
|
||||
{
|
||||
for (int i = 0; i + 1 < gap->ga_len; i += 2) {
|
||||
char *p = ((char **)gap->ga_data)[i + 1];
|
||||
if (STRNCMP(ptr + wlen, p, strlen(p)) == 0) {
|
||||
if (strncmp(ptr + wlen, p, strlen(p)) == 0) {
|
||||
// Second part matches at start of following compound word, now
|
||||
// check if first part matches at end of previous word.
|
||||
p = ((char **)gap->ga_data)[i];
|
||||
int len = (int)strlen(p);
|
||||
if (len <= wlen && STRNCMP(ptr + wlen - len, p, len) == 0) {
|
||||
if (len <= wlen && strncmp(ptr + wlen - len, p, (size_t)len) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1111,7 +1111,7 @@ static void find_prefix(matchinf_T *mip, int mode)
|
||||
|
||||
// Case-folded length may differ from original length.
|
||||
mip->mi_cprefixlen = nofold_len((char_u *)mip->mi_fword, mip->mi_prefixlen,
|
||||
mip->mi_word);
|
||||
(char_u *)mip->mi_word);
|
||||
find_word(mip, FIND_PREFIX);
|
||||
|
||||
if (len == 0) {
|
||||
@@ -1809,7 +1809,7 @@ static int count_syllables(slang_T *slang, const char_u *word)
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (const char_u *p = word; *p != NUL; p += len) {
|
||||
for (const char *p = (char *)word; *p != NUL; p += len) {
|
||||
// When running into a space reset counter.
|
||||
if (*p == ' ') {
|
||||
len = 1;
|
||||
@@ -1822,7 +1822,7 @@ static int count_syllables(slang_T *slang, const char_u *word)
|
||||
for (int i = 0; i < slang->sl_syl_items.ga_len; i++) {
|
||||
syl_item_T *syl = ((syl_item_T *)slang->sl_syl_items.ga_data) + i;
|
||||
if (syl->sy_len > len
|
||||
&& STRNCMP(p, syl->sy_chars, syl->sy_len) == 0) {
|
||||
&& strncmp(p, syl->sy_chars, (size_t)syl->sy_len) == 0) {
|
||||
len = syl->sy_len;
|
||||
}
|
||||
}
|
||||
@@ -1831,8 +1831,8 @@ static int count_syllables(slang_T *slang, const char_u *word)
|
||||
skip = false;
|
||||
} else {
|
||||
// No recognized syllable item, at least a syllable char then?
|
||||
int c = utf_ptr2char((char *)p);
|
||||
len = utfc_ptr2len((char *)p);
|
||||
int c = utf_ptr2char(p);
|
||||
len = utfc_ptr2len(p);
|
||||
if (vim_strchr((char *)slang->sl_syllable, c) == NULL) {
|
||||
skip = false; // No, search for next syllable
|
||||
} else if (!skip) {
|
||||
|
@@ -72,8 +72,8 @@ typedef int idx_T;
|
||||
// si_repsal, sl_rep, and si_sal. Not for sl_sal!
|
||||
// One replacement: from "ft_from" to "ft_to".
|
||||
typedef struct fromto_S {
|
||||
uint8_t *ft_from;
|
||||
uint8_t *ft_to;
|
||||
char *ft_from;
|
||||
char *ft_to;
|
||||
} fromto_T;
|
||||
|
||||
// Info from "SAL" entries in ".aff" file used in sl_sal.
|
||||
|
@@ -899,7 +899,7 @@ void suggest_load_files(void)
|
||||
slang_T *slang;
|
||||
char *dotp;
|
||||
FILE *fd;
|
||||
char_u buf[MAXWLEN];
|
||||
char buf[MAXWLEN];
|
||||
int i;
|
||||
time_t timestamp;
|
||||
int wcount;
|
||||
@@ -929,9 +929,9 @@ void suggest_load_files(void)
|
||||
|
||||
// <SUGHEADER>: <fileID> <versionnr> <timestamp>
|
||||
for (i = 0; i < VIMSUGMAGICL; i++) {
|
||||
buf[i] = (char_u)getc(fd); // <fileID>
|
||||
buf[i] = (char)getc(fd); // <fileID>
|
||||
}
|
||||
if (STRNCMP(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0) {
|
||||
if (strncmp(buf, VIMSUGMAGIC, VIMSUGMAGICL) != 0) {
|
||||
semsg(_("E778: This does not look like a .sug file: %s"),
|
||||
slang->sl_fname);
|
||||
goto nextone;
|
||||
@@ -1147,14 +1147,14 @@ static int read_rep_section(FILE *fd, garray_T *gap, int16_t *first)
|
||||
for (; gap->ga_len < cnt; ++gap->ga_len) {
|
||||
int c;
|
||||
ftp = &((fromto_T *)gap->ga_data)[gap->ga_len];
|
||||
ftp->ft_from = read_cnt_string(fd, 1, &c);
|
||||
ftp->ft_from = (char *)read_cnt_string(fd, 1, &c);
|
||||
if (c < 0) {
|
||||
return c;
|
||||
}
|
||||
if (c == 0) {
|
||||
return SP_FORMERROR;
|
||||
}
|
||||
ftp->ft_to = read_cnt_string(fd, 1, &c);
|
||||
ftp->ft_to = (char *)read_cnt_string(fd, 1, &c);
|
||||
if (c <= 0) {
|
||||
xfree(ftp->ft_from);
|
||||
if (c < 0) {
|
||||
@@ -1170,8 +1170,8 @@ static int read_rep_section(FILE *fd, garray_T *gap, int16_t *first)
|
||||
}
|
||||
for (int i = 0; i < gap->ga_len; i++) {
|
||||
ftp = &((fromto_T *)gap->ga_data)[i];
|
||||
if (first[*ftp->ft_from] == -1) {
|
||||
first[*ftp->ft_from] = (int16_t)i;
|
||||
if (first[(uint8_t)(*ftp->ft_from)] == -1) {
|
||||
first[(uint8_t)(*ftp->ft_from)] = (int16_t)i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -3057,9 +3057,9 @@ static void add_fromto(spellinfo_T *spin, garray_T *gap, char *from, char *to)
|
||||
|
||||
fromto_T *ftp = GA_APPEND_VIA_PTR(fromto_T, gap);
|
||||
(void)spell_casefold(curwin, (char_u *)from, (int)strlen(from), word, MAXWLEN);
|
||||
ftp->ft_from = (char_u *)getroom_save(spin, (char *)word);
|
||||
ftp->ft_from = getroom_save(spin, (char *)word);
|
||||
(void)spell_casefold(curwin, (char_u *)to, (int)strlen(to), word, MAXWLEN);
|
||||
ftp->ft_to = (char_u *)getroom_save(spin, (char *)word);
|
||||
ftp->ft_to = getroom_save(spin, (char *)word);
|
||||
}
|
||||
|
||||
/// Converts a boolean argument in a SAL line to true or false;
|
||||
@@ -4360,7 +4360,7 @@ static int rep_compare(const void *s1, const void *s2)
|
||||
fromto_T *p1 = (fromto_T *)s1;
|
||||
fromto_T *p2 = (fromto_T *)s2;
|
||||
|
||||
return strcmp((char *)p1->ft_from, (char *)p2->ft_from);
|
||||
return strcmp(p1->ft_from, p2->ft_from);
|
||||
}
|
||||
|
||||
/// Write the Vim .spl file "fname".
|
||||
@@ -4516,8 +4516,8 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
||||
assert(gap->ga_len >= 0);
|
||||
for (size_t i = 0; i < (size_t)gap->ga_len; i++) {
|
||||
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
|
||||
l += 1 + strlen((char *)ftp->ft_from); // count <*fromlen> and <*from>
|
||||
l += 1 + strlen((char *)ftp->ft_to); // count <*tolen> and <*to>
|
||||
l += 1 + strlen(ftp->ft_from); // count <*fromlen> and <*from>
|
||||
l += 1 + strlen(ftp->ft_to); // count <*tolen> and <*to>
|
||||
}
|
||||
if (round == 2) {
|
||||
l++; // count <salflags>
|
||||
@@ -4544,7 +4544,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
||||
// <sal> : <salfromlen> <salfrom> <saltolen> <salto>
|
||||
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
|
||||
for (unsigned int rr = 1; rr <= 2; rr++) {
|
||||
char *p = rr == 1 ? (char *)ftp->ft_from : (char *)ftp->ft_to;
|
||||
char *p = rr == 1 ? ftp->ft_from : ftp->ft_to;
|
||||
l = strlen(p);
|
||||
assert(l < INT_MAX);
|
||||
putc((int)l, fd);
|
||||
@@ -5516,7 +5516,7 @@ static void spell_message(const spellinfo_T *spin, char *str)
|
||||
// ":[count]spellrare {word}"
|
||||
void ex_spell(exarg_T *eap)
|
||||
{
|
||||
spell_add_word((char_u *)eap->arg, (int)strlen(eap->arg),
|
||||
spell_add_word(eap->arg, (int)strlen(eap->arg),
|
||||
eap->cmdidx == CMD_spellwrong ? SPELL_ADD_BAD :
|
||||
eap->cmdidx == CMD_spellrare ? SPELL_ADD_RARE : SPELL_ADD_GOOD,
|
||||
eap->forceit ? 0 : (int)eap->line2,
|
||||
@@ -5528,19 +5528,19 @@ void ex_spell(exarg_T *eap)
|
||||
/// @param what SPELL_ADD_ values
|
||||
/// @param idx "zG" and "zW": zero, otherwise index in 'spellfile'
|
||||
/// @param bool // true for "zug", "zuG", "zuw" and "zuW"
|
||||
void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo)
|
||||
void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo)
|
||||
{
|
||||
FILE *fd = NULL;
|
||||
buf_T *buf = NULL;
|
||||
bool new_spf = false;
|
||||
char *fname;
|
||||
char_u *fnamebuf = NULL;
|
||||
char_u line[MAXWLEN * 2];
|
||||
char line[MAXWLEN * 2];
|
||||
long fpos, fpos_next = 0;
|
||||
int i;
|
||||
char_u *spf;
|
||||
|
||||
if (!valid_spell_word((char *)word, (char *)word + len)) {
|
||||
if (!valid_spell_word(word, word + len)) {
|
||||
emsg(_(e_illegal_character_in_word));
|
||||
return;
|
||||
}
|
||||
@@ -5603,8 +5603,8 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo
|
||||
if (fpos_next < 0) {
|
||||
break; // should never happen
|
||||
}
|
||||
if (STRNCMP(word, line, len) == 0
|
||||
&& (line[len] == '/' || line[len] < ' ')) {
|
||||
if (strncmp(word, line, (size_t)len) == 0
|
||||
&& (line[len] == '/' || (uint8_t)line[len] < ' ')) {
|
||||
// Found duplicate word. Remove it by writing a '#' at
|
||||
// the start of the line. Mixing reading and writing
|
||||
// doesn't work for all systems, close the file first.
|
||||
|
@@ -75,7 +75,7 @@ typedef struct suginfo_S {
|
||||
int su_badlen; ///< length of detected bad word in line
|
||||
int su_badflags; ///< caps flags for bad word
|
||||
char_u su_badword[MAXWLEN]; ///< bad word truncated at su_badlen
|
||||
char_u su_fbadword[MAXWLEN]; ///< su_badword case-folded
|
||||
char su_fbadword[MAXWLEN]; ///< su_badword case-folded
|
||||
char_u su_sal_badword[MAXWLEN]; ///< su_badword soundfolded
|
||||
hashtab_T su_banned; ///< table with banned words
|
||||
slang_T *su_sallang; ///< default language for sound folding
|
||||
@@ -744,7 +744,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
||||
su->su_badlen = MAXWLEN - 1; // just in case
|
||||
}
|
||||
STRLCPY(su->su_badword, su->su_badptr, su->su_badlen + 1);
|
||||
(void)spell_casefold(curwin, (char_u *)su->su_badptr, su->su_badlen, su->su_fbadword,
|
||||
(void)spell_casefold(curwin, (char_u *)su->su_badptr, su->su_badlen, (char_u *)su->su_fbadword,
|
||||
MAXWLEN);
|
||||
|
||||
// TODO(vim): make this work if the case-folded text is longer than the
|
||||
@@ -1004,20 +1004,20 @@ static void spell_find_cleanup(suginfo_T *su)
|
||||
/// Try finding suggestions by recognizing specific situations.
|
||||
static void suggest_try_special(suginfo_T *su)
|
||||
{
|
||||
int c;
|
||||
char c;
|
||||
char_u word[MAXWLEN];
|
||||
|
||||
// Recognize a word that is repeated: "the the".
|
||||
char *p = skiptowhite((char *)su->su_fbadword);
|
||||
size_t len = (size_t)(p - (char *)su->su_fbadword);
|
||||
p = skipwhite(p);
|
||||
if (strlen(p) == len && STRNCMP(su->su_fbadword, p, len) == 0) {
|
||||
if (strlen(p) == len && strncmp(su->su_fbadword, p, len) == 0) {
|
||||
// Include badflags: if the badword is onecap or allcap
|
||||
// use that for the goodword too: "The the" -> "The".
|
||||
c = su->su_fbadword[len];
|
||||
su->su_fbadword[len] = NUL;
|
||||
make_case_word(su->su_fbadword, word, su->su_badflags);
|
||||
su->su_fbadword[len] = (char_u)c;
|
||||
make_case_word((char_u *)su->su_fbadword, word, su->su_badflags);
|
||||
su->su_fbadword[len] = c;
|
||||
|
||||
// Give a soundalike score of 0, compute the score as if deleting one
|
||||
// character.
|
||||
@@ -1106,7 +1106,7 @@ static void suggest_try_change(suginfo_T *su)
|
||||
#ifdef SUGGEST_PROFILE
|
||||
prof_init();
|
||||
#endif
|
||||
suggest_trie_walk(su, lp, (char_u *)fword, false);
|
||||
suggest_trie_walk(su, lp, fword, false);
|
||||
#ifdef SUGGEST_PROFILE
|
||||
prof_report("try_change");
|
||||
#endif
|
||||
@@ -1146,9 +1146,9 @@ static void suggest_try_change(suginfo_T *su)
|
||||
/// word splitting for now
|
||||
/// "similar_chars()"
|
||||
/// use "slang->sl_repsal" instead of "lp->lp_replang->sl_rep"
|
||||
static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool soundfold)
|
||||
static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soundfold)
|
||||
{
|
||||
char_u tword[MAXWLEN]; // good word collected so far
|
||||
char tword[MAXWLEN]; // good word collected so far
|
||||
trystate_T stack[MAXWLEN];
|
||||
char preword[MAXWLEN * 3] = { 0 }; // word found with proper case;
|
||||
// concatenation of prefix compound
|
||||
@@ -1168,7 +1168,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
garray_T *gap;
|
||||
idx_T arridx;
|
||||
int len;
|
||||
char_u *p;
|
||||
char *p;
|
||||
fromto_T *ftp;
|
||||
int fl = 0, tl;
|
||||
int repextra = 0; // extra bytes in fword[] from REP item
|
||||
@@ -1258,7 +1258,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
if (depth < MAXWLEN - 1 && (byts[arridx] == 0 || n == STATE_NOPREFIX)) {
|
||||
// Set su->su_badflags to the caps type at this position.
|
||||
// Use the caps type until here for the prefix itself.
|
||||
n = nofold_len(fword, sp->ts_fidx, (char_u *)su->su_badptr);
|
||||
n = nofold_len((char_u *)fword, sp->ts_fidx, (char_u *)su->su_badptr);
|
||||
flags = badword_captype((char_u *)su->su_badptr, (char_u *)su->su_badptr + n);
|
||||
su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
|
||||
(char_u *)su->su_badptr + su->su_badlen);
|
||||
@@ -1276,7 +1276,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// Move the prefix to preword[] with the right case
|
||||
// and make find_keepcap_word() works.
|
||||
tword[sp->ts_twordlen] = NUL;
|
||||
make_case_word(tword + sp->ts_splitoff,
|
||||
make_case_word((char_u *)tword + sp->ts_splitoff,
|
||||
(char_u *)preword + sp->ts_prewordlen, flags);
|
||||
sp->ts_prewordlen = (char_u)strlen(preword);
|
||||
sp->ts_splitoff = sp->ts_twordlen;
|
||||
@@ -1305,7 +1305,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
fword_ends = (fword[sp->ts_fidx] == NUL
|
||||
|| (soundfold
|
||||
? ascii_iswhite(fword[sp->ts_fidx])
|
||||
: !spell_iswordp(fword + sp->ts_fidx, curwin)));
|
||||
: !spell_iswordp((char_u *)fword + sp->ts_fidx, curwin)));
|
||||
tword[sp->ts_twordlen] = NUL;
|
||||
|
||||
if (sp->ts_prefixdepth <= PFD_NOTSPECIAL
|
||||
@@ -1320,7 +1320,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
for (c = 0; c < len && pbyts[n + c] == 0; c++) {}
|
||||
if (c > 0) {
|
||||
c = valid_word_prefix(c, n, flags,
|
||||
tword + sp->ts_splitoff, slang, false);
|
||||
(char_u *)tword + sp->ts_splitoff, slang, false);
|
||||
if (c == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -1357,7 +1357,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// need to check if a correct word follows.
|
||||
if (sp->ts_fidx - sp->ts_splitfidx
|
||||
== sp->ts_twordlen - sp->ts_splitoff
|
||||
&& STRNCMP(fword + sp->ts_splitfidx,
|
||||
&& strncmp(fword + sp->ts_splitfidx,
|
||||
tword + sp->ts_splitoff,
|
||||
sp->ts_fidx - sp->ts_splitfidx) == 0) {
|
||||
preword[sp->ts_prewordlen] = NUL;
|
||||
@@ -1386,7 +1386,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// For multi-byte chars check character length against
|
||||
// COMPOUNDMIN.
|
||||
if (slang->sl_compminlen > 0
|
||||
&& mb_charlen(tword + sp->ts_splitoff)
|
||||
&& mb_charlen((char_u *)tword + sp->ts_splitoff)
|
||||
< slang->sl_compminlen) {
|
||||
break;
|
||||
}
|
||||
@@ -1398,17 +1398,17 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
sp->ts_twordlen - sp->ts_splitoff + 1);
|
||||
|
||||
// Verify CHECKCOMPOUNDPATTERN rules.
|
||||
if (match_checkcompoundpattern((char_u *)preword, sp->ts_prewordlen,
|
||||
if (match_checkcompoundpattern(preword, sp->ts_prewordlen,
|
||||
&slang->sl_comppat)) {
|
||||
compound_ok = false;
|
||||
}
|
||||
|
||||
if (compound_ok) {
|
||||
p = (char_u *)preword;
|
||||
while (*skiptowhite((char *)p) != NUL) {
|
||||
p = (char_u *)skipwhite(skiptowhite((char *)p));
|
||||
p = preword;
|
||||
while (*skiptowhite(p) != NUL) {
|
||||
p = skipwhite(skiptowhite(p));
|
||||
}
|
||||
if (fword_ends && !can_compound(slang, (char *)p, compflags + sp->ts_compsplit)) {
|
||||
if (fword_ends && !can_compound(slang, p, compflags + sp->ts_compsplit)) {
|
||||
// Compound is not allowed. But it may still be
|
||||
// possible if we add another (short) word.
|
||||
compound_ok = false;
|
||||
@@ -1416,7 +1416,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
}
|
||||
|
||||
// Get pointer to last char of previous word.
|
||||
p = (char_u *)preword + sp->ts_prewordlen;
|
||||
p = preword + sp->ts_prewordlen;
|
||||
MB_PTR_BACK(preword, p);
|
||||
}
|
||||
}
|
||||
@@ -1441,10 +1441,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
|
||||
// When appending a compound word after a word character don't
|
||||
// use Onecap.
|
||||
if (p != NULL && spell_iswordp_nmw(p, curwin)) {
|
||||
if (p != NULL && spell_iswordp_nmw((char_u *)p, curwin)) {
|
||||
c &= ~WF_ONECAP;
|
||||
}
|
||||
make_case_word(tword + sp->ts_splitoff,
|
||||
make_case_word((char_u *)tword + sp->ts_splitoff,
|
||||
(char_u *)preword + sp->ts_prewordlen, c);
|
||||
}
|
||||
|
||||
@@ -1508,10 +1508,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// char, e.g., "thes," -> "these".
|
||||
p = fword + sp->ts_fidx;
|
||||
MB_PTR_BACK(fword, p);
|
||||
if (!spell_iswordp(p, curwin) && *preword != NUL) {
|
||||
p = (char_u *)preword + strlen(preword);
|
||||
if (!spell_iswordp((char_u *)p, curwin) && *preword != NUL) {
|
||||
p = preword + strlen(preword);
|
||||
MB_PTR_BACK(preword, p);
|
||||
if (spell_iswordp(p, curwin)) {
|
||||
if (spell_iswordp((char_u *)p, curwin)) {
|
||||
newscore += SCORE_NONWORD;
|
||||
}
|
||||
}
|
||||
@@ -1533,7 +1533,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// upper or lower case, add both.
|
||||
c = captype((char_u *)preword, NULL);
|
||||
if (c == 0 || c == WF_ALLCAP) {
|
||||
make_case_word(tword + sp->ts_splitoff,
|
||||
make_case_word((char_u *)tword + sp->ts_splitoff,
|
||||
(char_u *)preword + sp->ts_prewordlen,
|
||||
c == 0 ? WF_ALLCAP : 0);
|
||||
|
||||
@@ -1582,7 +1582,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
&& sp->ts_twordlen - sp->ts_splitoff
|
||||
>= slang->sl_compminlen
|
||||
&& (slang->sl_compminlen == 0
|
||||
|| mb_charlen(tword + sp->ts_splitoff)
|
||||
|| mb_charlen((char_u *)tword + sp->ts_splitoff)
|
||||
>= slang->sl_compminlen)
|
||||
&& (slang->sl_compsylmax < MAXWLEN
|
||||
|| sp->ts_complen + 1 - sp->ts_compsplit
|
||||
@@ -1621,12 +1621,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
&& (flags & WF_NEEDCOMP)) {
|
||||
break;
|
||||
}
|
||||
p = (char_u *)preword;
|
||||
while (*skiptowhite((char *)p) != NUL) {
|
||||
p = (char_u *)skipwhite(skiptowhite((char *)p));
|
||||
p = preword;
|
||||
while (*skiptowhite(p) != NUL) {
|
||||
p = skipwhite(skiptowhite(p));
|
||||
}
|
||||
if (sp->ts_complen > sp->ts_compsplit
|
||||
&& !can_compound(slang, (char *)p, compflags + sp->ts_compsplit)) {
|
||||
&& !can_compound(slang, p, compflags + sp->ts_compsplit)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1673,7 +1673,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// non-word character with a space. Always skip a
|
||||
// character when the word ends. But only when the
|
||||
// good word can end.
|
||||
if (((!try_compound && !spell_iswordp_nmw(fword
|
||||
if (((!try_compound && !spell_iswordp_nmw((char_u *)fword
|
||||
+ sp->ts_fidx,
|
||||
curwin))
|
||||
|| fword_ends)
|
||||
@@ -1681,7 +1681,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
&& goodword_ends) {
|
||||
int l;
|
||||
|
||||
l = utfc_ptr2len((char *)fword + sp->ts_fidx);
|
||||
l = utfc_ptr2len(fword + sp->ts_fidx);
|
||||
if (fword_ends) {
|
||||
// Copy the skipped character to preword.
|
||||
memmove(preword + sp->ts_prewordlen, fword + sp->ts_fidx, (size_t)l);
|
||||
@@ -1705,7 +1705,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
|
||||
// set su->su_badflags to the caps type at this
|
||||
// position
|
||||
n = nofold_len(fword, sp->ts_fidx, (char_u *)su->su_badptr);
|
||||
n = nofold_len((char_u *)fword, sp->ts_fidx, (char_u *)su->su_badptr);
|
||||
su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
|
||||
(char_u *)su->su_badptr + su->su_badlen);
|
||||
|
||||
@@ -1774,7 +1774,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// when the byte was already changed. And don't try when we
|
||||
// just deleted this byte, accepting it is always cheaper than
|
||||
// delete + substitute.
|
||||
if (c == fword[sp->ts_fidx]
|
||||
if (c == (uint8_t)fword[sp->ts_fidx]
|
||||
|| (sp->ts_tcharlen > 0
|
||||
&& sp->ts_isdiff != DIFF_NONE)) {
|
||||
newscore = 0;
|
||||
@@ -1784,7 +1784,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
if ((newscore == 0
|
||||
|| (sp->ts_fidx >= sp->ts_fidxtry
|
||||
&& ((sp->ts_flags & TSF_DIDDEL) == 0
|
||||
|| c != fword[sp->ts_delidx])))
|
||||
|| c != (uint8_t)fword[sp->ts_delidx])))
|
||||
&& TRY_DEEPER(su, stack, depth, newscore)) {
|
||||
go_deeper(stack, depth, newscore);
|
||||
#ifdef DEBUG_TRIEWALK
|
||||
@@ -1803,7 +1803,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
if (fword[sp->ts_fidx] != NUL) {
|
||||
sp->ts_fidx++;
|
||||
}
|
||||
tword[sp->ts_twordlen++] = (char_u)c;
|
||||
tword[sp->ts_twordlen++] = (char)c;
|
||||
sp->ts_arridx = idxs[arridx];
|
||||
if (newscore == SCORE_SUBST) {
|
||||
sp->ts_isdiff = DIFF_YES;
|
||||
@@ -1829,14 +1829,14 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// Correct ts_fidx for the byte length of the
|
||||
// character (we didn't check that before).
|
||||
sp->ts_fidx = (char_u)(sp->ts_fcharstart
|
||||
+ utfc_ptr2len((char *)fword + sp->ts_fcharstart));
|
||||
+ utfc_ptr2len(fword + sp->ts_fcharstart));
|
||||
|
||||
// For changing a composing character adjust
|
||||
// the score from SCORE_SUBST to
|
||||
// SCORE_SUBCOMP.
|
||||
if (utf_iscomposing(utf_ptr2char((char *)tword + sp->ts_twordlen
|
||||
- sp->ts_tcharlen))
|
||||
&& utf_iscomposing(utf_ptr2char((char *)fword
|
||||
&& utf_iscomposing(utf_ptr2char(fword
|
||||
+ sp->ts_fcharstart))) {
|
||||
sp->ts_score -= SCORE_SUBST - SCORE_SUBCOMP;
|
||||
} else if (!soundfold
|
||||
@@ -1844,15 +1844,15 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
&& similar_chars(slang,
|
||||
utf_ptr2char((char *)tword + sp->ts_twordlen -
|
||||
sp->ts_tcharlen),
|
||||
utf_ptr2char((char *)fword + sp->ts_fcharstart))) {
|
||||
utf_ptr2char(fword + sp->ts_fcharstart))) {
|
||||
// For a similar character adjust score from
|
||||
// SCORE_SUBST to SCORE_SIMILAR.
|
||||
sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR;
|
||||
}
|
||||
} else if (sp->ts_isdiff == DIFF_INSERT
|
||||
&& sp->ts_twordlen > sp->ts_tcharlen) {
|
||||
p = tword + sp->ts_twordlen - sp->ts_tcharlen;
|
||||
c = utf_ptr2char((char *)p);
|
||||
p = (char *)tword + sp->ts_twordlen - sp->ts_tcharlen;
|
||||
c = utf_ptr2char(p);
|
||||
if (utf_iscomposing(c)) {
|
||||
// Inserting a composing char doesn't
|
||||
// count that much.
|
||||
@@ -1864,7 +1864,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// tree (might seem illogical but does
|
||||
// give better scores).
|
||||
MB_PTR_BACK(tword, p);
|
||||
if (c == utf_ptr2char((char *)p)) {
|
||||
if (c == utf_ptr2char(p)) {
|
||||
sp->ts_score -= SCORE_INS - SCORE_INSDUP;
|
||||
}
|
||||
}
|
||||
@@ -1915,12 +1915,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// score if the same character is following "nn" -> "n". It's
|
||||
// a bit illogical for soundfold tree but it does give better
|
||||
// results.
|
||||
c = utf_ptr2char((char *)fword + sp->ts_fidx);
|
||||
c = utf_ptr2char(fword + sp->ts_fidx);
|
||||
stack[depth].ts_fidx =
|
||||
(char_u)(stack[depth].ts_fidx + utfc_ptr2len((char *)fword + sp->ts_fidx));
|
||||
(char_u)(stack[depth].ts_fidx + utfc_ptr2len(fword + sp->ts_fidx));
|
||||
if (utf_iscomposing(c)) {
|
||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
|
||||
} else if (c == utf_ptr2char((char *)fword + stack[depth].ts_fidx)) {
|
||||
} else if (c == utf_ptr2char(fword + stack[depth].ts_fidx)) {
|
||||
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
|
||||
}
|
||||
|
||||
@@ -1980,7 +1980,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
} else {
|
||||
newscore = SCORE_INS;
|
||||
}
|
||||
if (c != fword[sp->ts_fidx]
|
||||
if (c != (uint8_t)fword[sp->ts_fidx]
|
||||
&& TRY_DEEPER(su, stack, depth, newscore)) {
|
||||
go_deeper(stack, depth, newscore);
|
||||
#ifdef DEBUG_TRIEWALK
|
||||
@@ -1990,7 +1990,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
#endif
|
||||
depth++;
|
||||
sp = &stack[depth];
|
||||
tword[sp->ts_twordlen++] = (char_u)c;
|
||||
tword[sp->ts_twordlen++] = (char)c;
|
||||
sp->ts_arridx = idxs[n];
|
||||
fl = MB_BYTE2LEN(c);
|
||||
if (fl > 1) {
|
||||
@@ -2007,7 +2007,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// soundfold words (illogical but does give a better
|
||||
// score).
|
||||
if (sp->ts_twordlen >= 2
|
||||
&& tword[sp->ts_twordlen - 2] == c) {
|
||||
&& (uint8_t)tword[sp->ts_twordlen - 2] == c) {
|
||||
sp->ts_score -= SCORE_INS - SCORE_INSDUP;
|
||||
}
|
||||
}
|
||||
@@ -2019,7 +2019,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// We change "fword" here, it's changed back afterwards at
|
||||
// STATE_UNSWAP.
|
||||
p = fword + sp->ts_fidx;
|
||||
c = *p;
|
||||
c = (uint8_t)(*p);
|
||||
if (c == NUL) {
|
||||
// End of word, can't swap or replace.
|
||||
PROF_STORE(sp->ts_state)
|
||||
@@ -2029,20 +2029,20 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
|
||||
// Don't swap if the first character is not a word character.
|
||||
// SWAP3 etc. also don't make sense then.
|
||||
if (!soundfold && !spell_iswordp(p, curwin)) {
|
||||
if (!soundfold && !spell_iswordp((char_u *)p, curwin)) {
|
||||
PROF_STORE(sp->ts_state)
|
||||
sp->ts_state = STATE_REP_INI;
|
||||
break;
|
||||
}
|
||||
|
||||
n = utf_ptr2len((char *)p);
|
||||
c = utf_ptr2char((char *)p);
|
||||
n = utf_ptr2len(p);
|
||||
c = utf_ptr2char(p);
|
||||
if (p[n] == NUL) {
|
||||
c2 = NUL;
|
||||
} else if (!soundfold && !spell_iswordp(p + n, curwin)) {
|
||||
} else if (!soundfold && !spell_iswordp((char_u *)p + n, curwin)) {
|
||||
c2 = c; // don't swap non-word char
|
||||
} else {
|
||||
c2 = utf_ptr2char((char *)p + n);
|
||||
c2 = utf_ptr2char(p + n);
|
||||
}
|
||||
|
||||
// When the second character is NUL we can't swap.
|
||||
@@ -2072,7 +2072,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
depth++;
|
||||
fl = utf_char2len(c2);
|
||||
memmove(p, p + n, (size_t)fl);
|
||||
utf_char2bytes(c, (char *)p + fl);
|
||||
utf_char2bytes(c, p + fl);
|
||||
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl);
|
||||
} else {
|
||||
// If this swap doesn't work then SWAP3 won't either.
|
||||
@@ -2084,10 +2084,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
case STATE_UNSWAP:
|
||||
// Undo the STATE_SWAP swap: "21" -> "12".
|
||||
p = fword + sp->ts_fidx;
|
||||
n = utfc_ptr2len((char *)p);
|
||||
c = utf_ptr2char((char *)p + n);
|
||||
memmove(p + utfc_ptr2len((char *)p + n), p, (size_t)n);
|
||||
utf_char2bytes(c, (char *)p);
|
||||
n = utfc_ptr2len(p);
|
||||
c = utf_ptr2char(p + n);
|
||||
memmove(p + utfc_ptr2len(p + n), p, (size_t)n);
|
||||
utf_char2bytes(c, p);
|
||||
|
||||
FALLTHROUGH;
|
||||
|
||||
@@ -2095,14 +2095,14 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// Swap two bytes, skipping one: "123" -> "321". We change
|
||||
// "fword" here, it's changed back afterwards at STATE_UNSWAP3.
|
||||
p = fword + sp->ts_fidx;
|
||||
n = utf_ptr2len((char *)p);
|
||||
c = utf_ptr2char((char *)p);
|
||||
fl = utf_ptr2len((char *)p + n);
|
||||
c2 = utf_ptr2char((char *)p + n);
|
||||
if (!soundfold && !spell_iswordp(p + n + fl, curwin)) {
|
||||
n = utf_ptr2len(p);
|
||||
c = utf_ptr2char(p);
|
||||
fl = utf_ptr2len(p + n);
|
||||
c2 = utf_ptr2char(p + n);
|
||||
if (!soundfold && !spell_iswordp((char_u *)p + n + fl, curwin)) {
|
||||
c3 = c; // don't swap non-word char
|
||||
} else {
|
||||
c3 = utf_ptr2char((char *)p + n + fl);
|
||||
c3 = utf_ptr2char(p + n + fl);
|
||||
}
|
||||
|
||||
// When characters are identical: "121" then SWAP3 result is
|
||||
@@ -2128,8 +2128,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
depth++;
|
||||
tl = utf_char2len(c3);
|
||||
memmove(p, p + n + fl, (size_t)tl);
|
||||
utf_char2bytes(c2, (char *)p + tl);
|
||||
utf_char2bytes(c, (char *)p + fl + tl);
|
||||
utf_char2bytes(c2, p + tl);
|
||||
utf_char2bytes(c, p + fl + tl);
|
||||
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl + tl);
|
||||
} else {
|
||||
PROF_STORE(sp->ts_state)
|
||||
@@ -2140,17 +2140,17 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
case STATE_UNSWAP3:
|
||||
// Undo STATE_SWAP3: "321" -> "123"
|
||||
p = fword + sp->ts_fidx;
|
||||
n = utfc_ptr2len((char *)p);
|
||||
c2 = utf_ptr2char((char *)p + n);
|
||||
fl = utfc_ptr2len((char *)p + n);
|
||||
c = utf_ptr2char((char *)p + n + fl);
|
||||
tl = utfc_ptr2len((char *)p + n + fl);
|
||||
n = utfc_ptr2len(p);
|
||||
c2 = utf_ptr2char(p + n);
|
||||
fl = utfc_ptr2len(p + n);
|
||||
c = utf_ptr2char(p + n + fl);
|
||||
tl = utfc_ptr2len(p + n + fl);
|
||||
memmove(p + fl + tl, p, (size_t)n);
|
||||
utf_char2bytes(c, (char *)p);
|
||||
utf_char2bytes(c2, (char *)p + tl);
|
||||
utf_char2bytes(c, p);
|
||||
utf_char2bytes(c2, p + tl);
|
||||
p = p + tl;
|
||||
|
||||
if (!soundfold && !spell_iswordp(p, curwin)) {
|
||||
if (!soundfold && !spell_iswordp((char_u *)p, curwin)) {
|
||||
// Middle char is not a word char, skip the rotate. First and
|
||||
// third char were already checked at swap and swap3.
|
||||
PROF_STORE(sp->ts_state)
|
||||
@@ -2172,12 +2172,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
sp->ts_state = STATE_UNROT3L;
|
||||
depth++;
|
||||
p = fword + sp->ts_fidx;
|
||||
n = utf_ptr2len((char *)p);
|
||||
c = utf_ptr2char((char *)p);
|
||||
fl = utf_ptr2len((char *)p + n);
|
||||
fl += utf_ptr2len((char *)p + n + fl);
|
||||
n = utf_ptr2len(p);
|
||||
c = utf_ptr2char(p);
|
||||
fl = utf_ptr2len(p + n);
|
||||
fl += utf_ptr2len(p + n + fl);
|
||||
memmove(p, p + n, (size_t)fl);
|
||||
utf_char2bytes(c, (char *)p + fl);
|
||||
utf_char2bytes(c, p + fl);
|
||||
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + fl);
|
||||
} else {
|
||||
PROF_STORE(sp->ts_state)
|
||||
@@ -2188,12 +2188,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
case STATE_UNROT3L:
|
||||
// Undo ROT3L: "231" -> "123"
|
||||
p = fword + sp->ts_fidx;
|
||||
n = utfc_ptr2len((char *)p);
|
||||
n += utfc_ptr2len((char *)p + n);
|
||||
c = utf_ptr2char((char *)p + n);
|
||||
tl = utfc_ptr2len((char *)p + n);
|
||||
n = utfc_ptr2len(p);
|
||||
n += utfc_ptr2len(p + n);
|
||||
c = utf_ptr2char(p + n);
|
||||
tl = utfc_ptr2len(p + n);
|
||||
memmove(p + tl, p, (size_t)n);
|
||||
utf_char2bytes(c, (char *)p);
|
||||
utf_char2bytes(c, p);
|
||||
|
||||
// Rotate three bytes right: "123" -> "312". We change "fword"
|
||||
// here, it's changed back afterwards at STATE_UNROT3R.
|
||||
@@ -2209,12 +2209,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
sp->ts_state = STATE_UNROT3R;
|
||||
depth++;
|
||||
p = fword + sp->ts_fidx;
|
||||
n = utf_ptr2len((char *)p);
|
||||
n += utf_ptr2len((char *)p + n);
|
||||
c = utf_ptr2char((char *)p + n);
|
||||
tl = utf_ptr2len((char *)p + n);
|
||||
n = utf_ptr2len(p);
|
||||
n += utf_ptr2len(p + n);
|
||||
c = utf_ptr2char(p + n);
|
||||
tl = utf_ptr2len(p + n);
|
||||
memmove(p + tl, p, (size_t)n);
|
||||
utf_char2bytes(c, (char *)p);
|
||||
utf_char2bytes(c, p);
|
||||
stack[depth].ts_fidxtry = (char_u)(sp->ts_fidx + n + tl);
|
||||
} else {
|
||||
PROF_STORE(sp->ts_state)
|
||||
@@ -2225,12 +2225,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
case STATE_UNROT3R:
|
||||
// Undo ROT3R: "312" -> "123"
|
||||
p = fword + sp->ts_fidx;
|
||||
c = utf_ptr2char((char *)p);
|
||||
tl = utfc_ptr2len((char *)p);
|
||||
n = utfc_ptr2len((char *)p + tl);
|
||||
n += utfc_ptr2len((char *)p + tl + n);
|
||||
c = utf_ptr2char(p);
|
||||
tl = utfc_ptr2len(p);
|
||||
n = utfc_ptr2len(p + tl);
|
||||
n += utfc_ptr2len(p + tl + n);
|
||||
memmove(p, p + tl, (size_t)n);
|
||||
utf_char2bytes(c, (char *)p + n);
|
||||
utf_char2bytes(c, p + n);
|
||||
|
||||
FALLTHROUGH;
|
||||
|
||||
@@ -2251,9 +2251,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
// Use the first byte to quickly find the first entry that may
|
||||
// match. If the index is -1 there is none.
|
||||
if (soundfold) {
|
||||
sp->ts_curi = slang->sl_repsal_first[fword[sp->ts_fidx]];
|
||||
sp->ts_curi = slang->sl_repsal_first[(uint8_t)fword[sp->ts_fidx]];
|
||||
} else {
|
||||
sp->ts_curi = lp->lp_replang->sl_rep_first[fword[sp->ts_fidx]];
|
||||
sp->ts_curi = lp->lp_replang->sl_rep_first[(uint8_t)fword[sp->ts_fidx]];
|
||||
}
|
||||
|
||||
if (sp->ts_curi < 0) {
|
||||
@@ -2284,7 +2284,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
sp->ts_curi = (int16_t)gap->ga_len;
|
||||
break;
|
||||
}
|
||||
if (STRNCMP(ftp->ft_from, p, strlen((char *)ftp->ft_from)) == 0
|
||||
if (strncmp(ftp->ft_from, p, strlen(ftp->ft_from)) == 0
|
||||
&& TRY_DEEPER(su, stack, depth, SCORE_REP)) {
|
||||
go_deeper(stack, depth, SCORE_REP);
|
||||
#ifdef DEBUG_TRIEWALK
|
||||
@@ -2298,8 +2298,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
|
||||
// Change the "from" to the "to" string.
|
||||
depth++;
|
||||
fl = (int)strlen((char *)ftp->ft_from);
|
||||
tl = (int)strlen((char *)ftp->ft_to);
|
||||
fl = (int)strlen(ftp->ft_from);
|
||||
tl = (int)strlen(ftp->ft_to);
|
||||
if (fl != tl) {
|
||||
STRMOVE(p + tl, (char *)p + fl);
|
||||
repextra += tl - fl;
|
||||
@@ -2327,8 +2327,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
||||
gap = &lp->lp_replang->sl_rep;
|
||||
}
|
||||
ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;
|
||||
fl = (int)strlen((char *)ftp->ft_from);
|
||||
tl = (int)strlen((char *)ftp->ft_to);
|
||||
fl = (int)strlen(ftp->ft_from);
|
||||
tl = (int)strlen(ftp->ft_to);
|
||||
p = fword + sp->ts_fidx;
|
||||
if (fl != tl) {
|
||||
STRMOVE(p + fl, (char *)p + tl);
|
||||
@@ -2747,7 +2747,7 @@ static void suggest_try_soundalike(suginfo_T *su)
|
||||
#ifdef SUGGEST_PROFILE
|
||||
prof_init();
|
||||
#endif
|
||||
suggest_trie_walk(su, lp, salword, true);
|
||||
suggest_trie_walk(su, lp, (char *)salword, true);
|
||||
#ifdef SUGGEST_PROFILE
|
||||
prof_report("soundalike");
|
||||
#endif
|
||||
|
@@ -185,7 +185,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
|
||||
length++; // insert backslash
|
||||
}
|
||||
}
|
||||
if (do_special && find_cmdline_var(p, &l) >= 0) {
|
||||
if (do_special && find_cmdline_var((char *)p, &l) >= 0) {
|
||||
length++; // insert backslash
|
||||
p += l - 1;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
|
||||
*d++ = *p++;
|
||||
continue;
|
||||
}
|
||||
if (do_special && find_cmdline_var((char_u *)p, &l) >= 0) {
|
||||
if (do_special && find_cmdline_var(p, &l) >= 0) {
|
||||
*d++ = '\\'; // insert backslash
|
||||
while (--l != SIZE_MAX) { // copy the var
|
||||
*d++ = *p++;
|
||||
|
@@ -201,7 +201,6 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
|
||||
|
||||
#define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) // NOLINT(runtime/printf)
|
||||
#define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n))
|
||||
#define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
|
||||
#ifdef HAVE_STRCASECMP
|
||||
# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
|
||||
#else
|
||||
|
@@ -1825,7 +1825,7 @@ static void parse_quoted_string(ParserState *const pstate, ExprASTNode *const no
|
||||
if (p[1] != '*') {
|
||||
flags |= FSK_SIMPLIFY;
|
||||
}
|
||||
const size_t special_len = trans_special((const char_u **)&p, (size_t)(e - p),
|
||||
const size_t special_len = trans_special(&p, (size_t)(e - p),
|
||||
(char_u *)v_p, flags, false, NULL);
|
||||
if (special_len != 0) {
|
||||
v_p += special_len;
|
||||
|
Reference in New Issue
Block a user