mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: replace char_u with char (#21901)
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
parent
ee87b848a2
commit
4be6c6cf0d
@ -194,8 +194,8 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
snprintf((char *)pattern_buflocal, BUFLOCAL_PAT_LEN, "<buffer=%d>", (int)buf->handle);
|
||||
ADD(buffers, CSTR_TO_OBJ((char *)pattern_buflocal));
|
||||
snprintf(pattern_buflocal, BUFLOCAL_PAT_LEN, "<buffer=%d>", (int)buf->handle);
|
||||
ADD(buffers, CSTR_TO_OBJ(pattern_buflocal));
|
||||
} else if (opts->buffer.type == kObjectTypeArray) {
|
||||
if (opts->buffer.data.array.size > AUCMD_MAX_PATTERNS) {
|
||||
api_set_error(err,
|
||||
@ -215,8 +215,8 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
snprintf((char *)pattern_buflocal, BUFLOCAL_PAT_LEN, "<buffer=%d>", (int)buf->handle);
|
||||
ADD(buffers, CSTR_TO_OBJ((char *)pattern_buflocal));
|
||||
snprintf(pattern_buflocal, BUFLOCAL_PAT_LEN, "<buffer=%d>", (int)buf->handle);
|
||||
ADD(buffers, CSTR_TO_OBJ(pattern_buflocal));
|
||||
});
|
||||
} else if (opts->buffer.type != kObjectTypeNil) {
|
||||
api_set_error(err, kErrorTypeValidation,
|
||||
@ -319,7 +319,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
|
||||
|
||||
PUT(autocmd_info,
|
||||
"pattern",
|
||||
STRING_OBJ(cstr_to_string((char *)ap->pat)));
|
||||
STRING_OBJ(cstr_to_string(ap->pat)));
|
||||
|
||||
PUT(autocmd_info,
|
||||
"event",
|
||||
@ -934,7 +934,7 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
|
||||
char *pat = v->data.string.data;
|
||||
size_t patlen = aucmd_pattern_length(pat);
|
||||
while (patlen) {
|
||||
ADD(*patterns, STRING_OBJ(cbuf_to_string((char *)pat, patlen)));
|
||||
ADD(*patterns, STRING_OBJ(cbuf_to_string(pat, patlen)));
|
||||
|
||||
pat = aucmd_next_pattern(pat, patlen);
|
||||
patlen = aucmd_pattern_length(pat);
|
||||
@ -949,7 +949,7 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
|
||||
char *pat = entry.data.string.data;
|
||||
size_t patlen = aucmd_pattern_length(pat);
|
||||
while (patlen) {
|
||||
ADD(*patterns, STRING_OBJ(cbuf_to_string((char *)pat, patlen)));
|
||||
ADD(*patterns, STRING_OBJ(cbuf_to_string(pat, patlen)));
|
||||
|
||||
pat = aucmd_next_pattern(pat, patlen);
|
||||
patlen = aucmd_pattern_length(pat);
|
||||
@ -975,7 +975,7 @@ static bool get_patterns_from_pattern_or_buf(Array *patterns, Object pattern, Ob
|
||||
}
|
||||
|
||||
snprintf((char *)pattern_buflocal, BUFLOCAL_PAT_LEN, "<buffer=%d>", (int)buf->handle);
|
||||
ADD(*patterns, STRING_OBJ(cstr_to_string((char *)pattern_buflocal)));
|
||||
ADD(*patterns, STRING_OBJ(cstr_to_string(pattern_buflocal)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -127,7 +127,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
|
||||
// otherwise split arguments by whitespace.
|
||||
if (ea.argt & EX_NOSPC) {
|
||||
if (*ea.arg != NUL) {
|
||||
ADD(args, STRING_OBJ(cstrn_to_string((char *)ea.arg, length)));
|
||||
ADD(args, STRING_OBJ(cstrn_to_string(ea.arg, length)));
|
||||
}
|
||||
} else {
|
||||
size_t end = 0;
|
||||
@ -153,9 +153,9 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
|
||||
}
|
||||
|
||||
if (cmd != NULL) {
|
||||
PUT(result, "cmd", CSTR_TO_OBJ((char *)cmd->uc_name));
|
||||
PUT(result, "cmd", CSTR_TO_OBJ(cmd->uc_name));
|
||||
} else {
|
||||
PUT(result, "cmd", CSTR_TO_OBJ((char *)get_command_name(NULL, ea.cmdidx)));
|
||||
PUT(result, "cmd", CSTR_TO_OBJ(get_command_name(NULL, ea.cmdidx)));
|
||||
}
|
||||
|
||||
if (ea.argt & EX_RANGE) {
|
||||
@ -237,7 +237,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
|
||||
break;
|
||||
}
|
||||
PUT(result, "addr", CSTR_TO_OBJ(addr));
|
||||
PUT(result, "nextcmd", CSTR_TO_OBJ((char *)ea.nextcmd));
|
||||
PUT(result, "nextcmd", CSTR_TO_OBJ(ea.nextcmd));
|
||||
|
||||
Dictionary mods = ARRAY_DICT_INIT;
|
||||
|
||||
|
@ -554,7 +554,7 @@ static void find_runtime_cb(char *fname, void *cookie)
|
||||
{
|
||||
Array *rv = (Array *)cookie;
|
||||
if (fname != NULL) {
|
||||
ADD(*rv, STRING_OBJ(cstr_to_string((char *)fname)));
|
||||
ADD(*rv, STRING_OBJ(cstr_to_string(fname)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2266,7 +2266,7 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error *
|
||||
for (stl_hlrec_t *sp = hltab; sp->start != NULL; sp++) {
|
||||
Dictionary hl_info = ARRAY_DICT_INIT;
|
||||
|
||||
PUT(hl_info, "start", INTEGER_OBJ((char *)sp->start - buf));
|
||||
PUT(hl_info, "start", INTEGER_OBJ(sp->start - buf));
|
||||
|
||||
if (sp->userhl == 0) {
|
||||
grpname = get_default_stl_hl(wp, use_winbar);
|
||||
@ -2281,7 +2281,7 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error *
|
||||
}
|
||||
PUT(result, "highlights", ARRAY_OBJ(hl_values));
|
||||
}
|
||||
PUT(result, "str", CSTR_TO_OBJ((char *)buf));
|
||||
PUT(result, "str", CSTR_TO_OBJ(buf));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ static void aupat_show(AutoPat *ap, event_T event, int previous_group)
|
||||
char *exec_to_string = aucmd_exec_to_string(ac, ac->exec);
|
||||
if (ac->desc != NULL) {
|
||||
size_t msglen = 100;
|
||||
char *msg = (char *)xmallocz(msglen);
|
||||
char *msg = xmallocz(msglen);
|
||||
if (ac->exec.type == CALLABLE_CB) {
|
||||
msg_puts_attr(exec_to_string, HL_ATTR(HLF_8));
|
||||
snprintf(msg, msglen, " [%s]", ac->desc);
|
||||
@ -286,7 +286,7 @@ static void au_show_for_event(int group, event_T event, char *pat)
|
||||
if (aupat_is_buflocal(pat, patlen)) {
|
||||
// normalize pat into standard "<buffer>#N" form
|
||||
aupat_normalize_buflocal_pat(buflocal_pat, pat, patlen, aupat_get_buflocal_nr(pat, patlen));
|
||||
pat = (char *)buflocal_pat;
|
||||
pat = buflocal_pat;
|
||||
patlen = (int)strlen(buflocal_pat);
|
||||
}
|
||||
|
||||
@ -2119,8 +2119,8 @@ static bool call_autocmd_callback(const AutoCmd *ac, const AutoPatCmd *apc)
|
||||
Dictionary data = ARRAY_DICT_INIT;
|
||||
PUT(data, "id", INTEGER_OBJ(ac->id));
|
||||
PUT(data, "event", CSTR_TO_OBJ(event_nr2name(apc->event)));
|
||||
PUT(data, "match", CSTR_TO_OBJ((char *)autocmd_match));
|
||||
PUT(data, "file", CSTR_TO_OBJ((char *)autocmd_fname));
|
||||
PUT(data, "match", CSTR_TO_OBJ(autocmd_match));
|
||||
PUT(data, "file", CSTR_TO_OBJ(autocmd_fname));
|
||||
PUT(data, "buf", INTEGER_OBJ(autocmd_bufnr));
|
||||
|
||||
if (apc->data) {
|
||||
|
@ -2000,8 +2000,8 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa
|
||||
case CMD_snoremap:
|
||||
case CMD_xmap:
|
||||
case CMD_xnoremap:
|
||||
return (const char *)set_context_in_map_cmd(xp, (char *)cmd, (char *)arg, forceit, false,
|
||||
false, cmdidx);
|
||||
return set_context_in_map_cmd(xp, (char *)cmd, (char *)arg, forceit, false,
|
||||
false, cmdidx);
|
||||
case CMD_unmap:
|
||||
case CMD_nunmap:
|
||||
case CMD_vunmap:
|
||||
@ -2011,8 +2011,8 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa
|
||||
case CMD_lunmap:
|
||||
case CMD_sunmap:
|
||||
case CMD_xunmap:
|
||||
return (const char *)set_context_in_map_cmd(xp, (char *)cmd, (char *)arg, forceit, false,
|
||||
true, cmdidx);
|
||||
return set_context_in_map_cmd(xp, (char *)cmd, (char *)arg, forceit, false,
|
||||
true, cmdidx);
|
||||
case CMD_mapclear:
|
||||
case CMD_nmapclear:
|
||||
case CMD_vmapclear:
|
||||
@ -2032,13 +2032,13 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, expa
|
||||
case CMD_cnoreabbrev:
|
||||
case CMD_iabbrev:
|
||||
case CMD_inoreabbrev:
|
||||
return (const char *)set_context_in_map_cmd(xp, (char *)cmd, (char *)arg, forceit, true,
|
||||
false, cmdidx);
|
||||
return set_context_in_map_cmd(xp, (char *)cmd, (char *)arg, forceit, true,
|
||||
false, cmdidx);
|
||||
case CMD_unabbreviate:
|
||||
case CMD_cunabbrev:
|
||||
case CMD_iunabbrev:
|
||||
return (const char *)set_context_in_map_cmd(xp, (char *)cmd, (char *)arg, forceit, true,
|
||||
true, cmdidx);
|
||||
return set_context_in_map_cmd(xp, (char *)cmd, (char *)arg, forceit, true,
|
||||
true, cmdidx);
|
||||
case CMD_menu:
|
||||
case CMD_noremenu:
|
||||
case CMD_unmenu:
|
||||
@ -3238,7 +3238,7 @@ void globpath(char *path, char *file, garray_T *ga, int expand_options, bool dir
|
||||
ga_grow(ga, num_p);
|
||||
// take over the pointers and put them in "ga"
|
||||
for (int i = 0; i < num_p; i++) {
|
||||
((char_u **)ga->ga_data)[ga->ga_len] = (char_u *)p[i];
|
||||
((char **)ga->ga_data)[ga->ga_len] = p[i];
|
||||
ga->ga_len++;
|
||||
}
|
||||
xfree(p);
|
||||
|
@ -494,10 +494,10 @@ int gchar_cursor(void)
|
||||
|
||||
/// Write a character at the current cursor position.
|
||||
/// It is directly written into the block.
|
||||
void pchar_cursor(char_u c)
|
||||
void pchar_cursor(char c)
|
||||
{
|
||||
*(ml_get_buf(curbuf, curwin->w_cursor.lnum, true)
|
||||
+ curwin->w_cursor.col) = (char)c;
|
||||
+ curwin->w_cursor.col) = c;
|
||||
}
|
||||
|
||||
/// @return pointer to cursor line.
|
||||
|
@ -727,7 +727,7 @@ void ex_breaklist(exarg_T *eap)
|
||||
for (int i = 0; i < dbg_breakp.ga_len; i++) {
|
||||
struct debuggy *bp = &BREAKP(i);
|
||||
if (bp->dbg_type == DBG_FILE) {
|
||||
home_replace(NULL, bp->dbg_name, (char *)NameBuff, MAXPATHL, true);
|
||||
home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, true);
|
||||
}
|
||||
if (bp->dbg_type != DBG_EXPR) {
|
||||
smsg(_("%3d %s %s line %" PRId64),
|
||||
|
@ -1401,7 +1401,7 @@ static int pc_status;
|
||||
#define PC_STATUS_RIGHT 1 // right half of double-wide char
|
||||
#define PC_STATUS_LEFT 2 // left half of double-wide char
|
||||
#define PC_STATUS_SET 3 // pc_bytes was filled
|
||||
static char_u pc_bytes[MB_MAXBYTES + 1]; // saved bytes
|
||||
static char pc_bytes[MB_MAXBYTES + 1]; // saved bytes
|
||||
static int pc_attr;
|
||||
static int pc_row;
|
||||
static int pc_col;
|
||||
@ -1438,7 +1438,7 @@ void edit_putchar(int c, bool highlight)
|
||||
|
||||
// save the character to be able to put it back
|
||||
if (pc_status == PC_STATUS_UNSET) {
|
||||
grid_getbytes(&curwin->w_grid, pc_row, pc_col, (char *)pc_bytes, &pc_attr);
|
||||
grid_getbytes(&curwin->w_grid, pc_row, pc_col, pc_bytes, &pc_attr);
|
||||
pc_status = PC_STATUS_SET;
|
||||
}
|
||||
grid_putchar(&curwin->w_grid, c, pc_row, pc_col, attr);
|
||||
@ -1521,7 +1521,7 @@ void edit_unputchar(void)
|
||||
if (pc_status == PC_STATUS_RIGHT || pc_status == PC_STATUS_LEFT) {
|
||||
redrawWinline(curwin, curwin->w_cursor.lnum);
|
||||
} else {
|
||||
grid_puts(&curwin->w_grid, (char *)pc_bytes, pc_row - msg_scrolled, pc_col, pc_attr);
|
||||
grid_puts(&curwin->w_grid, pc_bytes, pc_row - msg_scrolled, pc_col, pc_attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2051,7 +2051,7 @@ void insertchar(int c, int flags, int second_indent)
|
||||
|
||||
// Check whether this character should end a comment.
|
||||
if (did_ai && c == end_comment_pending) {
|
||||
char_u lead_end[COM_MAX_LEN]; // end-comment string
|
||||
char lead_end[COM_MAX_LEN]; // end-comment string
|
||||
|
||||
// Need to remove existing (middle) comment leader and insert end
|
||||
// comment leader. First, check what comment leader we can find.
|
||||
@ -2062,7 +2062,7 @@ void insertchar(int c, int flags, int second_indent)
|
||||
while (*p && p[-1] != ':') { // find end of middle flags
|
||||
p++;
|
||||
}
|
||||
int middle_len = (int)copy_option_part(&p, (char *)lead_end, COM_MAX_LEN, ",");
|
||||
int middle_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
|
||||
// Don't count trailing white space for middle_len
|
||||
while (middle_len > 0 && ascii_iswhite(lead_end[middle_len - 1])) {
|
||||
middle_len--;
|
||||
@ -2072,7 +2072,7 @@ void insertchar(int c, int flags, int second_indent)
|
||||
while (*p && p[-1] != ':') { // find end of end flags
|
||||
p++;
|
||||
}
|
||||
int end_len = (int)copy_option_part(&p, (char *)lead_end, COM_MAX_LEN, ",");
|
||||
int end_len = (int)copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
|
||||
|
||||
// Skip white space before the cursor
|
||||
i = curwin->w_cursor.col;
|
||||
@ -2083,13 +2083,13 @@ void insertchar(int c, int flags, int second_indent)
|
||||
i -= middle_len;
|
||||
|
||||
// Check some expected things before we go on
|
||||
if (i >= 0 && lead_end[end_len - 1] == end_comment_pending) {
|
||||
if (i >= 0 && (uint8_t)lead_end[end_len - 1] == end_comment_pending) {
|
||||
// Backspace over all the stuff we want to replace
|
||||
backspace_until_column(i);
|
||||
|
||||
// Insert the end-comment string, except for the last
|
||||
// character, which will get inserted as normal later.
|
||||
ins_bytes_len((char *)lead_end, (size_t)(end_len - 1));
|
||||
ins_bytes_len(lead_end, (size_t)(end_len - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2416,7 +2416,7 @@ void set_last_insert(int c)
|
||||
if (c < ' ' || c == DEL) {
|
||||
*s++ = Ctrl_V;
|
||||
}
|
||||
s = (char *)add_char2buf(c, (char_u *)s);
|
||||
s = add_char2buf(c, s);
|
||||
*s++ = ESC;
|
||||
*s++ = NUL;
|
||||
last_insert_skip = 0;
|
||||
@ -2443,9 +2443,9 @@ void beginline(int flags)
|
||||
curwin->w_cursor.coladd = 0;
|
||||
|
||||
if (flags & (BL_WHITE | BL_SOL)) {
|
||||
char_u *ptr;
|
||||
char *ptr;
|
||||
|
||||
for (ptr = (char_u *)get_cursor_line_ptr(); ascii_iswhite(*ptr)
|
||||
for (ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr)
|
||||
&& !((flags & BL_FIX) && ptr[1] == NUL); ptr++) {
|
||||
curwin->w_cursor.col++;
|
||||
}
|
||||
@ -2676,7 +2676,7 @@ int stuff_inserted(int c, long count, int no_esc)
|
||||
char *last_ptr;
|
||||
char last = NUL;
|
||||
|
||||
ptr = (char *)get_last_insert();
|
||||
ptr = get_last_insert();
|
||||
if (ptr == NULL) {
|
||||
emsg(_(e_noinstext));
|
||||
return FAIL;
|
||||
@ -2725,13 +2725,13 @@ int stuff_inserted(int c, long count, int no_esc)
|
||||
return OK;
|
||||
}
|
||||
|
||||
char_u *get_last_insert(void)
|
||||
char *get_last_insert(void)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
if (last_insert == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return (char_u *)last_insert + last_insert_skip;
|
||||
return last_insert + last_insert_skip;
|
||||
}
|
||||
|
||||
// Get last inserted string, and remove trailing <Esc>.
|
||||
@ -4581,7 +4581,7 @@ static bool ins_tab(void)
|
||||
// Delete following spaces.
|
||||
i = cursor->col - fpos.col;
|
||||
if (i > 0) {
|
||||
STRMOVE(ptr, (char *)ptr + i);
|
||||
STRMOVE(ptr, ptr + i);
|
||||
// correct replace stack.
|
||||
if ((State & REPLACE_FLAG)
|
||||
&& !(State & VREPLACE_FLAG)) {
|
||||
|
@ -3915,7 +3915,7 @@ char *partial_name(partial_T *pt)
|
||||
if (pt->pt_name != NULL) {
|
||||
return pt->pt_name;
|
||||
}
|
||||
return (char *)pt->pt_func->uf_name;
|
||||
return pt->pt_func->uf_name;
|
||||
}
|
||||
|
||||
static void partial_free(partial_T *pt)
|
||||
@ -5052,7 +5052,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref)
|
||||
if (tv_list_len(list) == 0) {
|
||||
arg_idx = 0;
|
||||
} else if (tv_list_len(list) > MAX_FUNC_ARGS) {
|
||||
emsg_funcname((char *)e_toomanyarg, s);
|
||||
emsg_funcname(e_toomanyarg, s);
|
||||
xfree(name);
|
||||
goto theend;
|
||||
}
|
||||
|
@ -8769,7 +8769,7 @@ static void f_tr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
tolen = utfc_ptr2len(p);
|
||||
if (idx-- == 0) {
|
||||
cplen = tolen;
|
||||
cpstr = (char *)p;
|
||||
cpstr = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -751,8 +751,8 @@ int tv_list_concat(list_T *const l1, list_T *const l2, typval_T *const tv)
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char_u *s;
|
||||
char_u *tofree;
|
||||
char *s;
|
||||
char *tofree;
|
||||
} Join;
|
||||
|
||||
/// Join list into a string, helper function
|
||||
@ -785,7 +785,7 @@ static int list_join_inner(garray_T *const gap, list_T *const l, const char *con
|
||||
sumlen += len;
|
||||
|
||||
Join *const p = GA_APPEND_VIA_PTR(Join, join_gap);
|
||||
p->tofree = p->s = (char_u *)s;
|
||||
p->tofree = p->s = s;
|
||||
|
||||
line_breakcheck();
|
||||
});
|
||||
@ -806,7 +806,7 @@ static int list_join_inner(garray_T *const gap, list_T *const l, const char *con
|
||||
const Join *const p = ((const Join *)join_gap->ga_data) + i;
|
||||
|
||||
if (p->s != NULL) {
|
||||
ga_concat(gap, (char *)p->s);
|
||||
ga_concat(gap, p->s);
|
||||
}
|
||||
line_breakcheck();
|
||||
}
|
||||
@ -1673,7 +1673,7 @@ char *callback_to_string(Callback *cb)
|
||||
}
|
||||
|
||||
const size_t msglen = 100;
|
||||
char *msg = (char *)xmallocz(msglen);
|
||||
char *msg = xmallocz(msglen);
|
||||
|
||||
switch (cb->type) {
|
||||
case kCallbackFuncref:
|
||||
|
@ -880,7 +880,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
|
||||
fc->rettv = rettv;
|
||||
fc->level = ex_nesting_level;
|
||||
// Check if this function has a breakpoint.
|
||||
fc->breakpoint = dbg_find_breakpoint(false, (char *)fp->uf_name, (linenr_T)0);
|
||||
fc->breakpoint = dbg_find_breakpoint(false, fp->uf_name, (linenr_T)0);
|
||||
fc->dbg_tick = debug_tick;
|
||||
|
||||
// Set up fields for closure.
|
||||
@ -1075,7 +1075,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
|
||||
|
||||
bool func_not_yet_profiling_but_should =
|
||||
do_profiling_yes
|
||||
&& !fp->uf_profiling && has_profiling(false, (char *)fp->uf_name, NULL);
|
||||
&& !fp->uf_profiling && has_profiling(false, fp->uf_name, NULL);
|
||||
|
||||
if (func_not_yet_profiling_but_should) {
|
||||
started_profiling = true;
|
||||
@ -1669,7 +1669,7 @@ static void list_func_head(ufunc_T *fp, int indent, bool force)
|
||||
if (fp->uf_name_exp != NULL) {
|
||||
msg_puts((const char *)fp->uf_name_exp);
|
||||
} else {
|
||||
msg_puts((const char *)fp->uf_name);
|
||||
msg_puts(fp->uf_name);
|
||||
}
|
||||
msg_putchar('(');
|
||||
int j;
|
||||
@ -1999,10 +1999,10 @@ static void list_functions(regmatch_T *regmatch)
|
||||
todo--;
|
||||
if ((fp->uf_flags & FC_DEAD) == 0
|
||||
&& (regmatch == NULL
|
||||
? (!message_filtered((char *)fp->uf_name)
|
||||
? (!message_filtered(fp->uf_name)
|
||||
&& !func_name_refcount(fp->uf_name))
|
||||
: (!isdigit((uint8_t)(*fp->uf_name))
|
||||
&& vim_regexec(regmatch, (char *)fp->uf_name, 0)))) {
|
||||
&& vim_regexec(regmatch, fp->uf_name, 0)))) {
|
||||
list_func_head(fp, false, false);
|
||||
if (changed != func_hashtab.ht_changed) {
|
||||
emsg(_("E454: function list was modified"));
|
||||
@ -2194,7 +2194,7 @@ void ex_function(exarg_T *eap)
|
||||
j++;
|
||||
}
|
||||
if (arg[j] != NUL) {
|
||||
emsg_funcname((char *)e_invarg2, arg);
|
||||
emsg_funcname(e_invarg2, arg);
|
||||
}
|
||||
}
|
||||
// Disallow using the g: dict.
|
||||
@ -2748,7 +2748,7 @@ char *get_user_func_name(expand_T *xp, int idx)
|
||||
}
|
||||
|
||||
if (strlen(fp->uf_name) + 4 >= IOSIZE) {
|
||||
return (char *)fp->uf_name; // Prevent overflow.
|
||||
return fp->uf_name; // Prevent overflow.
|
||||
}
|
||||
|
||||
cat_func_name(IObuff, fp);
|
||||
@ -3228,7 +3228,7 @@ char *get_func_line(int c, void *cookie, int indent, bool do_concat)
|
||||
|
||||
// If breakpoints have been added/deleted need to check for it.
|
||||
if (fcp->dbg_tick != debug_tick) {
|
||||
fcp->breakpoint = dbg_find_breakpoint(false, (char *)fp->uf_name, SOURCING_LNUM);
|
||||
fcp->breakpoint = dbg_find_breakpoint(false, fp->uf_name, SOURCING_LNUM);
|
||||
fcp->dbg_tick = debug_tick;
|
||||
}
|
||||
if (do_profiling == PROF_YES) {
|
||||
@ -3258,9 +3258,9 @@ char *get_func_line(int c, void *cookie, int indent, bool do_concat)
|
||||
|
||||
// Did we encounter a breakpoint?
|
||||
if (fcp->breakpoint != 0 && fcp->breakpoint <= SOURCING_LNUM) {
|
||||
dbg_breakpoint((char *)fp->uf_name, SOURCING_LNUM);
|
||||
dbg_breakpoint(fp->uf_name, SOURCING_LNUM);
|
||||
// Find next breakpoint.
|
||||
fcp->breakpoint = dbg_find_breakpoint(false, (char *)fp->uf_name, SOURCING_LNUM);
|
||||
fcp->breakpoint = dbg_find_breakpoint(false, fp->uf_name, SOURCING_LNUM);
|
||||
fcp->dbg_tick = debug_tick;
|
||||
}
|
||||
|
||||
|
@ -1818,7 +1818,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
|
||||
if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
|
||||
char buff[DIALOG_MSG_SIZE];
|
||||
|
||||
dialog_msg((char *)buff, _("Overwrite existing file \"%s\"?"), fname);
|
||||
dialog_msg(buff, _("Overwrite existing file \"%s\"?"), fname);
|
||||
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) {
|
||||
return FAIL;
|
||||
}
|
||||
@ -1854,7 +1854,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
|
||||
if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
|
||||
char buff[DIALOG_MSG_SIZE];
|
||||
|
||||
dialog_msg((char *)buff,
|
||||
dialog_msg(buff,
|
||||
_("Swap file \"%s\" exists, overwrite anyway?"),
|
||||
swapname);
|
||||
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2)
|
||||
@ -1974,11 +1974,11 @@ static int check_readonly(int *forceit, buf_T *buf)
|
||||
char buff[DIALOG_MSG_SIZE];
|
||||
|
||||
if (buf->b_p_ro) {
|
||||
dialog_msg((char *)buff,
|
||||
dialog_msg(buff,
|
||||
_("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
|
||||
buf->b_fname);
|
||||
} else {
|
||||
dialog_msg((char *)buff,
|
||||
dialog_msg(buff,
|
||||
_("File permissions of \"%s\" are read-only.\nIt may still be possible to "
|
||||
"write it.\nDo you wish to try?"),
|
||||
buf->b_fname);
|
||||
|
@ -3200,7 +3200,7 @@ char *skip_range(const char *cmd, int *ctx)
|
||||
}
|
||||
|
||||
// Skip ":" and white space.
|
||||
cmd = skip_colon_white((char *)cmd, false);
|
||||
cmd = skip_colon_white(cmd, false);
|
||||
|
||||
return (char *)cmd;
|
||||
}
|
||||
@ -4011,7 +4011,7 @@ static char *getargcmd(char **argp)
|
||||
if (*arg == '+') { // +[command]
|
||||
arg++;
|
||||
if (ascii_isspace(*arg) || *arg == '\0') {
|
||||
command = (char *)dollar_command;
|
||||
command = dollar_command;
|
||||
} else {
|
||||
command = arg;
|
||||
arg = skip_cmd_arg(command, true);
|
||||
@ -4401,7 +4401,7 @@ static int check_more(int message, bool forceit)
|
||||
if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && curbuf->b_fname != NULL) {
|
||||
char buff[DIALOG_MSG_SIZE];
|
||||
|
||||
vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
|
||||
vim_snprintf(buff, DIALOG_MSG_SIZE,
|
||||
NGETTEXT("%d more file to edit. Quit anyway?",
|
||||
"%d more files to edit. Quit anyway?", n), n);
|
||||
if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) {
|
||||
@ -4769,7 +4769,7 @@ void tabpage_close_other(tabpage_T *tp, int forceit)
|
||||
// Limit to 1000 windows, autocommands may add a window while we close
|
||||
// one. OK, so I'm paranoid...
|
||||
while (++done < 1000) {
|
||||
snprintf((char *)prev_idx, sizeof(prev_idx), "%i", tabpage_index(tp));
|
||||
snprintf(prev_idx, sizeof(prev_idx), "%i", tabpage_index(tp));
|
||||
win_T *wp = tp->tp_lastwin;
|
||||
ex_win_close(forceit, wp, tp);
|
||||
|
||||
@ -6748,7 +6748,7 @@ char *eval_vars(char *src, const char *srcstart, size_t *usedlen, linenr_T *lnum
|
||||
// Note: In "\\%" the % is also not recognized!
|
||||
if (src > srcstart && src[-1] == '\\') {
|
||||
*usedlen = 0;
|
||||
STRMOVE(src - 1, (char *)src); // remove backslash
|
||||
STRMOVE(src - 1, src); // remove backslash
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -6925,7 +6925,7 @@ char *eval_vars(char *src, const char *srcstart, size_t *usedlen, linenr_T *lnum
|
||||
*errormsg = _("E961: no line number to use for \"<sflnum>\"");
|
||||
return NULL;
|
||||
}
|
||||
snprintf((char *)strbuf, sizeof(strbuf), "%" PRIdLINENR,
|
||||
snprintf(strbuf, sizeof(strbuf), "%" PRIdLINENR,
|
||||
current_sctx.sc_lnum + SOURCING_LNUM);
|
||||
result = strbuf;
|
||||
break;
|
||||
|
@ -3380,14 +3380,14 @@ static void ui_ext_cmdline_show(CmdlineInfo *line)
|
||||
ADD_C(item, INTEGER_OBJ(chunk.attr));
|
||||
|
||||
assert(chunk.end >= chunk.start);
|
||||
ADD_C(item, STRING_OBJ(cbuf_as_string((char *)line->cmdbuff + chunk.start,
|
||||
ADD_C(item, STRING_OBJ(cbuf_as_string(line->cmdbuff + chunk.start,
|
||||
(size_t)(chunk.end - chunk.start))));
|
||||
ADD_C(content, ARRAY_OBJ(item));
|
||||
}
|
||||
} else {
|
||||
Array item = arena_array(&arena, 2);
|
||||
ADD_C(item, INTEGER_OBJ(0));
|
||||
ADD_C(item, STRING_OBJ(cstr_as_string((char *)(line->cmdbuff))));
|
||||
ADD_C(item, STRING_OBJ(cstr_as_string(line->cmdbuff)));
|
||||
content = arena_array(&arena, 1);
|
||||
ADD_C(content, ARRAY_OBJ(item));
|
||||
}
|
||||
|
@ -18,8 +18,6 @@
|
||||
#define READ_NOWINENTER 0x80 // do not trigger BufWinEnter
|
||||
#define READ_NOFILE 0x100 // do not read a file, do trigger BufReadCmd
|
||||
|
||||
#define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
|
||||
|
||||
typedef varnumber_T (*CheckItem)(void *expr, const char *name);
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
|
@ -179,7 +179,7 @@ static char *get_buffcont(buffheader_T *buffer, int dozero)
|
||||
/// Return the contents of the record buffer as a single string
|
||||
/// and clear the record buffer.
|
||||
/// K_SPECIAL in the returned string is escaped.
|
||||
char_u *get_recorded(void)
|
||||
char *get_recorded(void)
|
||||
{
|
||||
char *p;
|
||||
size_t len;
|
||||
@ -201,7 +201,7 @@ char_u *get_recorded(void)
|
||||
p[len - 1] = NUL;
|
||||
}
|
||||
|
||||
return (char_u *)p;
|
||||
return p;
|
||||
}
|
||||
|
||||
/// Return the contents of the redo buffer as a single string.
|
||||
@ -978,7 +978,7 @@ int ins_typebuf(char *str, int noremap, int offset, bool nottyped, bool silent)
|
||||
int ins_char_typebuf(int c, int modifiers)
|
||||
{
|
||||
char_u buf[MB_MAXBYTES * 3 + 4];
|
||||
unsigned int len = special_to_buf(c, modifiers, true, buf);
|
||||
unsigned int len = special_to_buf(c, modifiers, true, (char *)buf);
|
||||
assert(len < sizeof(buf));
|
||||
buf[len] = NUL;
|
||||
(void)ins_typebuf((char *)buf, KeyNoremap, 0, !KeyTyped, cmd_silent);
|
||||
@ -2197,7 +2197,7 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
|
||||
// mode temporarily. Append K_SELECT to switch back to Select mode.
|
||||
if (VIsual_active && VIsual_select && (mp->m_mode & MODE_VISUAL)) {
|
||||
VIsual_select = false;
|
||||
(void)ins_typebuf((char *)K_SELECT_STRING, REMAP_NONE, 0, true, false);
|
||||
(void)ins_typebuf(K_SELECT_STRING, REMAP_NONE, 0, true, false);
|
||||
}
|
||||
|
||||
// Copy the values from *mp that are used, because evaluating the
|
||||
@ -2887,13 +2887,13 @@ int inchar(char_u *buf, int maxlen, long wait_time)
|
||||
typebuf.tb_change_cnt = 1;
|
||||
}
|
||||
|
||||
return fix_input_buffer(buf, len);
|
||||
return fix_input_buffer((char *)buf, len);
|
||||
}
|
||||
|
||||
// Fix typed characters for use by vgetc() and check_termcode().
|
||||
// "buf[]" must have room to triple the number of bytes!
|
||||
// Returns the new length.
|
||||
int fix_input_buffer(char_u *buf, int len)
|
||||
int fix_input_buffer(char *buf, int len)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (!using_script()) {
|
||||
@ -2905,7 +2905,7 @@ int fix_input_buffer(char_u *buf, int len)
|
||||
|
||||
// Reading from script, need to process special bytes
|
||||
int i;
|
||||
char_u *p = buf;
|
||||
char_u *p = (char_u *)buf;
|
||||
|
||||
// Two characters are special: NUL and K_SPECIAL.
|
||||
// Replace NUL by K_SPECIAL KS_ZERO KE_FILLER
|
||||
|
@ -457,8 +457,8 @@ hash_T hash_hash_len(const char *key, const size_t len)
|
||||
///
|
||||
/// Used for testing because luajit ffi does not allow getting addresses of
|
||||
/// globals.
|
||||
const char_u *_hash_key_removed(void)
|
||||
const char *_hash_key_removed(void)
|
||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
return (char_u *)HI_KEY_REMOVED;
|
||||
return HI_KEY_REMOVED;
|
||||
}
|
||||
|
@ -1089,7 +1089,7 @@ static void do_helptags(char *dirname, bool add_help_tags, bool ignore_writeerr)
|
||||
|
||||
// Get a list of all files in the help directory and in subdirectories.
|
||||
xstrlcpy(NameBuff, dirname, sizeof(NameBuff));
|
||||
if (!add_pathsep((char *)NameBuff)
|
||||
if (!add_pathsep(NameBuff)
|
||||
|| xstrlcat(NameBuff, "**", sizeof(NameBuff)) >= MAXPATHL) {
|
||||
emsg(_(e_fnametoolong));
|
||||
return;
|
||||
|
@ -205,7 +205,7 @@ int ns_get_hl(NS *ns_hl, int hl_id, bool link, bool nodefault)
|
||||
if (!valid_item && p->hl_def != LUA_NOREF && !recursive) {
|
||||
MAXSIZE_TEMP_ARRAY(args, 3);
|
||||
ADD_C(args, INTEGER_OBJ((Integer)ns_id));
|
||||
ADD_C(args, STRING_OBJ(cstr_to_string((char *)syn_id2name(hl_id))));
|
||||
ADD_C(args, STRING_OBJ(cstr_to_string(syn_id2name(hl_id))));
|
||||
ADD_C(args, BOOLEAN_OBJ(link));
|
||||
// TODO(bfredl): preload the "global" attr dict?
|
||||
|
||||
@ -1115,7 +1115,7 @@ static void hl_inspect_impl(Array *arr, int attr)
|
||||
case kHlSyntax:
|
||||
PUT(item, "kind", STRING_OBJ(cstr_to_string("syntax")));
|
||||
PUT(item, "hi_name",
|
||||
STRING_OBJ(cstr_to_string((char *)syn_id2name(e.id1))));
|
||||
STRING_OBJ(cstr_to_string(syn_id2name(e.id1))));
|
||||
break;
|
||||
|
||||
case kHlUI:
|
||||
@ -1123,7 +1123,7 @@ static void hl_inspect_impl(Array *arr, int attr)
|
||||
const char *ui_name = (e.id1 == -1) ? "Normal" : hlf_names[e.id1];
|
||||
PUT(item, "ui_name", STRING_OBJ(cstr_to_string(ui_name)));
|
||||
PUT(item, "hi_name",
|
||||
STRING_OBJ(cstr_to_string((char *)syn_id2name(e.id2))));
|
||||
STRING_OBJ(cstr_to_string(syn_id2name(e.id2))));
|
||||
break;
|
||||
|
||||
case kHlTerminal:
|
||||
|
@ -1522,7 +1522,7 @@ Dictionary get_global_hl_defs(Arena *arena)
|
||||
char *link = hl_table[h->sg_link - 1].sg_name;
|
||||
PUT_C(attrs, "link", STRING_OBJ(cstr_as_string(link)));
|
||||
}
|
||||
PUT_C(rv, (char *)h->sg_name, DICTIONARY_OBJ(attrs));
|
||||
PUT_C(rv, h->sg_name, DICTIONARY_OBJ(attrs));
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -1547,7 +1547,7 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg
|
||||
char buf[100];
|
||||
const char *ts = buf;
|
||||
if (type == LIST_INT) {
|
||||
snprintf((char *)buf, sizeof(buf), "%d", iarg - 1);
|
||||
snprintf(buf, sizeof(buf), "%d", iarg - 1);
|
||||
} else if (type == LIST_STRING) {
|
||||
ts = sarg;
|
||||
} else { // type == LIST_ATTR
|
||||
|
@ -86,7 +86,7 @@ int ask_yesno(const char *const str, const bool direct)
|
||||
/// Translates the interrupt character for unix to ESC.
|
||||
int get_keystroke(MultiQueue *events)
|
||||
{
|
||||
char_u *buf = NULL;
|
||||
char *buf = NULL;
|
||||
int buflen = 150;
|
||||
int maxlen;
|
||||
int len = 0;
|
||||
@ -113,7 +113,7 @@ int get_keystroke(MultiQueue *events)
|
||||
|
||||
// First time: blocking wait. Second time: wait up to 100ms for a
|
||||
// terminal code to complete.
|
||||
n = os_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0, events);
|
||||
n = os_inchar((uint8_t *)buf + len, maxlen, len == 0 ? -1L : 100L, 0, events);
|
||||
if (n > 0) {
|
||||
// Replace zero and K_SPECIAL by a special key code.
|
||||
n = fix_input_buffer(buf + len, n);
|
||||
@ -128,14 +128,14 @@ int get_keystroke(MultiQueue *events)
|
||||
}
|
||||
|
||||
// Handle modifier and/or special key code.
|
||||
n = buf[0];
|
||||
n = (uint8_t)buf[0];
|
||||
if (n == K_SPECIAL) {
|
||||
n = TO_SPECIAL(buf[1], buf[2]);
|
||||
if (buf[1] == KS_MODIFIER
|
||||
n = TO_SPECIAL((uint8_t)buf[1], (uint8_t)buf[2]);
|
||||
if ((uint8_t)buf[1] == KS_MODIFIER
|
||||
|| n == K_IGNORE
|
||||
|| (is_mouse_key(n) && n != K_LEFTMOUSE)) {
|
||||
if (buf[1] == KS_MODIFIER) {
|
||||
mod_mask = buf[2];
|
||||
if ((uint8_t)buf[1] == KS_MODIFIER) {
|
||||
mod_mask = (uint8_t)buf[2];
|
||||
}
|
||||
len -= 3;
|
||||
if (len > 0) {
|
||||
@ -150,7 +150,7 @@ int get_keystroke(MultiQueue *events)
|
||||
continue;
|
||||
}
|
||||
buf[len >= buflen ? buflen - 1 : len] = NUL;
|
||||
n = utf_ptr2char((char *)buf);
|
||||
n = utf_ptr2char(buf);
|
||||
break;
|
||||
}
|
||||
xfree(buf);
|
||||
|
@ -582,7 +582,7 @@ unsigned int trans_special(const char **const srcp, const size_t src_len, char *
|
||||
return 0;
|
||||
}
|
||||
|
||||
return special_to_buf(key, modifiers, escape_ks, (char_u *)dst);
|
||||
return special_to_buf(key, modifiers, escape_ks, dst);
|
||||
}
|
||||
|
||||
/// Put the character sequence for "key" with "modifiers" into "dst" and return
|
||||
@ -590,27 +590,27 @@ unsigned int trans_special(const char **const srcp, const size_t src_len, char *
|
||||
/// When "escape_ks" is true escape K_SPECIAL bytes in the character.
|
||||
/// The sequence is not NUL terminated.
|
||||
/// This is how characters in a string are encoded.
|
||||
unsigned int special_to_buf(int key, int modifiers, bool escape_ks, char_u *dst)
|
||||
unsigned int special_to_buf(int key, int modifiers, bool escape_ks, char *dst)
|
||||
{
|
||||
unsigned int dlen = 0;
|
||||
|
||||
// Put the appropriate modifier in a string.
|
||||
if (modifiers != 0) {
|
||||
dst[dlen++] = K_SPECIAL;
|
||||
dst[dlen++] = KS_MODIFIER;
|
||||
dst[dlen++] = (char_u)modifiers;
|
||||
dst[dlen++] = (char)(uint8_t)K_SPECIAL;
|
||||
dst[dlen++] = (char)(uint8_t)KS_MODIFIER;
|
||||
dst[dlen++] = (char)(uint8_t)modifiers;
|
||||
}
|
||||
|
||||
if (IS_SPECIAL(key)) {
|
||||
dst[dlen++] = K_SPECIAL;
|
||||
dst[dlen++] = (char_u)KEY2TERMCAP0(key);
|
||||
dst[dlen++] = KEY2TERMCAP1(key);
|
||||
dst[dlen++] = (char)(uint8_t)K_SPECIAL;
|
||||
dst[dlen++] = (char)(uint8_t)KEY2TERMCAP0(key);
|
||||
dst[dlen++] = (char)(uint8_t)KEY2TERMCAP1(key);
|
||||
} else if (escape_ks) {
|
||||
char_u *after = add_char2buf(key, dst + dlen);
|
||||
char *after = add_char2buf(key, dst + dlen);
|
||||
assert(after >= dst && (uintmax_t)(after - dst) <= UINT_MAX);
|
||||
dlen = (unsigned int)(after - dst);
|
||||
} else {
|
||||
dlen += (unsigned int)utf_char2bytes(key, (char *)dst + dlen);
|
||||
dlen += (unsigned int)utf_char2bytes(key, dst + dlen);
|
||||
}
|
||||
|
||||
return dlen;
|
||||
@ -1033,20 +1033,20 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
||||
/// @param[out] s Buffer to add to. Must have at least MB_MAXBYTES + 1 bytes.
|
||||
///
|
||||
/// @return Pointer to after the added bytes.
|
||||
char_u *add_char2buf(int c, char_u *s)
|
||||
char *add_char2buf(int c, char *s)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
char_u temp[MB_MAXBYTES + 1];
|
||||
const int len = utf_char2bytes(c, (char *)temp);
|
||||
char temp[MB_MAXBYTES + 1];
|
||||
const int len = utf_char2bytes(c, temp);
|
||||
for (int i = 0; i < len; i++) {
|
||||
c = (uint8_t)temp[i];
|
||||
// Need to escape K_SPECIAL like in the typeahead buffer.
|
||||
if (c == K_SPECIAL) {
|
||||
*s++ = K_SPECIAL;
|
||||
*s++ = KS_SPECIAL;
|
||||
*s++ = (char)(uint8_t)K_SPECIAL;
|
||||
*s++ = (char)(uint8_t)KS_SPECIAL;
|
||||
*s++ = KE_FILLER;
|
||||
} else {
|
||||
*s++ = (char_u)c;
|
||||
*s++ = (char)(uint8_t)c;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
@ -1060,9 +1060,9 @@ char *vim_strsave_escape_ks(char *p)
|
||||
// illegal utf-8 byte:
|
||||
// 0xc0 -> 0xc3 - 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER
|
||||
char *res = xmalloc(strlen(p) * 4 + 1);
|
||||
char_u *d = (char_u *)res;
|
||||
for (char_u *s = (char_u *)p; *s != NUL;) {
|
||||
if (s[0] == K_SPECIAL && s[1] != NUL && s[2] != NUL) {
|
||||
char *d = res;
|
||||
for (char *s = p; *s != NUL;) {
|
||||
if ((uint8_t)s[0] == K_SPECIAL && s[1] != NUL && s[2] != NUL) {
|
||||
// Copy special key unmodified.
|
||||
*d++ = *s++;
|
||||
*d++ = *s++;
|
||||
@ -1070,8 +1070,8 @@ char *vim_strsave_escape_ks(char *p)
|
||||
} else {
|
||||
// Add character, possibly multi-byte to destination, escaping
|
||||
// K_SPECIAL. Be careful, it can be an illegal byte!
|
||||
d = add_char2buf(utf_ptr2char((char *)s), d);
|
||||
s += utf_ptr2len((char *)s);
|
||||
d = add_char2buf(utf_ptr2char(s), d);
|
||||
s += utf_ptr2len(s);
|
||||
}
|
||||
}
|
||||
*d = NUL;
|
||||
@ -1081,9 +1081,9 @@ char *vim_strsave_escape_ks(char *p)
|
||||
|
||||
/// Remove escaping from K_SPECIAL characters. Reverse of
|
||||
/// vim_strsave_escape_ks(). Works in-place.
|
||||
void vim_unescape_ks(char_u *p)
|
||||
void vim_unescape_ks(char *p)
|
||||
{
|
||||
char_u *s = p, *d = p;
|
||||
char_u *s = (char_u *)p, *d = (char_u *)p;
|
||||
|
||||
while (*s != NUL) {
|
||||
if (s[0] == K_SPECIAL && s[1] == KS_SPECIAL && s[2] == KE_FILLER) {
|
||||
|
@ -59,7 +59,7 @@
|
||||
// Used for switching Select mode back on after a mapping or menu.
|
||||
|
||||
#define KS_SELECT 245
|
||||
#define K_SELECT_STRING (char_u *)"\200\365X"
|
||||
#define K_SELECT_STRING "\200\365X"
|
||||
|
||||
/// Used a termcap entry that produces a normal character.
|
||||
#define KS_KEY 242
|
||||
|
@ -1993,7 +1993,7 @@ char *nlua_register_table_as_callable(const typval_T *const arg)
|
||||
void nlua_execute_on_key(int c)
|
||||
{
|
||||
char buf[NUMBUFLEN];
|
||||
size_t buf_len = special_to_buf(c, mod_mask, false, (char_u *)buf);
|
||||
size_t buf_len = special_to_buf(c, mod_mask, false, buf);
|
||||
|
||||
lua_State *const lstate = global_lstate;
|
||||
|
||||
|
@ -222,7 +222,7 @@ static int nlua_str_utf_start(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
||||
if (offset < 0 || offset > (intptr_t)s1_len) {
|
||||
return luaL_error(lstate, "index out of range");
|
||||
}
|
||||
int head_offset = utf_cp_head_off((char_u *)s1, (char_u *)s1 + offset - 1);
|
||||
int head_offset = utf_cp_head_off(s1, s1 + offset - 1);
|
||||
lua_pushinteger(lstate, head_offset);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1589,7 +1589,7 @@ static void open_script_files(mparm_T *parmp)
|
||||
scriptin[0] = file_open_new(&error, parmp->scriptin,
|
||||
kFileReadOnly|kFileNonBlocking, 0);
|
||||
if (scriptin[0] == NULL) {
|
||||
vim_snprintf((char *)IObuff, IOSIZE,
|
||||
vim_snprintf(IObuff, IOSIZE,
|
||||
_("Cannot open for reading: \"%s\": %s\n"),
|
||||
parmp->scriptin, os_strerror(error));
|
||||
os_errmsg(IObuff);
|
||||
|
@ -1162,7 +1162,7 @@ static bool expand_buffer = false;
|
||||
/// @param cpo_flags Value of various flags present in &cpo
|
||||
///
|
||||
/// @return NULL when there is a problem.
|
||||
static char_u *translate_mapping(char_u *str, int cpo_flags)
|
||||
static char *translate_mapping(char_u *str, int cpo_flags)
|
||||
{
|
||||
garray_T ga;
|
||||
ga_init(&ga, 1, 40);
|
||||
@ -1203,7 +1203,7 @@ static char_u *translate_mapping(char_u *str, int cpo_flags)
|
||||
}
|
||||
}
|
||||
ga_append(&ga, NUL);
|
||||
return (char_u *)(ga.ga_data);
|
||||
return (char *)ga.ga_data;
|
||||
}
|
||||
|
||||
/// Work out what to complete when doing command line completion of mapping
|
||||
@ -1212,8 +1212,8 @@ static char_u *translate_mapping(char_u *str, int cpo_flags)
|
||||
/// @param forceit true if '!' given
|
||||
/// @param isabbrev true if abbreviation
|
||||
/// @param isunmap true if unmap/unabbrev command
|
||||
char_u *set_context_in_map_cmd(expand_T *xp, char *cmd, char *arg, bool forceit, bool isabbrev,
|
||||
bool isunmap, cmdidx_T cmdidx)
|
||||
char *set_context_in_map_cmd(expand_T *xp, char *cmd, char *arg, bool forceit, bool isabbrev,
|
||||
bool isunmap, cmdidx_T cmdidx)
|
||||
{
|
||||
if (forceit && cmdidx != CMD_map && cmdidx != CMD_unmap) {
|
||||
xp->xp_context = EXPAND_NOTHING;
|
||||
@ -1346,7 +1346,7 @@ int ExpandMappings(char *pat, regmatch_T *regmatch, int *numMatches, char ***mat
|
||||
continue;
|
||||
}
|
||||
|
||||
char *p = (char *)translate_mapping((char_u *)mp->m_keys, CPO_TO_CPO_FLAGS);
|
||||
char *p = translate_mapping((char_u *)mp->m_keys, CPO_TO_CPO_FLAGS);
|
||||
if (p == NULL) {
|
||||
continue;
|
||||
}
|
||||
@ -1503,7 +1503,7 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
|
||||
if (strchr((const char *)mp->m_keys, K_SPECIAL) != NULL) {
|
||||
// Might have K_SPECIAL escaped mp->m_keys.
|
||||
q = xstrdup(mp->m_keys);
|
||||
vim_unescape_ks((char_u *)q);
|
||||
vim_unescape_ks(q);
|
||||
qlen = (int)strlen(q);
|
||||
}
|
||||
// find entries with right mode and keys
|
||||
@ -1607,7 +1607,7 @@ char *eval_map_expr(mapblock_T *mp, int c)
|
||||
// typeahead.
|
||||
if (mp->m_luaref == LUA_NOREF) {
|
||||
expr = xstrdup(mp->m_str);
|
||||
vim_unescape_ks((char_u *)expr);
|
||||
vim_unescape_ks(expr);
|
||||
}
|
||||
|
||||
const bool replace_keycodes = mp->m_replace_keycodes;
|
||||
|
@ -1842,7 +1842,7 @@ int utf_cp_tail_off(const char *base, const char *p_in)
|
||||
/// @param[in] p Pointer to byte for which to return the offset to the previous codepoint
|
||||
//
|
||||
/// @return 0 if invalid sequence, else offset to previous codepoint
|
||||
int utf_cp_head_off(const char_u *base, const char_u *p)
|
||||
int utf_cp_head_off(const char *base, const char *p)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
@ -1853,16 +1853,16 @@ int utf_cp_head_off(const char_u *base, const char_u *p)
|
||||
|
||||
// Find the first character that is not 10xx.xxxx
|
||||
for (i = 0; p - i > base; i--) {
|
||||
if ((p[i] & 0xc0) != 0x80) {
|
||||
if (((uint8_t)p[i] & 0xc0) != 0x80) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the last character that is 10xx.xxxx
|
||||
for (j = 0; (p[j + 1] & 0xc0) == 0x80; j++) {}
|
||||
for (j = 0; ((uint8_t)p[j + 1] & 0xc0) == 0x80; j++) {}
|
||||
|
||||
// Check for illegal sequence.
|
||||
if (utf8len_tab[p[i]] == 1) {
|
||||
if (utf8len_tab[(uint8_t)p[i]] == 1) {
|
||||
return 0;
|
||||
}
|
||||
return i;
|
||||
|
@ -185,8 +185,8 @@ struct block0 {
|
||||
char_u b0_mtime[4]; // last modification time of file
|
||||
char_u b0_ino[4]; // inode of b0_fname
|
||||
char_u b0_pid[4]; // process id of creator (or 0)
|
||||
char_u b0_uname[B0_UNAME_SIZE]; // name of user (uid if no name)
|
||||
char_u b0_hname[B0_HNAME_SIZE]; // host name (if it has a name)
|
||||
char b0_uname[B0_UNAME_SIZE]; // name of user (uid if no name)
|
||||
char b0_hname[B0_HNAME_SIZE]; // host name (if it has a name)
|
||||
char b0_fname[B0_FNAME_SIZE_ORG]; // name of file being edited
|
||||
long b0_magic_long; // check for byte order of long
|
||||
int b0_magic_int; // check for byte order of int
|
||||
@ -303,9 +303,9 @@ int ml_open(buf_T *buf)
|
||||
b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0;
|
||||
b0p->b0_flags = (char)(get_fileformat(buf) + 1);
|
||||
set_b0_fname(b0p, buf);
|
||||
(void)os_get_username((char *)b0p->b0_uname, B0_UNAME_SIZE);
|
||||
(void)os_get_username(b0p->b0_uname, B0_UNAME_SIZE);
|
||||
b0p->b0_uname[B0_UNAME_SIZE - 1] = NUL;
|
||||
os_get_hostname((char *)b0p->b0_hname, B0_HNAME_SIZE);
|
||||
os_get_hostname(b0p->b0_hname, B0_HNAME_SIZE);
|
||||
b0p->b0_hname[B0_HNAME_SIZE - 1] = NUL;
|
||||
long_to_char((long)os_get_pid(), b0p->b0_pid);
|
||||
}
|
||||
@ -632,7 +632,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
|
||||
// editing the same file on different machines over a network.
|
||||
// First replace home dir path with "~/" with home_replace().
|
||||
// Then insert the user name to get "~user/".
|
||||
home_replace(NULL, buf->b_ffname, (char *)b0p->b0_fname,
|
||||
home_replace(NULL, buf->b_ffname, b0p->b0_fname,
|
||||
B0_FNAME_SIZE_CRYPT, true);
|
||||
if (b0p->b0_fname[0] == '~') {
|
||||
// If there is no user name or it is too long, don't use "~/"
|
||||
@ -691,7 +691,7 @@ static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf)
|
||||
if ((int)strlen(b0p->b0_fname) + n + 1 > size) {
|
||||
b0p->b0_flags = (char)(b0p->b0_flags & ~B0_HAS_FENC);
|
||||
} else {
|
||||
memmove((char *)b0p->b0_fname + size - n,
|
||||
memmove(b0p->b0_fname + size - n,
|
||||
buf->b_p_fenc, (size_t)n);
|
||||
*(b0p->b0_fname + size - n - 1) = NUL;
|
||||
b0p->b0_flags |= B0_HAS_FENC;
|
||||
@ -848,7 +848,7 @@ void ml_recover(bool checkext)
|
||||
msg_puts_attr(_("The file was created on "), attr | MSG_HIST);
|
||||
// avoid going past the end of a corrupted hostname
|
||||
b0p->b0_fname[0] = NUL;
|
||||
msg_puts_attr((char *)b0p->b0_hname, attr | MSG_HIST);
|
||||
msg_puts_attr(b0p->b0_hname, attr | MSG_HIST);
|
||||
msg_puts_attr(_(",\nor the file has been damaged."), attr | MSG_HIST);
|
||||
msg_end();
|
||||
goto theend;
|
||||
@ -886,7 +886,7 @@ void ml_recover(bool checkext)
|
||||
|
||||
// If .swp file name given directly, use name from swap file for buffer.
|
||||
if (directly) {
|
||||
expand_env((char *)b0p->b0_fname, NameBuff, MAXPATHL);
|
||||
expand_env(b0p->b0_fname, NameBuff, MAXPATHL);
|
||||
if (setfname(curbuf, NameBuff, NULL, true) == FAIL) {
|
||||
goto theend;
|
||||
}
|
||||
@ -922,7 +922,7 @@ void ml_recover(bool checkext)
|
||||
if (b0p->b0_flags & B0_HAS_FENC) {
|
||||
int fnsize = B0_FNAME_SIZE_NOCRYPT;
|
||||
|
||||
for (p = (char *)b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) {}
|
||||
for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) {}
|
||||
b0_fenc = xstrnsave(p, (size_t)(b0p->b0_fname + fnsize - p));
|
||||
}
|
||||
|
||||
@ -1411,11 +1411,11 @@ void get_b0_dict(const char *fname, dict_T *d)
|
||||
} else {
|
||||
// We have swap information.
|
||||
tv_dict_add_str_len(d, S_LEN("version"), b0.b0_version, 10);
|
||||
tv_dict_add_str_len(d, S_LEN("user"), (char *)b0.b0_uname,
|
||||
tv_dict_add_str_len(d, S_LEN("user"), b0.b0_uname,
|
||||
B0_UNAME_SIZE);
|
||||
tv_dict_add_str_len(d, S_LEN("host"), (char *)b0.b0_hname,
|
||||
tv_dict_add_str_len(d, S_LEN("host"), b0.b0_hname,
|
||||
B0_HNAME_SIZE);
|
||||
tv_dict_add_str_len(d, S_LEN("fname"), (char *)b0.b0_fname,
|
||||
tv_dict_add_str_len(d, S_LEN("fname"), b0.b0_fname,
|
||||
B0_FNAME_SIZE_ORG);
|
||||
|
||||
tv_dict_add_nr(d, S_LEN("pid"), char_to_long(b0.b0_pid));
|
||||
@ -1480,7 +1480,7 @@ static time_t swapfile_info(char *fname)
|
||||
if (b0.b0_fname[0] == NUL) {
|
||||
msg_puts(_("[No Name]"));
|
||||
} else {
|
||||
msg_outtrans((char *)b0.b0_fname);
|
||||
msg_outtrans(b0.b0_fname);
|
||||
}
|
||||
|
||||
msg_puts(_("\n modified: "));
|
||||
@ -1488,7 +1488,7 @@ static time_t swapfile_info(char *fname)
|
||||
|
||||
if (*(b0.b0_uname) != NUL) {
|
||||
msg_puts(_("\n user name: "));
|
||||
msg_outtrans((char *)b0.b0_uname);
|
||||
msg_outtrans(b0.b0_uname);
|
||||
}
|
||||
|
||||
if (*(b0.b0_hname) != NUL) {
|
||||
@ -1497,7 +1497,7 @@ static time_t swapfile_info(char *fname)
|
||||
} else {
|
||||
msg_puts(_("\n host name: "));
|
||||
}
|
||||
msg_outtrans((char *)b0.b0_hname);
|
||||
msg_outtrans(b0.b0_hname);
|
||||
}
|
||||
|
||||
if (char_to_long(b0.b0_pid) != 0L) {
|
||||
@ -3029,7 +3029,7 @@ char *makeswapname(char *fname, char *ffname, buf_T *buf, char *dir_name)
|
||||
|
||||
// Expand symlink in the file name, so that we put the swap file with the
|
||||
// actual file instead of with the symlink.
|
||||
if (resolve_symlink(fname, (char *)fname_buf) == OK) {
|
||||
if (resolve_symlink(fname, fname_buf) == OK) {
|
||||
fname_res = fname_buf;
|
||||
}
|
||||
#endif
|
||||
@ -3267,12 +3267,12 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
|
||||
// have a different mountpoint.
|
||||
if (b0.b0_flags & B0_SAME_DIR) {
|
||||
if (path_fnamecmp(path_tail(buf->b_ffname),
|
||||
path_tail((char *)b0.b0_fname)) != 0
|
||||
path_tail(b0.b0_fname)) != 0
|
||||
|| !same_directory(fname, buf->b_ffname)) {
|
||||
// Symlinks may point to the same file even
|
||||
// when the name differs, need to check the
|
||||
// inode too.
|
||||
expand_env((char *)b0.b0_fname, NameBuff, MAXPATHL);
|
||||
expand_env(b0.b0_fname, NameBuff, MAXPATHL);
|
||||
if (fnamecmp_ino(buf->b_ffname, NameBuff,
|
||||
char_to_long(b0.b0_ino))) {
|
||||
differ = true;
|
||||
@ -3281,7 +3281,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
|
||||
} else {
|
||||
// The name in the swap file may be
|
||||
// "~user/path/file". Expand it first.
|
||||
expand_env((char *)b0.b0_fname, NameBuff, MAXPATHL);
|
||||
expand_env(b0.b0_fname, NameBuff, MAXPATHL);
|
||||
if (fnamecmp_ino(buf->b_ffname, NameBuff,
|
||||
char_to_long(b0.b0_ino))) {
|
||||
differ = true;
|
||||
@ -3516,8 +3516,8 @@ static bool fnamecmp_ino(char *fname_c, char *fname_s, long ino_block0)
|
||||
|
||||
// One of the inode numbers is unknown, try a forced vim_FullName() and
|
||||
// compare the file names.
|
||||
retval_c = vim_FullName(fname_c, (char *)buf_c, MAXPATHL, true);
|
||||
retval_s = vim_FullName(fname_s, (char *)buf_s, MAXPATHL, true);
|
||||
retval_c = vim_FullName(fname_c, buf_c, MAXPATHL, true);
|
||||
retval_s = vim_FullName(fname_s, buf_s, MAXPATHL, true);
|
||||
if (retval_c == OK && retval_s == OK) {
|
||||
return strcmp(buf_c, buf_s) != 0;
|
||||
}
|
||||
|
@ -1085,7 +1085,7 @@ void ex_messages(void *const eap_p)
|
||||
} else if (p->msg && p->msg[0]) {
|
||||
Array content_entry = ARRAY_DICT_INIT;
|
||||
ADD(content_entry, INTEGER_OBJ(p->attr));
|
||||
ADD(content_entry, STRING_OBJ(cstr_to_string((char *)(p->msg))));
|
||||
ADD(content_entry, STRING_OBJ(cstr_to_string(p->msg)));
|
||||
ADD(content, ARRAY_OBJ(content_entry));
|
||||
}
|
||||
ADD(entry, ARRAY_OBJ(content));
|
||||
@ -1470,9 +1470,9 @@ void msg_putchar_attr(int c, int attr)
|
||||
buf[2] = (char)K_THIRD(c);
|
||||
buf[3] = NUL;
|
||||
} else {
|
||||
buf[utf_char2bytes(c, (char *)buf)] = NUL;
|
||||
buf[utf_char2bytes(c, buf)] = NUL;
|
||||
}
|
||||
msg_puts_attr((const char *)buf, attr);
|
||||
msg_puts_attr(buf, attr);
|
||||
}
|
||||
|
||||
void msg_outnum(long n)
|
||||
@ -2139,7 +2139,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
|
||||
int t_col = 0; // Screen cells todo, 0 when "t_s" not used.
|
||||
int l;
|
||||
int cw;
|
||||
const char *sb_str = (char *)str;
|
||||
const char *sb_str = str;
|
||||
int sb_col = msg_col;
|
||||
int wrap;
|
||||
int did_last_char;
|
||||
@ -2153,7 +2153,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
|
||||
}
|
||||
// Concat pieces with the same highlight
|
||||
size_t len = strnlen(str, (size_t)maxlen); // -V781
|
||||
ga_concat_len(&msg_ext_last_chunk, (char *)str, len);
|
||||
ga_concat_len(&msg_ext_last_chunk, str, len);
|
||||
msg_ext_cur_len += len;
|
||||
return;
|
||||
}
|
||||
|
@ -926,7 +926,7 @@ int do_record(int c)
|
||||
char *p = (char *)get_recorded();
|
||||
if (p != NULL) {
|
||||
// Remove escaping for K_SPECIAL in multi-byte chars.
|
||||
vim_unescape_ks((char_u *)p);
|
||||
vim_unescape_ks(p);
|
||||
(void)tv_dict_add_str(dict, S_LEN("regcontents"), (const char *)p);
|
||||
}
|
||||
|
||||
@ -3848,7 +3848,7 @@ void ex_display(exarg_T *eap)
|
||||
}
|
||||
|
||||
// display last inserted text
|
||||
if ((p = (char *)get_last_insert()) != NULL
|
||||
if ((p = get_last_insert()) != NULL
|
||||
&& (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int
|
||||
&& !message_filtered(p)) {
|
||||
msg_puts("\n c \". ");
|
||||
@ -5490,7 +5490,7 @@ void cursor_pos_info(dict_T *dict)
|
||||
validate_virtcol();
|
||||
col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
|
||||
(int)curwin->w_virtcol + 1);
|
||||
col_print((char *)buf2, sizeof(buf2), (int)strlen(p), linetabsize(p));
|
||||
col_print(buf2, sizeof(buf2), (int)strlen(p), linetabsize(p));
|
||||
|
||||
if (char_count_cursor == byte_count_cursor
|
||||
&& char_count == byte_count) {
|
||||
|
@ -754,7 +754,7 @@ static void do_set_bool(int opt_idx, int opt_flags, int prefix, int nextchar, co
|
||||
}
|
||||
}
|
||||
|
||||
*errmsg = set_bool_option(opt_idx, (char_u *)varp, (int)value, opt_flags);
|
||||
*errmsg = set_bool_option(opt_idx, (char *)varp, (int)value, opt_flags);
|
||||
}
|
||||
|
||||
static void do_set_num(int opt_idx, int opt_flags, char **argp, int nextchar, const set_op_T op,
|
||||
@ -1109,7 +1109,7 @@ static void do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
||||
}
|
||||
|
||||
// Set the new value.
|
||||
*(char_u **)(varp) = (char_u *)newval;
|
||||
*(char **)(varp) = newval;
|
||||
|
||||
// origval may be freed by did_set_string_option(), make a copy.
|
||||
char *saved_origval = (origval != NULL) ? xstrdup(origval) : NULL;
|
||||
@ -1974,7 +1974,7 @@ static void apply_optionset_autocmd(int opt_idx, long opt_flags, long oldval, lo
|
||||
/// @param[in] opt_flags OPT_LOCAL and/or OPT_GLOBAL.
|
||||
///
|
||||
/// @return NULL on success, error message on error.
|
||||
static char *set_bool_option(const int opt_idx, char_u *const varp, const int value,
|
||||
static char *set_bool_option(const int opt_idx, char *const varp, const int value,
|
||||
const int opt_flags)
|
||||
{
|
||||
int old_value = *(int *)varp;
|
||||
@ -2010,7 +2010,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
|
||||
// Ensure that options set to p_force_off cannot be enabled.
|
||||
} else if ((int *)varp == &p_force_off && p_force_off == true) {
|
||||
p_force_off = false;
|
||||
return (char *)e_unsupportedoption;
|
||||
return e_unsupportedoption;
|
||||
} else if ((int *)varp == &p_lrm) {
|
||||
// 'langremap' -> !'langnoremap'
|
||||
p_lnr = !p_lrm;
|
||||
@ -2023,7 +2023,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
|
||||
// delete the undo file, the option may be set again without making
|
||||
// any changes in between.
|
||||
if (curbuf->b_p_udf || p_udf) {
|
||||
char_u hash[UNDO_HASH_SIZE];
|
||||
uint8_t hash[UNDO_HASH_SIZE];
|
||||
|
||||
FOR_ALL_BUFFERS(bp) {
|
||||
// When 'undofile' is set globally: for every buffer, otherwise
|
||||
@ -2103,7 +2103,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (varp == (char_u *)&(curbuf->b_p_lisp)) {
|
||||
} else if (varp == (char *)&(curbuf->b_p_lisp)) {
|
||||
// When 'lisp' option changes include/exclude '-' in
|
||||
// keyword characters.
|
||||
(void)buf_init_chartab(curbuf, false); // ignore errors
|
||||
@ -3127,7 +3127,7 @@ char *set_option_value(const char *const name, const long number, const char *co
|
||||
if (flags & P_NUM) {
|
||||
return set_num_option(opt_idx, varp, numval, NULL, 0, opt_flags);
|
||||
}
|
||||
return set_bool_option(opt_idx, varp, (int)numval, opt_flags);
|
||||
return set_bool_option(opt_idx, (char *)varp, (int)numval, opt_flags);
|
||||
}
|
||||
|
||||
/// Call set_option_value() and when an error is returned report it.
|
||||
@ -3218,13 +3218,13 @@ static void showoptions(bool all, int opt_flags)
|
||||
continue;
|
||||
}
|
||||
|
||||
char_u *varp = NULL;
|
||||
char *varp = NULL;
|
||||
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) {
|
||||
if (p->indir != PV_NONE) {
|
||||
varp = (char_u *)get_varp_scope(p, opt_flags);
|
||||
varp = get_varp_scope(p, opt_flags);
|
||||
}
|
||||
} else {
|
||||
varp = get_varp(p);
|
||||
varp = (char *)get_varp(p);
|
||||
}
|
||||
if (varp != NULL
|
||||
&& (all == 1 || (all == 0 && !optval_default(p, varp)))) {
|
||||
@ -3278,7 +3278,7 @@ static void showoptions(bool all, int opt_flags)
|
||||
}
|
||||
|
||||
/// Return true if option "p" has its default value.
|
||||
static int optval_default(vimoption_T *p, const char_u *varp)
|
||||
static int optval_default(vimoption_T *p, const char *varp)
|
||||
{
|
||||
if (varp == NULL) {
|
||||
return true; // hidden option is always at default
|
||||
@ -3403,7 +3403,7 @@ int makeset(FILE *fd, int opt_flags, int local_only)
|
||||
continue;
|
||||
}
|
||||
// Global values are only written when not at the default value.
|
||||
if ((opt_flags & OPT_GLOBAL) && optval_default(p, (char_u *)varp)) {
|
||||
if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -3424,7 +3424,7 @@ int makeset(FILE *fd, int opt_flags, int local_only)
|
||||
// default, need to write it too.
|
||||
if (!(opt_flags & OPT_GLOBAL) && !local_only) {
|
||||
char_u *varp_fresh = (char_u *)get_varp_scope(p, OPT_GLOBAL); // local value
|
||||
if (!optval_default(p, varp_fresh)) {
|
||||
if (!optval_default(p, (char *)varp_fresh)) {
|
||||
round = 1;
|
||||
varp_local = (char_u *)varp;
|
||||
varp = (char *)varp_fresh;
|
||||
@ -4966,7 +4966,7 @@ static void option_value2string(vimoption_T *opp, int scope)
|
||||
if (varp == NULL) { // Just in case.
|
||||
NameBuff[0] = NUL;
|
||||
} else if (opp->flags & P_EXPAND) {
|
||||
home_replace(NULL, varp, (char *)NameBuff, MAXPATHL, false);
|
||||
home_replace(NULL, varp, NameBuff, MAXPATHL, false);
|
||||
// Translate 'pastetoggle' into special key names.
|
||||
} else if ((char **)opp->var == &p_pt) {
|
||||
str2specialbuf((const char *)p_pt, NameBuff, MAXPATHL);
|
||||
@ -5187,8 +5187,8 @@ void fill_breakat_flags(void)
|
||||
}
|
||||
|
||||
if (p_breakat != NULL) {
|
||||
for (char_u *p = (char_u *)p_breakat; *p; p++) {
|
||||
breakat_flags[*p] = true;
|
||||
for (char *p = p_breakat; *p; p++) {
|
||||
breakat_flags[(uint8_t)(*p)] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -810,7 +810,7 @@ static int find_previous_pathsep(char *path, char **psep)
|
||||
}
|
||||
|
||||
/// Returns true if "maybe_unique" is unique wrt other_paths in "gap".
|
||||
/// "maybe_unique" is the end portion of "((char_u **)gap->ga_data)[i]".
|
||||
/// "maybe_unique" is the end portion of "((char **)gap->ga_data)[i]".
|
||||
static bool is_unique(char *maybe_unique, garray_T *gap, int i)
|
||||
{
|
||||
char **other_paths = gap->ga_data;
|
||||
@ -879,7 +879,7 @@ static void expand_path_option(char *curdir, garray_T *gap)
|
||||
}
|
||||
STRMOVE(buf + len + 1, buf);
|
||||
STRCPY(buf, curdir);
|
||||
buf[len] = (char_u)PATHSEP;
|
||||
buf[len] = PATHSEP;
|
||||
simplify_filename(buf);
|
||||
}
|
||||
|
||||
@ -1923,7 +1923,7 @@ void path_fix_case(char *name)
|
||||
xstrlcpy(newname + (tail - name), entry,
|
||||
(size_t)(MAXPATHL - (tail - name) + 1));
|
||||
FileInfo file_info_new;
|
||||
if (os_fileinfo_link((char *)newname, &file_info_new)
|
||||
if (os_fileinfo_link(newname, &file_info_new)
|
||||
&& os_fileinfo_id_equal(&file_info, &file_info_new)) {
|
||||
STRCPY(tail, entry);
|
||||
break;
|
||||
@ -1956,11 +1956,11 @@ bool same_directory(char *f1, char *f2)
|
||||
return false;
|
||||
}
|
||||
|
||||
(void)vim_FullName(f1, (char *)ffname, MAXPATHL, false);
|
||||
(void)vim_FullName(f1, ffname, MAXPATHL, false);
|
||||
t1 = path_tail_with_sep(ffname);
|
||||
t2 = path_tail_with_sep(f2);
|
||||
return t1 - ffname == t2 - f2
|
||||
&& pathcmp((char *)ffname, f2, (int)(t1 - ffname)) == 0;
|
||||
&& pathcmp(ffname, f2, (int)(t1 - ffname)) == 0;
|
||||
}
|
||||
|
||||
// Compare path "p[]" to "q[]".
|
||||
|
@ -95,7 +95,7 @@ static struct spat spats[2] = {
|
||||
|
||||
static int last_idx = 0; // index in spats[] for RE_LAST
|
||||
|
||||
static char_u lastc[2] = { NUL, NUL }; // last character searched for
|
||||
static uint8_t lastc[2] = { NUL, NUL }; // last character searched for
|
||||
static Direction lastcdir = FORWARD; // last direction of character search
|
||||
static int last_t_cmd = true; // last search t_cmd
|
||||
static char lastc_bytes[MB_MAXBYTES + 1];
|
||||
@ -439,7 +439,7 @@ int last_csearch_until(void)
|
||||
|
||||
void set_last_csearch(int c, char *s, int len)
|
||||
{
|
||||
*lastc = (char_u)c;
|
||||
*lastc = (uint8_t)c;
|
||||
lastc_bytelen = len;
|
||||
if (len) {
|
||||
memcpy(lastc_bytes, s, (size_t)len);
|
||||
@ -1053,7 +1053,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, long count, i
|
||||
|
||||
// Find out the direction of the search.
|
||||
if (dirc == 0) {
|
||||
dirc = (char_u)spats[0].off.dir;
|
||||
dirc = (uint8_t)spats[0].off.dir;
|
||||
} else {
|
||||
spats[0].off.dir = (char)dirc;
|
||||
set_vv_searchforward();
|
||||
@ -1510,7 +1510,7 @@ int searchc(cmdarg_T *cap, int t_cmd)
|
||||
|
||||
if (c != NUL) { // normal search: remember args for repeat
|
||||
if (!KeyStuffed) { // don't remember when redoing
|
||||
*lastc = (char_u)c;
|
||||
*lastc = (uint8_t)c;
|
||||
set_csearch_direction(dir);
|
||||
set_csearch_until(t_cmd);
|
||||
lastc_bytelen = utf_char2bytes(c, lastc_bytes);
|
||||
@ -3125,8 +3125,7 @@ static int fuzzy_match_recursive(const char *fuzpat, const char *str, uint32_t s
|
||||
/// normalized and varies with pattern.
|
||||
/// Recursion is limited internally (default=10) to prevent degenerate cases
|
||||
/// (pat_arg="aaaaaa" str="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").
|
||||
/// Uses char_u for match indices. Therefore patterns are limited to
|
||||
/// MAX_FUZZY_MATCHES characters.
|
||||
/// Patterns are limited to MAX_FUZZY_MATCHES characters.
|
||||
///
|
||||
/// @return true if "pat_arg" matches "str". Also returns the match score in
|
||||
/// "outScore" and the matching character positions in "matches".
|
||||
|
@ -201,14 +201,14 @@ void sha256_update(context_sha256_T *ctx, const uint8_t *input, size_t length)
|
||||
memcpy(ctx->buffer + left, input, fill);
|
||||
sha256_process(ctx, ctx->buffer);
|
||||
length -= fill;
|
||||
input += fill;
|
||||
input += fill;
|
||||
left = 0;
|
||||
}
|
||||
|
||||
while (length >= SHA256_BUFFER_SIZE) {
|
||||
sha256_process(ctx, input);
|
||||
length -= SHA256_BUFFER_SIZE;
|
||||
input += SHA256_BUFFER_SIZE;
|
||||
input += SHA256_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (length) {
|
||||
|
@ -2579,7 +2579,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef
|
||||
{ STATIC_CSTR_AS_STRING("pid"),
|
||||
INTEGER_OBJ((Integer)os_get_pid()) },
|
||||
{ STATIC_CSTR_AS_STRING("encoding"),
|
||||
STRING_OBJ(cstr_as_string((char *)p_enc)) },
|
||||
STRING_OBJ(cstr_as_string(p_enc)) },
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
@ -298,8 +298,8 @@ static dict_T *sign_get_info(sign_entry_T *sign)
|
||||
dict_T *d = tv_dict_alloc();
|
||||
tv_dict_add_nr(d, S_LEN("id"), sign->se_id);
|
||||
tv_dict_add_str(d, S_LEN("group"), ((sign->se_group == NULL)
|
||||
? (char *)""
|
||||
: (char *)sign->se_group->sg_name));
|
||||
? ""
|
||||
: sign->se_group->sg_name));
|
||||
tv_dict_add_nr(d, S_LEN("lnum"), sign->se_lnum);
|
||||
tv_dict_add_str(d, S_LEN("name"), sign_typenr2name(sign->se_typenr));
|
||||
tv_dict_add_nr(d, S_LEN("priority"), sign->se_priority);
|
||||
@ -576,7 +576,7 @@ static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char *group)
|
||||
lnum = sign->se_lnum;
|
||||
buf_signcols_del_check(buf, lnum, lnum);
|
||||
if (sign->se_group != NULL) {
|
||||
sign_group_unref((char *)sign->se_group->sg_name);
|
||||
sign_group_unref(sign->se_group->sg_name);
|
||||
}
|
||||
xfree(sign);
|
||||
redraw_buf_line_later(buf, lnum, false);
|
||||
@ -688,7 +688,7 @@ void buf_delete_signs(buf_T *buf, char *group)
|
||||
next->se_prev = sign->se_prev;
|
||||
}
|
||||
if (sign->se_group != NULL) {
|
||||
sign_group_unref((char *)sign->se_group->sg_name);
|
||||
sign_group_unref(sign->se_group->sg_name);
|
||||
}
|
||||
xfree(sign);
|
||||
} else {
|
||||
@ -1778,7 +1778,7 @@ static char *get_nth_sign_group_name(int idx)
|
||||
todo--;
|
||||
if (current_idx++ == idx) {
|
||||
signgroup_T *const group = HI2SG(hi);
|
||||
return (char *)group->sg_name;
|
||||
return group->sg_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -437,14 +437,14 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
int flen;
|
||||
char *ptr;
|
||||
slang_T *slang = mip->mi_lp->lp_slang;
|
||||
char_u *byts;
|
||||
uint8_t *byts;
|
||||
idx_T *idxs;
|
||||
|
||||
if (mode == FIND_KEEPWORD || mode == FIND_KEEPCOMPOUND) {
|
||||
// Check for word with matching case in keep-case tree.
|
||||
ptr = mip->mi_word;
|
||||
flen = 9999; // no case folding, always enough bytes
|
||||
byts = (char_u *)slang->sl_kbyts;
|
||||
byts = (uint8_t *)slang->sl_kbyts;
|
||||
idxs = slang->sl_kidxs;
|
||||
|
||||
if (mode == FIND_KEEPCOMPOUND) {
|
||||
@ -455,7 +455,7 @@ static void find_word(matchinf_T *mip, int mode)
|
||||
// Check for case-folded in case-folded tree.
|
||||
ptr = mip->mi_fword;
|
||||
flen = mip->mi_fwordlen; // available case-folded bytes
|
||||
byts = (char_u *)slang->sl_fbyts;
|
||||
byts = (uint8_t *)slang->sl_fbyts;
|
||||
idxs = slang->sl_fidxs;
|
||||
|
||||
if (mode == FIND_PREFIX) {
|
||||
@ -964,7 +964,7 @@ bool can_compound(slang_T *slang, const char *word, const uint8_t *flags)
|
||||
bool match_compoundrule(slang_T *slang, const char_u *compflags)
|
||||
{
|
||||
// loop over all the COMPOUNDRULE entries
|
||||
for (char_u *p = (char_u *)slang->sl_comprules; *p != NUL; p++) {
|
||||
for (char *p = (char *)slang->sl_comprules; *p != NUL; p++) {
|
||||
// loop over the flags in the compound word we have made, match
|
||||
// them against the current rule entry
|
||||
for (int i = 0;; i++) {
|
||||
@ -982,21 +982,21 @@ bool match_compoundrule(slang_T *slang, const char_u *compflags)
|
||||
// compare against all the flags in []
|
||||
p++;
|
||||
while (*p != ']' && *p != NUL) {
|
||||
if (*p++ == c) {
|
||||
if ((uint8_t)(*p++) == c) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
break; // none matches
|
||||
}
|
||||
} else if (*p != c) {
|
||||
} else if ((uint8_t)(*p) != c) {
|
||||
break; // flag of word doesn't match flag in pattern
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
// Skip to the next "/", where the next pattern starts.
|
||||
p = (char_u *)vim_strchr((char *)p, '/');
|
||||
p = vim_strchr(p, '/');
|
||||
if (p == NULL) {
|
||||
break;
|
||||
}
|
||||
@ -1062,13 +1062,13 @@ static void find_prefix(matchinf_T *mip, int mode)
|
||||
int wlen = 0;
|
||||
slang_T *slang = mip->mi_lp->lp_slang;
|
||||
|
||||
char_u *byts = (char_u *)slang->sl_pbyts;
|
||||
uint8_t *byts = (uint8_t *)slang->sl_pbyts;
|
||||
if (byts == NULL) {
|
||||
return; // array is empty
|
||||
}
|
||||
// We use the case-folded word here, since prefixes are always
|
||||
// case-folded.
|
||||
char_u *ptr = (char_u *)mip->mi_fword;
|
||||
char *ptr = mip->mi_fword;
|
||||
int flen = mip->mi_fwordlen; // available case-folded bytes
|
||||
if (mode == FIND_COMPOUND) {
|
||||
// Skip over the previously found word(s).
|
||||
@ -1126,7 +1126,7 @@ static void find_prefix(matchinf_T *mip, int mode)
|
||||
}
|
||||
|
||||
// Perform a binary search in the list of accepted bytes.
|
||||
int c = ptr[wlen];
|
||||
int c = (uint8_t)ptr[wlen];
|
||||
idx_T lo = arridx;
|
||||
idx_T hi = arridx + len - 1;
|
||||
while (lo < hi) {
|
||||
@ -1483,9 +1483,9 @@ theend:
|
||||
// to skip those bytes if the word was OK.
|
||||
void spell_cat_line(char *buf, char *line, int maxlen)
|
||||
{
|
||||
char_u *p = (char_u *)skipwhite(line);
|
||||
char *p = skipwhite(line);
|
||||
while (vim_strchr("*#/\"\t", (uint8_t)(*p)) != NULL) {
|
||||
p = (char_u *)skipwhite((char *)p + 1);
|
||||
p = skipwhite(p + 1);
|
||||
}
|
||||
|
||||
if (*p == NUL) {
|
||||
@ -1494,10 +1494,10 @@ void spell_cat_line(char *buf, char *line, int maxlen)
|
||||
|
||||
// Only worth concatenating if there is something else than spaces to
|
||||
// concatenate.
|
||||
int n = (int)(p - (char_u *)line) + 1;
|
||||
int n = (int)(p - line) + 1;
|
||||
if (n < maxlen - 1) {
|
||||
memset(buf, ' ', (size_t)n);
|
||||
xstrlcpy(buf + n, (char *)p, (size_t)(maxlen - n));
|
||||
xstrlcpy(buf + n, p, (size_t)(maxlen - n));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1775,7 +1775,7 @@ bool byte_in_str(uint8_t *str, int n)
|
||||
int init_syl_tab(slang_T *slang)
|
||||
{
|
||||
ga_init(&slang->sl_syl_items, sizeof(syl_item_T), 4);
|
||||
char *p = vim_strchr((char *)slang->sl_syllable, '/');
|
||||
char *p = vim_strchr(slang->sl_syllable, '/');
|
||||
while (p != NULL) {
|
||||
*p++ = NUL;
|
||||
if (*p == NUL) { // trailing slash
|
||||
@ -1838,7 +1838,7 @@ static int count_syllables(slang_T *slang, const char *word)
|
||||
// No recognized syllable item, at least a syllable char then?
|
||||
int c = utf_ptr2char(p);
|
||||
len = utfc_ptr2len(p);
|
||||
if (vim_strchr((char *)slang->sl_syllable, c) == NULL) {
|
||||
if (vim_strchr(slang->sl_syllable, c) == NULL) {
|
||||
skip = false; // No, search for next syllable
|
||||
} else if (!skip) {
|
||||
cnt++; // Yes, count it
|
||||
@ -2167,7 +2167,7 @@ static void use_midword(slang_T *lp, win_T *wp)
|
||||
return;
|
||||
}
|
||||
|
||||
for (char *p = (char *)lp->sl_midword; *p != NUL;) {
|
||||
for (char *p = lp->sl_midword; *p != NUL;) {
|
||||
const int c = utf_ptr2char(p);
|
||||
const int l = utfc_ptr2len(p);
|
||||
if (c < 256 && l <= 2) {
|
||||
@ -2660,24 +2660,24 @@ void onecap_copy(char *word, char *wcopy, bool upper)
|
||||
// "wcopy[MAXWLEN]". The result is NUL terminated.
|
||||
void allcap_copy(char *word, char *wcopy)
|
||||
{
|
||||
char_u *d = (char_u *)wcopy;
|
||||
char *d = wcopy;
|
||||
for (char *s = word; *s != NUL;) {
|
||||
int c = mb_cptr2char_adv((const char **)&s);
|
||||
|
||||
if (c == 0xdf) {
|
||||
c = 'S';
|
||||
if (d - (char_u *)wcopy >= MAXWLEN - 1) {
|
||||
if (d - wcopy >= MAXWLEN - 1) {
|
||||
break;
|
||||
}
|
||||
*d++ = (char_u)c;
|
||||
*d++ = (char)c;
|
||||
} else {
|
||||
c = SPELL_TOUPPER(c);
|
||||
}
|
||||
|
||||
if (d - (char_u *)wcopy >= MAXWLEN - MB_MAXBYTES) {
|
||||
if (d - wcopy >= MAXWLEN - MB_MAXBYTES) {
|
||||
break;
|
||||
}
|
||||
d += utf_char2bytes(c, (char *)d);
|
||||
d += utf_char2bytes(c, d);
|
||||
}
|
||||
*d = NUL;
|
||||
}
|
||||
@ -2846,7 +2846,7 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
// But keep white space.
|
||||
int wordlen = 0;
|
||||
for (const char *s = (char *)inword; *s != NUL;) {
|
||||
const char_u *t = (char_u *)s;
|
||||
const char *t = s;
|
||||
int c = mb_cptr2char_adv(&s);
|
||||
if (slang->sl_rem_accents) {
|
||||
if (utf_class(c) == 0) {
|
||||
@ -2857,7 +2857,7 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
did_white = true;
|
||||
} else {
|
||||
did_white = false;
|
||||
if (!spell_iswordp_nmw((char *)t, curwin)) {
|
||||
if (!spell_iswordp_nmw(t, curwin)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -2914,10 +2914,10 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
}
|
||||
k++;
|
||||
}
|
||||
char_u *s = (char_u *)smp[n].sm_rules;
|
||||
char *s = smp[n].sm_rules;
|
||||
pri = 5; // default priority
|
||||
|
||||
p0 = *s;
|
||||
p0 = (uint8_t)(*s);
|
||||
k0 = k;
|
||||
while (*s == '-' && k > 1) {
|
||||
k--;
|
||||
@ -2928,7 +2928,7 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
}
|
||||
if (ascii_isdigit(*s)) {
|
||||
// determine priority
|
||||
pri = *s - '0';
|
||||
pri = (uint8_t)(*s) - '0';
|
||||
s++;
|
||||
}
|
||||
if (*s == '^' && *(s + 1) == '^') {
|
||||
@ -2991,7 +2991,7 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
}
|
||||
|
||||
p0 = 5;
|
||||
s = (char_u *)smp[n0].sm_rules;
|
||||
s = smp[n0].sm_rules;
|
||||
while (*s == '-') {
|
||||
// "k0" gets NOT reduced because
|
||||
// "if (k0 == k)"
|
||||
@ -3001,7 +3001,7 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
s++;
|
||||
}
|
||||
if (ascii_isdigit(*s)) {
|
||||
p0 = *s - '0';
|
||||
p0 = (uint8_t)(*s) - '0';
|
||||
s++;
|
||||
}
|
||||
|
||||
@ -3032,8 +3032,8 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
|
||||
// replace string
|
||||
ws = smp[n].sm_to_w;
|
||||
s = (char_u *)smp[n].sm_rules;
|
||||
p0 = (vim_strchr((char *)s, '<') != NULL) ? 1 : 0;
|
||||
s = smp[n].sm_rules;
|
||||
p0 = (vim_strchr(s, '<') != NULL) ? 1 : 0;
|
||||
if (p0 == 1 && z == 0) {
|
||||
// rule with '<' is used
|
||||
if (reslen > 0 && ws != NULL && *ws != NUL
|
||||
@ -3076,7 +3076,7 @@ static void spell_soundfold_wsal(slang_T *slang, const char *inword, char *res)
|
||||
} else {
|
||||
c = *ws;
|
||||
}
|
||||
if (strstr((char *)s, "^^") != NULL) {
|
||||
if (strstr(s, "^^") != NULL) {
|
||||
if (c != NUL) {
|
||||
wres[reslen++] = c;
|
||||
}
|
||||
@ -3462,7 +3462,7 @@ static linenr_T dump_prefixes(slang_T *slang, char *word, char *pat, Direction *
|
||||
has_word_up = true;
|
||||
}
|
||||
|
||||
char_u *byts = (char_u *)slang->sl_pbyts;
|
||||
char *byts = slang->sl_pbyts;
|
||||
idx_T *idxs = slang->sl_pidxs;
|
||||
if (byts != NULL) { // array not is empty
|
||||
// Loop over all prefixes, building them byte-by-byte in prefix[].
|
||||
@ -3472,7 +3472,7 @@ static linenr_T dump_prefixes(slang_T *slang, char *word, char *pat, Direction *
|
||||
curi[0] = 1;
|
||||
while (depth >= 0 && !got_int) {
|
||||
int n = arridx[depth];
|
||||
int len = byts[n];
|
||||
int len = (uint8_t)byts[n];
|
||||
if (curi[depth] > len) {
|
||||
// Done all bytes at this node, go up one level.
|
||||
depth--;
|
||||
@ -3481,7 +3481,7 @@ static linenr_T dump_prefixes(slang_T *slang, char *word, char *pat, Direction *
|
||||
// Do one more byte at this node.
|
||||
n += curi[depth];
|
||||
curi[depth]++;
|
||||
c = byts[n];
|
||||
c = (uint8_t)byts[n];
|
||||
if (c == 0) {
|
||||
// End of prefix, find out how many IDs there are.
|
||||
int i;
|
||||
|
@ -82,7 +82,7 @@ typedef struct fromto_S {
|
||||
typedef struct salitem_S {
|
||||
char *sm_lead; // leading letters
|
||||
int sm_leadlen; // length of "sm_lead"
|
||||
char_u *sm_oneof; // letters from () or NULL
|
||||
char *sm_oneof; // letters from () or NULL
|
||||
char *sm_rules; // rules like ^, $, priority
|
||||
char *sm_to; // replacement.
|
||||
int *sm_lead_w; // wide character copy of "sm_lead"
|
||||
@ -119,20 +119,20 @@ struct slang_S {
|
||||
char *sl_fname; // name of .spl file
|
||||
bool sl_add; // true if it's a .add file.
|
||||
|
||||
char *sl_fbyts; // case-folded word bytes
|
||||
long sl_fbyts_len; // length of sl_fbyts
|
||||
idx_T *sl_fidxs; // case-folded word indexes
|
||||
char *sl_kbyts; // keep-case word bytes
|
||||
idx_T *sl_kidxs; // keep-case word indexes
|
||||
char *sl_pbyts; // prefix tree word bytes
|
||||
idx_T *sl_pidxs; // prefix tree word indexes
|
||||
char *sl_fbyts; // case-folded word bytes
|
||||
long sl_fbyts_len; // length of sl_fbyts
|
||||
idx_T *sl_fidxs; // case-folded word indexes
|
||||
char *sl_kbyts; // keep-case word bytes
|
||||
idx_T *sl_kidxs; // keep-case word indexes
|
||||
char *sl_pbyts; // prefix tree word bytes
|
||||
idx_T *sl_pidxs; // prefix tree word indexes
|
||||
|
||||
char_u *sl_info; // infotext string or NULL
|
||||
char *sl_info; // infotext string or NULL
|
||||
|
||||
char sl_regions[MAXREGIONS * 2 + 1];
|
||||
// table with up to 8 region names plus NUL
|
||||
|
||||
char_u *sl_midword; // MIDWORD string or NULL
|
||||
char *sl_midword; // MIDWORD string or NULL
|
||||
|
||||
hashtab_T sl_wordcount; // hashtable with word count, wordcount_T
|
||||
|
||||
@ -141,13 +141,13 @@ struct slang_S {
|
||||
int sl_compsylmax; // COMPOUNDSYLMAX (default: MAXWLEN)
|
||||
int sl_compoptions; // COMP_* flags
|
||||
garray_T sl_comppat; // CHECKCOMPOUNDPATTERN items
|
||||
regprog_T *sl_compprog; // COMPOUNDRULE turned into a regexp progrm
|
||||
// (NULL when no compounding)
|
||||
regprog_T *sl_compprog; // COMPOUNDRULE turned into a regexp progrm
|
||||
// (NULL when no compounding)
|
||||
uint8_t *sl_comprules; // all COMPOUNDRULE concatenated (or NULL)
|
||||
uint8_t *sl_compstartflags; // flags for first compound word
|
||||
uint8_t *sl_compallflags; // all flags for compound words
|
||||
bool sl_nobreak; // When true: no spaces between words
|
||||
char_u *sl_syllable; // SYLLABLE repeatable chars or NULL
|
||||
char *sl_syllable; // SYLLABLE repeatable chars or NULL
|
||||
garray_T sl_syl_items; // syllable items
|
||||
|
||||
int sl_prefixcnt; // number of items in "sl_prefprog"
|
||||
|
@ -386,7 +386,7 @@ typedef struct affheader_S {
|
||||
|
||||
// Flag used in compound items.
|
||||
typedef struct compitem_S {
|
||||
char_u ci_key[AH_KEY_LEN]; // key for hashtab == name of compound
|
||||
char ci_key[AH_KEY_LEN]; // key for hashtab == name of compound
|
||||
unsigned ci_flag; // affix name as number, uses "af_flagtype"
|
||||
int ci_newID; // affix ID after renumbering.
|
||||
} compitem_T;
|
||||
@ -674,7 +674,7 @@ slang_T *spell_load_file(char *fname, char *lang, slang_T *old_lp, bool silent)
|
||||
res = 0;
|
||||
switch (n) {
|
||||
case SN_INFO:
|
||||
lp->sl_info = READ_STRING(fd, len); // <infotext>
|
||||
lp->sl_info = read_string(fd, (size_t)len); // <infotext>
|
||||
if (lp->sl_info == NULL) {
|
||||
goto endFAIL;
|
||||
}
|
||||
@ -689,7 +689,7 @@ slang_T *spell_load_file(char *fname, char *lang, slang_T *old_lp, bool silent)
|
||||
break;
|
||||
|
||||
case SN_MIDWORD:
|
||||
lp->sl_midword = READ_STRING(fd, len); // <midword>
|
||||
lp->sl_midword = read_string(fd, (size_t)len); // <midword>
|
||||
if (lp->sl_midword == NULL) {
|
||||
goto endFAIL;
|
||||
}
|
||||
@ -716,7 +716,7 @@ slang_T *spell_load_file(char *fname, char *lang, slang_T *old_lp, bool silent)
|
||||
break;
|
||||
|
||||
case SN_MAP:
|
||||
p = (char *)READ_STRING(fd, len); // <mapstr>
|
||||
p = read_string(fd, (size_t)len); // <mapstr>
|
||||
if (p == NULL) {
|
||||
goto endFAIL;
|
||||
}
|
||||
@ -749,7 +749,7 @@ slang_T *spell_load_file(char *fname, char *lang, slang_T *old_lp, bool silent)
|
||||
break;
|
||||
|
||||
case SN_SYLLABLE:
|
||||
lp->sl_syllable = READ_STRING(fd, len); // <syllable>
|
||||
lp->sl_syllable = read_string(fd, (size_t)len); // <syllable>
|
||||
if (lp->sl_syllable == NULL) {
|
||||
goto endFAIL;
|
||||
}
|
||||
@ -838,8 +838,9 @@ endOK:
|
||||
|
||||
// Fill in the wordcount fields for a trie.
|
||||
// Returns the total number of words.
|
||||
static void tree_count_words(const char_u *byts, idx_T *idxs)
|
||||
static void tree_count_words(const char *byts_in, idx_T *idxs)
|
||||
{
|
||||
const uint8_t *byts= (const uint8_t *)byts_in;
|
||||
int depth;
|
||||
idx_T arridx[MAXWLEN];
|
||||
int curi[MAXWLEN];
|
||||
@ -1000,8 +1001,8 @@ someerror:
|
||||
|
||||
// Need to put word counts in the word tries, so that we can find
|
||||
// a word by its number.
|
||||
tree_count_words((char_u *)slang->sl_fbyts, slang->sl_fidxs);
|
||||
tree_count_words((char_u *)slang->sl_sbyts, slang->sl_sidxs);
|
||||
tree_count_words(slang->sl_fbyts, slang->sl_fidxs);
|
||||
tree_count_words(slang->sl_sbyts, slang->sl_sidxs);
|
||||
|
||||
nextone:
|
||||
if (fd != NULL) {
|
||||
@ -1017,10 +1018,10 @@ nextone:
|
||||
// Returns NULL when the count is zero.
|
||||
// Sets "*cntp" to SP_*ERROR when there is an error, length of the result
|
||||
// otherwise.
|
||||
static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
|
||||
static char *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
|
||||
{
|
||||
int cnt = 0;
|
||||
char_u *str;
|
||||
char *str;
|
||||
|
||||
// read the length bytes, MSB first
|
||||
for (int i = 0; i < cnt_bytes; i++) {
|
||||
@ -1036,7 +1037,7 @@ static char_u *read_cnt_string(FILE *fd, int cnt_bytes, int *cntp)
|
||||
if (cnt == 0) {
|
||||
return NULL; // nothing to read, return NULL
|
||||
}
|
||||
str = READ_STRING(fd, cnt);
|
||||
str = read_string(fd, (size_t)cnt);
|
||||
if (str == NULL) {
|
||||
*cntp = SP_OTHERERROR;
|
||||
}
|
||||
@ -1065,13 +1066,13 @@ static int read_charflags_section(FILE *fd)
|
||||
int flagslen, follen;
|
||||
|
||||
// <charflagslen> <charflags>
|
||||
flags = (char *)read_cnt_string(fd, 1, &flagslen);
|
||||
flags = read_cnt_string(fd, 1, &flagslen);
|
||||
if (flagslen < 0) {
|
||||
return flagslen;
|
||||
}
|
||||
|
||||
// <folcharslen> <folchars>
|
||||
fol = read_cnt_string(fd, 2, &follen);
|
||||
fol = (char_u *)read_cnt_string(fd, 2, &follen);
|
||||
if (follen < 0) {
|
||||
xfree(flags);
|
||||
return follen;
|
||||
@ -1143,14 +1144,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 = (char *)read_cnt_string(fd, 1, &c);
|
||||
ftp->ft_from = read_cnt_string(fd, 1, &c);
|
||||
if (c < 0) {
|
||||
return c;
|
||||
}
|
||||
if (c == 0) {
|
||||
return SP_FORMERROR;
|
||||
}
|
||||
ftp->ft_to = (char *)read_cnt_string(fd, 1, &c);
|
||||
ftp->ft_to = read_cnt_string(fd, 1, &c);
|
||||
if (c <= 0) {
|
||||
xfree(ftp->ft_from);
|
||||
if (c < 0) {
|
||||
@ -1181,7 +1182,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
garray_T *gap;
|
||||
salitem_T *smp;
|
||||
int ccnt;
|
||||
char_u *p;
|
||||
char *p;
|
||||
|
||||
slang->sl_sofo = false;
|
||||
|
||||
@ -1215,7 +1216,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
return SP_TRUNCERROR;
|
||||
}
|
||||
p = xmalloc((size_t)ccnt + 2);
|
||||
smp->sm_lead = (char *)p;
|
||||
smp->sm_lead = p;
|
||||
|
||||
// Read up to the first special char into sm_lead.
|
||||
int i = 0;
|
||||
@ -1224,9 +1225,9 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
if (vim_strchr("0123456789(-<^$", c) != NULL) {
|
||||
break;
|
||||
}
|
||||
*p++ = (char_u)c;
|
||||
*p++ = (char)(uint8_t)c;
|
||||
}
|
||||
smp->sm_leadlen = (int)(p - (char_u *)smp->sm_lead);
|
||||
smp->sm_leadlen = (int)(p - smp->sm_lead);
|
||||
*p++ = NUL;
|
||||
|
||||
// Put (abc) chars in sm_oneof, if any.
|
||||
@ -1237,7 +1238,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
if (c == ')') {
|
||||
break;
|
||||
}
|
||||
*p++ = (char_u)c;
|
||||
*p++ = (char)(uint8_t)c;
|
||||
}
|
||||
*p++ = NUL;
|
||||
if (++i < ccnt) {
|
||||
@ -1248,22 +1249,22 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
}
|
||||
|
||||
// Any following chars go in sm_rules.
|
||||
smp->sm_rules = (char *)p;
|
||||
smp->sm_rules = p;
|
||||
if (i < ccnt) {
|
||||
// store the char we got while checking for end of sm_lead
|
||||
*p++ = (char_u)c;
|
||||
*p++ = (char)(uint8_t)c;
|
||||
}
|
||||
i++;
|
||||
if (i < ccnt) {
|
||||
SPELL_READ_NONNUL_BYTES( // <salfrom>
|
||||
(char *)p, (size_t)(ccnt - i), fd,
|
||||
p, (size_t)(ccnt - i), fd,
|
||||
xfree(smp->sm_lead));
|
||||
p += (ccnt - i);
|
||||
}
|
||||
*p++ = NUL;
|
||||
|
||||
// <saltolen> <salto>
|
||||
smp->sm_to = (char *)read_cnt_string(fd, 1, &ccnt);
|
||||
smp->sm_to = read_cnt_string(fd, 1, &ccnt);
|
||||
if (ccnt < 0) {
|
||||
xfree(smp->sm_lead);
|
||||
return ccnt;
|
||||
@ -1275,7 +1276,7 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
if (smp->sm_oneof == NULL) {
|
||||
smp->sm_oneof_w = NULL;
|
||||
} else {
|
||||
smp->sm_oneof_w = mb_str2wide((char *)smp->sm_oneof);
|
||||
smp->sm_oneof_w = mb_str2wide(smp->sm_oneof);
|
||||
}
|
||||
if (smp->sm_to == NULL) {
|
||||
smp->sm_to_w = NULL;
|
||||
@ -1290,12 +1291,12 @@ static int read_sal_section(FILE *fd, slang_T *slang)
|
||||
smp = &((salitem_T *)gap->ga_data)[gap->ga_len];
|
||||
p = xmalloc(1);
|
||||
p[0] = NUL;
|
||||
smp->sm_lead = (char *)p;
|
||||
smp->sm_lead = p;
|
||||
smp->sm_lead_w = mb_str2wide(smp->sm_lead);
|
||||
smp->sm_leadlen = 0;
|
||||
smp->sm_oneof = NULL;
|
||||
smp->sm_oneof_w = NULL;
|
||||
smp->sm_rules = (char *)p;
|
||||
smp->sm_rules = p;
|
||||
smp->sm_to = NULL;
|
||||
smp->sm_to_w = NULL;
|
||||
gap->ga_len++;
|
||||
@ -1350,13 +1351,13 @@ static int read_sofo_section(FILE *fd, slang_T *slang)
|
||||
slang->sl_sofo = true;
|
||||
|
||||
// <sofofromlen> <sofofrom>
|
||||
from = (char *)read_cnt_string(fd, 2, &cnt);
|
||||
from = read_cnt_string(fd, 2, &cnt);
|
||||
if (cnt < 0) {
|
||||
return cnt;
|
||||
}
|
||||
|
||||
// <sofotolen> <sofoto>
|
||||
to = (char *)read_cnt_string(fd, 2, &cnt);
|
||||
to = read_cnt_string(fd, 2, &cnt);
|
||||
if (cnt < 0) {
|
||||
xfree(from);
|
||||
return cnt;
|
||||
@ -1428,7 +1429,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
|
||||
ga_init(gap, sizeof(char *), c);
|
||||
ga_grow(gap, c);
|
||||
while (--c >= 0) {
|
||||
((char **)(gap->ga_data))[gap->ga_len++] = (char *)read_cnt_string(fd, 1, &cnt);
|
||||
((char **)(gap->ga_data))[gap->ga_len++] = read_cnt_string(fd, 1, &cnt);
|
||||
// <comppatlen> <comppattext>
|
||||
if (cnt < 0) {
|
||||
return cnt;
|
||||
@ -1464,7 +1465,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
|
||||
uint8_t *crp = xmalloc((size_t)todo + 1);
|
||||
slang->sl_comprules = crp;
|
||||
|
||||
char_u *pp = (char_u *)pat;
|
||||
char *pp = pat;
|
||||
*pp++ = '^';
|
||||
*pp++ = '\\';
|
||||
*pp++ = '(';
|
||||
@ -1520,7 +1521,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
|
||||
if (c == '?' || c == '+' || c == '~') {
|
||||
*pp++ = '\\'; // "a?" becomes "a\?", "a+" becomes "a\+"
|
||||
}
|
||||
pp += utf_char2bytes(c, (char *)pp);
|
||||
pp += utf_char2bytes(c, pp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1954,9 +1955,9 @@ static void spell_print_node(wordnode_T *node, int depth)
|
||||
PRINTSOME(line1, depth, "(%d)", node->wn_nr, 0);
|
||||
PRINTSOME(line2, depth, " ", 0, 0);
|
||||
PRINTSOME(line3, depth, " ", 0, 0);
|
||||
msg((char_u *)line1);
|
||||
msg((char_u *)line2);
|
||||
msg((char_u *)line3);
|
||||
msg(line1);
|
||||
msg(line2);
|
||||
msg(line3);
|
||||
} else {
|
||||
node->wn_u1.index = true;
|
||||
|
||||
@ -1980,9 +1981,9 @@ static void spell_print_node(wordnode_T *node, int depth)
|
||||
}
|
||||
|
||||
if (node->wn_byte == NUL) {
|
||||
msg((char_u *)line1);
|
||||
msg((char_u *)line2);
|
||||
msg((char_u *)line3);
|
||||
msg(line1);
|
||||
msg(line2);
|
||||
msg(line3);
|
||||
}
|
||||
|
||||
// do the children
|
||||
@ -2789,7 +2790,7 @@ static void aff_process_flags(afffile_T *affile, affentry_T *entry)
|
||||
char_u *prevp = (char_u *)p;
|
||||
unsigned flag = get_affitem(affile->af_flagtype, &p);
|
||||
if (flag == affile->af_comppermit || flag == affile->af_compforbid) {
|
||||
STRMOVE(prevp, (char *)p);
|
||||
STRMOVE(prevp, p);
|
||||
p = (char *)prevp;
|
||||
if (flag == affile->af_comppermit) {
|
||||
entry->ae_comppermit = true;
|
||||
@ -2925,9 +2926,9 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char *compflags
|
||||
id = spin->si_newcompID--;
|
||||
} while (vim_strchr("/?*+[]\\-^", id) != NULL);
|
||||
ci->ci_newID = id;
|
||||
hash_add(&aff->af_comp, (char *)ci->ci_key);
|
||||
hash_add(&aff->af_comp, ci->ci_key);
|
||||
}
|
||||
*tp++ = (char_u)id;
|
||||
*tp++ = (uint8_t)id;
|
||||
}
|
||||
if (aff->af_flagtype == AFT_NUM && *p == ',') {
|
||||
p++;
|
||||
@ -3079,21 +3080,21 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
{
|
||||
hashtab_T ht;
|
||||
char line[MAXLINELEN];
|
||||
char_u *p;
|
||||
char_u *afflist;
|
||||
char_u store_afflist[MAXWLEN];
|
||||
char *p;
|
||||
char *afflist;
|
||||
char store_afflist[MAXWLEN];
|
||||
int pfxlen;
|
||||
bool need_affix;
|
||||
char *dw;
|
||||
char_u *pc;
|
||||
char_u *w;
|
||||
char *pc;
|
||||
char *w;
|
||||
int l;
|
||||
hash_T hash;
|
||||
hashitem_T *hi;
|
||||
int lnum = 1;
|
||||
int non_ascii = 0;
|
||||
int retval = OK;
|
||||
char_u message[MAXLINELEN + MAXWLEN];
|
||||
char message[MAXLINELEN + MAXWLEN];
|
||||
int flags;
|
||||
int duplicate = 0;
|
||||
Timestamp last_msg_time = 0;
|
||||
@ -3142,7 +3143,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
|
||||
// Convert from "SET" to 'encoding' when needed.
|
||||
if (spin->si_conv.vc_type != CONV_NONE) {
|
||||
pc = (char_u *)string_convert(&spin->si_conv, (char *)line, NULL);
|
||||
pc = string_convert(&spin->si_conv, (char *)line, NULL);
|
||||
if (pc == NULL) {
|
||||
smsg(_("Conversion failure for word in %s line %d: %s"),
|
||||
fname, lnum, line);
|
||||
@ -3151,7 +3152,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
w = pc;
|
||||
} else {
|
||||
pc = NULL;
|
||||
w = (char_u *)line;
|
||||
w = line;
|
||||
}
|
||||
|
||||
// Truncate the word at the "/", set "afflist" to what follows.
|
||||
@ -3159,7 +3160,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
afflist = NULL;
|
||||
for (p = w; *p != NUL; MB_PTR_ADV(p)) {
|
||||
if (*p == '\\' && (p[1] == '\\' || p[1] == '/')) {
|
||||
STRMOVE(p, (char *)p + 1);
|
||||
STRMOVE(p, p + 1);
|
||||
} else if (*p == '/') {
|
||||
*p = NUL;
|
||||
afflist = p + 1;
|
||||
@ -3168,7 +3169,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
}
|
||||
|
||||
// Skip non-ASCII words when "spin->si_ascii" is true.
|
||||
if (spin->si_ascii && has_non_ascii((char *)w)) {
|
||||
if (spin->si_ascii && has_non_ascii(w)) {
|
||||
non_ascii++;
|
||||
xfree(pc);
|
||||
continue;
|
||||
@ -3180,11 +3181,11 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
spin->si_msg_count = 0;
|
||||
if (os_time() > last_msg_time) {
|
||||
last_msg_time = os_time();
|
||||
vim_snprintf((char *)message, sizeof(message),
|
||||
vim_snprintf(message, sizeof(message),
|
||||
_("line %6d, word %6ld - %s"),
|
||||
lnum, spin->si_foldwcount + spin->si_keepwcount, w);
|
||||
msg_start();
|
||||
msg_outtrans_long_attr((char *)message, 0);
|
||||
msg_outtrans_long_attr(message, 0);
|
||||
msg_clr_eos();
|
||||
msg_didout = false;
|
||||
msg_col = 0;
|
||||
@ -3193,7 +3194,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
}
|
||||
|
||||
// Store the word in the hashtable to be able to find duplicates.
|
||||
dw = getroom_save(spin, (char *)w);
|
||||
dw = getroom_save(spin, w);
|
||||
if (dw == NULL) {
|
||||
retval = FAIL;
|
||||
xfree(pc);
|
||||
@ -3201,7 +3202,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
}
|
||||
|
||||
hash = hash_hash(dw);
|
||||
hi = hash_lookup(&ht, (const char *)dw, strlen(dw), hash);
|
||||
hi = hash_lookup(&ht, dw, strlen(dw), hash);
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
if (p_verbose > 0) {
|
||||
smsg(_("Duplicate word in %s line %d: %s"),
|
||||
@ -3221,45 +3222,45 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
|
||||
need_affix = false;
|
||||
if (afflist != NULL) {
|
||||
// Extract flags from the affix list.
|
||||
flags |= get_affix_flags(affile, (char *)afflist);
|
||||
flags |= get_affix_flags(affile, afflist);
|
||||
|
||||
if (affile->af_needaffix != 0
|
||||
&& flag_in_afflist(affile->af_flagtype, (char *)afflist,
|
||||
&& flag_in_afflist(affile->af_flagtype, afflist,
|
||||
affile->af_needaffix)) {
|
||||
need_affix = true;
|
||||
}
|
||||
|
||||
if (affile->af_pfxpostpone) {
|
||||
// Need to store the list of prefix IDs with the word.
|
||||
pfxlen = get_pfxlist(affile, (char *)afflist, store_afflist);
|
||||
pfxlen = get_pfxlist(affile, afflist, store_afflist);
|
||||
}
|
||||
|
||||
if (spin->si_compflags != NULL) {
|
||||
// Need to store the list of compound flags with the word.
|
||||
// Concatenate them to the list of prefix IDs.
|
||||
get_compflags(affile, (char *)afflist, store_afflist + pfxlen);
|
||||
get_compflags(affile, afflist, (char_u *)store_afflist + pfxlen);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the word to the word tree(s).
|
||||
if (store_word(spin, dw, flags, spin->si_region,
|
||||
(char *)store_afflist, need_affix) == FAIL) {
|
||||
store_afflist, need_affix) == FAIL) {
|
||||
retval = FAIL;
|
||||
}
|
||||
|
||||
if (afflist != NULL) {
|
||||
// Find all matching suffixes and add the resulting words.
|
||||
// Additionally do matching prefixes that combine.
|
||||
if (store_aff_word(spin, dw, (char *)afflist, affile,
|
||||
if (store_aff_word(spin, dw, afflist, affile,
|
||||
&affile->af_suff, &affile->af_pref,
|
||||
CONDIT_SUF, flags, (char *)store_afflist, pfxlen) == FAIL) {
|
||||
CONDIT_SUF, flags, store_afflist, pfxlen) == FAIL) {
|
||||
retval = FAIL;
|
||||
}
|
||||
|
||||
// Find all matching prefixes and add the resulting words.
|
||||
if (store_aff_word(spin, dw, (char *)afflist, affile,
|
||||
if (store_aff_word(spin, dw, afflist, affile,
|
||||
&affile->af_pref, NULL,
|
||||
CONDIT_SUF, flags, (char *)store_afflist, pfxlen) == FAIL) {
|
||||
CONDIT_SUF, flags, store_afflist, pfxlen) == FAIL) {
|
||||
retval = FAIL;
|
||||
}
|
||||
}
|
||||
@ -3321,7 +3322,7 @@ static int get_affix_flags(afffile_T *affile, char *afflist)
|
||||
// Used for PFXPOSTPONE.
|
||||
// Put the resulting flags in "store_afflist[MAXWLEN]" with a terminating NUL
|
||||
// and return the number of affixes.
|
||||
static int get_pfxlist(afffile_T *affile, char *afflist, char_u *store_afflist)
|
||||
static int get_pfxlist(afffile_T *affile, char *afflist, char *store_afflist)
|
||||
{
|
||||
int cnt = 0;
|
||||
int id;
|
||||
@ -3338,7 +3339,7 @@ static int get_pfxlist(afffile_T *affile, char *afflist, char_u *store_afflist)
|
||||
if (!HASHITEM_EMPTY(hi)) {
|
||||
id = HI2AH(hi)->ah_newID;
|
||||
if (id != 0) {
|
||||
store_afflist[cnt++] = (char_u)id;
|
||||
store_afflist[cnt++] = (char)(uint8_t)id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3408,7 +3409,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_
|
||||
char *use_pfxlist;
|
||||
int use_pfxlen;
|
||||
bool need_affix;
|
||||
char_u store_afflist[MAXWLEN];
|
||||
char store_afflist[MAXWLEN];
|
||||
char pfx_pfxlist[MAXWLEN];
|
||||
size_t wordlen = strlen(word);
|
||||
int use_condit;
|
||||
@ -3517,7 +3518,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_
|
||||
} else {
|
||||
use_pfxlen = 0;
|
||||
}
|
||||
use_pfxlist = (char *)store_afflist;
|
||||
use_pfxlist = store_afflist;
|
||||
|
||||
// Combine the prefix IDs. Avoid adding the
|
||||
// same ID twice.
|
||||
@ -3642,7 +3643,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
|
||||
long lnum = 0;
|
||||
char rline[MAXLINELEN];
|
||||
char *line;
|
||||
char_u *pc = NULL;
|
||||
char *pc = NULL;
|
||||
char_u *p;
|
||||
int l;
|
||||
int retval = OK;
|
||||
@ -3684,13 +3685,13 @@ static int spell_read_wordfile(spellinfo_T *spin, char *fname)
|
||||
// Convert from "/encoding={encoding}" to 'encoding' when needed.
|
||||
xfree(pc);
|
||||
if (spin->si_conv.vc_type != CONV_NONE) {
|
||||
pc = (char_u *)string_convert(&spin->si_conv, rline, NULL);
|
||||
pc = string_convert(&spin->si_conv, rline, NULL);
|
||||
if (pc == NULL) {
|
||||
smsg(_("Conversion failure for word in %s line %ld: %s"),
|
||||
fname, lnum, rline);
|
||||
continue;
|
||||
}
|
||||
line = (char *)pc;
|
||||
line = pc;
|
||||
} else {
|
||||
pc = NULL;
|
||||
line = rline;
|
||||
@ -3907,7 +3908,7 @@ static int store_word(spellinfo_T *spin, char *word, int flags, int region, cons
|
||||
{
|
||||
int len = (int)strlen(word);
|
||||
int ct = captype(word, word + len);
|
||||
char_u foldword[MAXWLEN];
|
||||
char foldword[MAXWLEN];
|
||||
int res = OK;
|
||||
|
||||
// Avoid adding illegal bytes to the word tree.
|
||||
@ -3915,10 +3916,10 @@ static int store_word(spellinfo_T *spin, char *word, int flags, int region, cons
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
(void)spell_casefold(curwin, word, len, (char *)foldword, MAXWLEN);
|
||||
(void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
|
||||
for (const char_u *p = (char_u *)pfxlist; res == OK; p++) {
|
||||
if (!need_affix || (p != NULL && *p != NUL)) {
|
||||
res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
|
||||
res = tree_add_word(spin, (char_u *)foldword, spin->si_foldroot, ct | flags,
|
||||
region, p == NULL ? 0 : *p);
|
||||
}
|
||||
if (p == NULL || *p == NUL) {
|
||||
|
@ -74,9 +74,9 @@ typedef struct suginfo_S {
|
||||
char *su_badptr; ///< start of bad word in line
|
||||
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 su_badword[MAXWLEN]; ///< bad word truncated at su_badlen
|
||||
char su_fbadword[MAXWLEN]; ///< su_badword case-folded
|
||||
char_u su_sal_badword[MAXWLEN]; ///< su_badword soundfolded
|
||||
char su_sal_badword[MAXWLEN]; ///< su_badword soundfolded
|
||||
hashtab_T su_banned; ///< table with banned words
|
||||
slang_T *su_sallang; ///< default language for sound folding
|
||||
} suginfo_T;
|
||||
@ -269,13 +269,13 @@ static bool can_be_compound(trystate_T *sp, slang_T *slang, char_u *compflags, i
|
||||
/// Adjust the score of common words.
|
||||
///
|
||||
/// @param split word was split, less bonus
|
||||
static int score_wordcount_adj(slang_T *slang, int score, char_u *word, bool split)
|
||||
static int score_wordcount_adj(slang_T *slang, int score, char *word, bool split)
|
||||
{
|
||||
wordcount_T *wc;
|
||||
int bonus;
|
||||
int newscore;
|
||||
|
||||
hashitem_T *hi = hash_find(&slang->sl_wordcount, (char *)word);
|
||||
hashitem_T *hi = hash_find(&slang->sl_wordcount, word);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
return score;
|
||||
}
|
||||
@ -302,14 +302,14 @@ static int score_wordcount_adj(slang_T *slang, int score, char_u *word, bool spl
|
||||
/// Like captype() but for a KEEPCAP word add ONECAP if the word starts with a
|
||||
/// capital. So that make_case_word() can turn WOrd into Word.
|
||||
/// Add ALLCAP for "WOrD".
|
||||
static int badword_captype(char_u *word, char_u *end)
|
||||
static int badword_captype(char *word, char *end)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int flags = captype((char *)word, (char *)end);
|
||||
int flags = captype(word, end);
|
||||
int c;
|
||||
int l, u;
|
||||
bool first;
|
||||
char_u *p;
|
||||
char *p;
|
||||
|
||||
if (!(flags & WF_KEEPCAP)) {
|
||||
return flags;
|
||||
@ -319,7 +319,7 @@ static int badword_captype(char_u *word, char_u *end)
|
||||
l = u = 0;
|
||||
first = false;
|
||||
for (p = word; p < end; MB_PTR_ADV(p)) {
|
||||
c = utf_ptr2char((char *)p);
|
||||
c = utf_ptr2char(p);
|
||||
if (SPELL_ISUPPER(c)) {
|
||||
u++;
|
||||
if (p == word) {
|
||||
@ -351,9 +351,9 @@ static int badword_captype(char_u *word, char_u *end)
|
||||
/// "pp" points to the bytes and is advanced over it.
|
||||
///
|
||||
/// @return the offset.
|
||||
static int bytes2offset(char_u **pp)
|
||||
static int bytes2offset(char **pp)
|
||||
{
|
||||
char_u *p = *pp;
|
||||
char_u *p = (char_u *)(*pp);
|
||||
int nr;
|
||||
int c;
|
||||
|
||||
@ -374,7 +374,7 @@ static int bytes2offset(char_u **pp)
|
||||
nr = nr * 255 + (*p++ - 1);
|
||||
}
|
||||
|
||||
*pp = p;
|
||||
*pp = (char *)p;
|
||||
return nr;
|
||||
}
|
||||
|
||||
@ -401,11 +401,11 @@ int spell_check_sps(void)
|
||||
sps_limit = 9999;
|
||||
|
||||
for (p = p_sps; *p != NUL;) {
|
||||
copy_option_part(&p, (char *)buf, MAXPATHL, ",");
|
||||
copy_option_part(&p, buf, MAXPATHL, ",");
|
||||
|
||||
f = 0;
|
||||
if (ascii_isdigit(*buf)) {
|
||||
s = (char *)buf;
|
||||
s = buf;
|
||||
sps_limit = getdigits_int(&s, true, 0);
|
||||
if (*s != NUL && !ascii_isdigit(*s)) {
|
||||
f = -1;
|
||||
@ -450,7 +450,7 @@ void spell_suggest(int count)
|
||||
char *line;
|
||||
pos_T prev_cursor = curwin->w_cursor;
|
||||
char wcopy[MAXWLEN + 2];
|
||||
char_u *p;
|
||||
char *p;
|
||||
int c;
|
||||
suginfo_T sug;
|
||||
suggest_T *stp;
|
||||
@ -499,21 +499,21 @@ void spell_suggest(int count)
|
||||
// cursor.
|
||||
curwin->w_cursor = prev_cursor;
|
||||
line = get_cursor_line_ptr();
|
||||
p = (char_u *)line + curwin->w_cursor.col;
|
||||
p = line + curwin->w_cursor.col;
|
||||
// Backup to before start of word.
|
||||
while (p > (char_u *)line && spell_iswordp_nmw((char *)p, curwin)) {
|
||||
while (p > line && spell_iswordp_nmw(p, curwin)) {
|
||||
MB_PTR_BACK(line, p);
|
||||
}
|
||||
// Forward to start of word.
|
||||
while (*p != NUL && !spell_iswordp_nmw((char *)p, curwin)) {
|
||||
while (*p != NUL && !spell_iswordp_nmw(p, curwin)) {
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
|
||||
if (!spell_iswordp_nmw((char *)p, curwin)) { // No word found.
|
||||
if (!spell_iswordp_nmw(p, curwin)) { // No word found.
|
||||
beep_flush();
|
||||
return;
|
||||
}
|
||||
curwin->w_cursor.col = (colnr_T)(p - (char_u *)line);
|
||||
curwin->w_cursor.col = (colnr_T)(p - line);
|
||||
}
|
||||
|
||||
// Get the word and its length.
|
||||
@ -532,7 +532,7 @@ void spell_suggest(int count)
|
||||
} else {
|
||||
limit = sps_limit;
|
||||
}
|
||||
spell_find_suggest((char_u *)line + curwin->w_cursor.col, badlen, &sug, limit,
|
||||
spell_find_suggest(line + curwin->w_cursor.col, badlen, &sug, limit,
|
||||
true, need_cap, true);
|
||||
|
||||
if (GA_EMPTY(&sug.su_ga)) {
|
||||
@ -659,12 +659,12 @@ void spell_suggest(int count)
|
||||
// For redo we use a change-word command.
|
||||
ResetRedobuff();
|
||||
AppendToRedobuff("ciw");
|
||||
AppendToRedobuffLit((char *)p + c,
|
||||
AppendToRedobuffLit(p + c,
|
||||
stp->st_wordlen + sug.su_badlen - stp->st_orglen);
|
||||
AppendCharToRedobuff(ESC);
|
||||
|
||||
// "p" may be freed here
|
||||
ml_replace(curwin->w_cursor.lnum, (char *)p, false);
|
||||
ml_replace(curwin->w_cursor.lnum, p, false);
|
||||
curwin->w_cursor.col = c;
|
||||
|
||||
inserted_bytes(curwin->w_cursor.lnum, c, stp->st_orglen, stp->st_wordlen);
|
||||
@ -686,12 +686,12 @@ void spell_suggest_list(garray_T *gap, char *word, int maxcount, bool need_cap,
|
||||
{
|
||||
suginfo_T sug;
|
||||
suggest_T *stp;
|
||||
char_u *wcopy;
|
||||
char *wcopy;
|
||||
|
||||
spell_find_suggest((char_u *)word, 0, &sug, maxcount, false, need_cap, interactive);
|
||||
spell_find_suggest(word, 0, &sug, maxcount, false, need_cap, interactive);
|
||||
|
||||
// Make room in "gap".
|
||||
ga_init(gap, sizeof(char_u *), sug.su_ga.ga_len + 1);
|
||||
ga_init(gap, sizeof(char *), sug.su_ga.ga_len + 1);
|
||||
ga_grow(gap, sug.su_ga.ga_len);
|
||||
for (int i = 0; i < sug.su_ga.ga_len; i++) {
|
||||
stp = &SUG(sug.su_ga, i);
|
||||
@ -701,7 +701,7 @@ void spell_suggest_list(garray_T *gap, char *word, int maxcount, bool need_cap,
|
||||
wcopy = xmalloc((size_t)stp->st_wordlen + strlen(sug.su_badptr + stp->st_orglen) + 1);
|
||||
STRCPY(wcopy, stp->st_word);
|
||||
STRCPY(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen);
|
||||
((char_u **)gap->ga_data)[gap->ga_len++] = wcopy;
|
||||
((char **)gap->ga_data)[gap->ga_len++] = wcopy;
|
||||
}
|
||||
|
||||
spell_find_cleanup(&sug);
|
||||
@ -716,7 +716,7 @@ void spell_suggest_list(garray_T *gap, char *word, int maxcount, bool need_cap,
|
||||
/// @param badlen length of bad word or 0 if unknown
|
||||
/// @param banbadword don't include badword in suggestions
|
||||
/// @param need_cap word should start with capital
|
||||
static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int maxcount,
|
||||
static void spell_find_suggest(char *badptr, int badlen, suginfo_T *su, int maxcount,
|
||||
bool banbadword, bool need_cap, bool interactive)
|
||||
{
|
||||
hlf_T attr = HLF_COUNT;
|
||||
@ -738,7 +738,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
||||
}
|
||||
hash_init(&su->su_banned);
|
||||
|
||||
su->su_badptr = (char *)badptr;
|
||||
su->su_badptr = badptr;
|
||||
if (badlen != 0) {
|
||||
su->su_badlen = badlen;
|
||||
} else {
|
||||
@ -752,7 +752,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
||||
if (su->su_badlen >= MAXWLEN) {
|
||||
su->su_badlen = MAXWLEN - 1; // just in case
|
||||
}
|
||||
xstrlcpy((char *)su->su_badword, su->su_badptr, (size_t)su->su_badlen + 1);
|
||||
xstrlcpy(su->su_badword, su->su_badptr, (size_t)su->su_badlen + 1);
|
||||
(void)spell_casefold(curwin, su->su_badptr, su->su_badlen, su->su_fbadword,
|
||||
MAXWLEN);
|
||||
|
||||
@ -762,8 +762,8 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
||||
su->su_fbadword[su->su_badlen] = NUL;
|
||||
|
||||
// get caps flags for bad word
|
||||
su->su_badflags = badword_captype((char_u *)su->su_badptr,
|
||||
(char_u *)su->su_badptr + su->su_badlen);
|
||||
su->su_badflags = badword_captype(su->su_badptr,
|
||||
su->su_badptr + su->su_badlen);
|
||||
if (need_cap) {
|
||||
su->su_badflags |= WF_ONECAP;
|
||||
}
|
||||
@ -783,8 +783,8 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
||||
// Soundfold the bad word with the default sound folding, so that we don't
|
||||
// have to do this many times.
|
||||
if (su->su_sallang != NULL) {
|
||||
spell_soundfold(su->su_sallang, (char *)su->su_fbadword, true,
|
||||
(char *)su->su_sal_badword);
|
||||
spell_soundfold(su->su_sallang, su->su_fbadword, true,
|
||||
su->su_sal_badword);
|
||||
}
|
||||
|
||||
// If the word is not capitalised and spell_check() doesn't consider the
|
||||
@ -792,14 +792,14 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
||||
// for that.
|
||||
c = utf_ptr2char(su->su_badptr);
|
||||
if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) {
|
||||
make_case_word((char *)su->su_badword, buf, WF_ONECAP);
|
||||
add_suggestion(su, &su->su_ga, (char *)buf, su->su_badlen, SCORE_ICASE,
|
||||
make_case_word(su->su_badword, buf, WF_ONECAP);
|
||||
add_suggestion(su, &su->su_ga, buf, su->su_badlen, SCORE_ICASE,
|
||||
0, true, su->su_sallang, false);
|
||||
}
|
||||
|
||||
// Ban the bad word itself. It may appear in another region.
|
||||
if (banbadword) {
|
||||
add_banned(su, (char *)su->su_badword);
|
||||
add_banned(su, su->su_badword);
|
||||
}
|
||||
|
||||
// Make a copy of 'spellsuggest', because the expression may change it.
|
||||
@ -807,22 +807,22 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
||||
|
||||
// Loop over the items in 'spellsuggest'.
|
||||
for (p = sps_copy; *p != NUL;) {
|
||||
copy_option_part(&p, (char *)buf, MAXPATHL, ",");
|
||||
copy_option_part(&p, buf, MAXPATHL, ",");
|
||||
|
||||
if (strncmp(buf, "expr:", 5) == 0) {
|
||||
// Evaluate an expression. Skip this when called recursively,
|
||||
// when using spellsuggest() in the expression.
|
||||
if (!expr_busy) {
|
||||
expr_busy = true;
|
||||
spell_suggest_expr(su, (char_u *)buf + 5);
|
||||
spell_suggest_expr(su, buf + 5);
|
||||
expr_busy = false;
|
||||
}
|
||||
} else if (strncmp(buf, "file:", 5) == 0) {
|
||||
// Use list of suggestions in a file.
|
||||
spell_suggest_file(su, (char_u *)buf + 5);
|
||||
spell_suggest_file(su, buf + 5);
|
||||
} else if (strncmp(buf, "timeout:", 8) == 0) {
|
||||
// Limit the time searching for suggestions.
|
||||
spell_suggest_timeout = atol((char *)buf + 8);
|
||||
spell_suggest_timeout = atol(buf + 8);
|
||||
} else if (!did_intern) {
|
||||
// Use internal method once.
|
||||
spell_suggest_intern(su, interactive);
|
||||
@ -843,7 +843,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
||||
}
|
||||
|
||||
/// Find suggestions by evaluating expression "expr".
|
||||
static void spell_suggest_expr(suginfo_T *su, char_u *expr)
|
||||
static void spell_suggest_expr(suginfo_T *su, char *expr)
|
||||
{
|
||||
int score;
|
||||
const char *p;
|
||||
@ -851,7 +851,7 @@ static void spell_suggest_expr(suginfo_T *su, char_u *expr)
|
||||
// The work is split up in a few parts to avoid having to export
|
||||
// suginfo_T.
|
||||
// First evaluate the expression and get the resulting list.
|
||||
list_T *const list = eval_spell_expr((char *)su->su_badword, (char *)expr);
|
||||
list_T *const list = eval_spell_expr(su->su_badword, expr);
|
||||
if (list != NULL) {
|
||||
// Loop over the items in the list.
|
||||
TV_LIST_ITER(list, li, {
|
||||
@ -873,43 +873,43 @@ static void spell_suggest_expr(suginfo_T *su, char_u *expr)
|
||||
}
|
||||
|
||||
/// Find suggestions in file "fname". Used for "file:" in 'spellsuggest'.
|
||||
static void spell_suggest_file(suginfo_T *su, char_u *fname)
|
||||
static void spell_suggest_file(suginfo_T *su, char *fname)
|
||||
{
|
||||
FILE *fd;
|
||||
char_u line[MAXWLEN * 2];
|
||||
char_u *p;
|
||||
char line[MAXWLEN * 2];
|
||||
char *p;
|
||||
int len;
|
||||
char_u cword[MAXWLEN];
|
||||
char cword[MAXWLEN];
|
||||
|
||||
// Open the file.
|
||||
fd = os_fopen((char *)fname, "r");
|
||||
fd = os_fopen(fname, "r");
|
||||
if (fd == NULL) {
|
||||
semsg(_(e_notopen), fname);
|
||||
return;
|
||||
}
|
||||
|
||||
// Read it line by line.
|
||||
while (!vim_fgets((char *)line, MAXWLEN * 2, fd) && !got_int) {
|
||||
while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int) {
|
||||
line_breakcheck();
|
||||
|
||||
p = (char_u *)vim_strchr((char *)line, '/');
|
||||
p = vim_strchr(line, '/');
|
||||
if (p == NULL) {
|
||||
continue; // No Tab found, just skip the line.
|
||||
}
|
||||
*p++ = NUL;
|
||||
if (STRICMP(su->su_badword, line) == 0) {
|
||||
// Match! Isolate the good word, until CR or NL.
|
||||
for (len = 0; p[len] >= ' '; len++) {}
|
||||
for (len = 0; (uint8_t)p[len] >= ' '; len++) {}
|
||||
p[len] = NUL;
|
||||
|
||||
// If the suggestion doesn't have specific case duplicate the case
|
||||
// of the bad word.
|
||||
if (captype((char *)p, NULL) == 0) {
|
||||
make_case_word((char *)p, (char *)cword, su->su_badflags);
|
||||
if (captype(p, NULL) == 0) {
|
||||
make_case_word(p, cword, su->su_badflags);
|
||||
p = cword;
|
||||
}
|
||||
|
||||
add_suggestion(su, &su->su_ga, (char *)p, su->su_badlen,
|
||||
add_suggestion(su, &su->su_ga, p, su->su_badlen,
|
||||
SCORE_FILE, 0, true, su->su_sallang, false);
|
||||
}
|
||||
}
|
||||
@ -1014,23 +1014,23 @@ static void spell_find_cleanup(suginfo_T *su)
|
||||
static void suggest_try_special(suginfo_T *su)
|
||||
{
|
||||
char c;
|
||||
char_u word[MAXWLEN];
|
||||
char 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);
|
||||
char *p = skiptowhite(su->su_fbadword);
|
||||
size_t len = (size_t)(p - su->su_fbadword);
|
||||
p = skipwhite(p);
|
||||
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, (char *)word, su->su_badflags);
|
||||
make_case_word(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.
|
||||
add_suggestion(su, &su->su_ga, (char *)word, su->su_badlen,
|
||||
add_suggestion(su, &su->su_ga, word, su->su_badlen,
|
||||
RESCORE(SCORE_REP, 0), 0, true, su->su_sallang, false);
|
||||
}
|
||||
}
|
||||
@ -1268,9 +1268,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
// 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, 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);
|
||||
flags = badword_captype(su->su_badptr, su->su_badptr + n);
|
||||
su->su_badflags = badword_captype(su->su_badptr + n,
|
||||
su->su_badptr + su->su_badlen);
|
||||
#ifdef DEBUG_TRIEWALK
|
||||
sprintf(changename[depth], "prefix"); // NOLINT(runtime/printf)
|
||||
#endif
|
||||
@ -1371,11 +1371,11 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
(size_t)(sp->ts_fidx - sp->ts_splitfidx)) == 0) {
|
||||
preword[sp->ts_prewordlen] = NUL;
|
||||
newscore = score_wordcount_adj(slang, sp->ts_score,
|
||||
(char_u *)preword + sp->ts_prewordlen,
|
||||
preword + sp->ts_prewordlen,
|
||||
sp->ts_prewordlen > 0);
|
||||
// Add the suggestion if the score isn't too bad.
|
||||
if (newscore <= su->su_maxscore) {
|
||||
add_suggestion(su, &su->su_ga, (char *)preword,
|
||||
add_suggestion(su, &su->su_ga, preword,
|
||||
sp->ts_splitfidx - repextra,
|
||||
newscore, 0, false,
|
||||
lp->lp_sallang, false);
|
||||
@ -1437,7 +1437,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
STRCPY(preword + sp->ts_prewordlen, tword + sp->ts_splitoff);
|
||||
} else if (flags & WF_KEEPCAP) {
|
||||
// Must find the word in the keep-case tree.
|
||||
find_keepcap_word(slang, (char *)tword + sp->ts_splitoff, preword + sp->ts_prewordlen);
|
||||
find_keepcap_word(slang, tword + sp->ts_splitoff, preword + sp->ts_prewordlen);
|
||||
} else {
|
||||
// Include badflags: If the badword is onecap or allcap
|
||||
// use that for the goodword too. But if the badword is
|
||||
@ -1465,8 +1465,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
break;
|
||||
}
|
||||
if ((sp->ts_complen == sp->ts_compsplit
|
||||
&& WAS_BANNED(su, (char *)preword + sp->ts_prewordlen))
|
||||
|| WAS_BANNED(su, (char *)preword)) {
|
||||
&& WAS_BANNED(su, preword + sp->ts_prewordlen))
|
||||
|| WAS_BANNED(su, preword)) {
|
||||
if (slang->sl_compprog == NULL) {
|
||||
break;
|
||||
}
|
||||
@ -1528,12 +1528,12 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
// Give a bonus to words seen before.
|
||||
score = score_wordcount_adj(slang,
|
||||
sp->ts_score + newscore,
|
||||
(char_u *)preword + sp->ts_prewordlen,
|
||||
preword + sp->ts_prewordlen,
|
||||
sp->ts_prewordlen > 0);
|
||||
|
||||
// Add the suggestion if the score isn't too bad.
|
||||
if (score <= su->su_maxscore) {
|
||||
add_suggestion(su, &su->su_ga, (char *)preword,
|
||||
add_suggestion(su, &su->su_ga, preword,
|
||||
sp->ts_fidx - repextra,
|
||||
score, 0, false, lp->lp_sallang, false);
|
||||
|
||||
@ -1546,7 +1546,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
preword + sp->ts_prewordlen,
|
||||
c == 0 ? WF_ALLCAP : 0);
|
||||
|
||||
add_suggestion(su, &su->su_ga, (char *)preword,
|
||||
add_suggestion(su, &su->su_ga, preword,
|
||||
sp->ts_fidx - repextra,
|
||||
score + SCORE_ICASE, 0, false,
|
||||
lp->lp_sallang, false);
|
||||
@ -1647,7 +1647,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
|
||||
// Give a bonus to words seen before.
|
||||
newscore = score_wordcount_adj(slang, newscore,
|
||||
(char_u *)preword + sp->ts_prewordlen, true);
|
||||
preword + sp->ts_prewordlen, true);
|
||||
}
|
||||
|
||||
if (TRY_DEEPER(su, stack, depth, newscore)) {
|
||||
@ -1715,8 +1715,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
// set su->su_badflags to the caps type at this
|
||||
// position
|
||||
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
|
||||
su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
|
||||
(char_u *)su->su_badptr + su->su_badlen);
|
||||
su->su_badflags = badword_captype(su->su_badptr + n,
|
||||
su->su_badptr + su->su_badlen);
|
||||
|
||||
// Restart at top of the tree.
|
||||
sp->ts_arridx = 0;
|
||||
@ -1843,7 +1843,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
// For changing a composing character adjust
|
||||
// the score from SCORE_SUBST to
|
||||
// SCORE_SUBCOMP.
|
||||
if (utf_iscomposing(utf_ptr2char((char *)tword + sp->ts_twordlen
|
||||
if (utf_iscomposing(utf_ptr2char(tword + sp->ts_twordlen
|
||||
- sp->ts_tcharlen))
|
||||
&& utf_iscomposing(utf_ptr2char(fword
|
||||
+ sp->ts_fcharstart))) {
|
||||
@ -1851,7 +1851,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
} else if (!soundfold
|
||||
&& slang->sl_has_map
|
||||
&& similar_chars(slang,
|
||||
utf_ptr2char((char *)tword + sp->ts_twordlen -
|
||||
utf_ptr2char(tword + sp->ts_twordlen -
|
||||
sp->ts_tcharlen),
|
||||
utf_ptr2char(fword + sp->ts_fcharstart))) {
|
||||
// For a similar character adjust score from
|
||||
@ -1860,7 +1860,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
}
|
||||
} else if (sp->ts_isdiff == DIFF_INSERT
|
||||
&& sp->ts_twordlen > sp->ts_tcharlen) {
|
||||
p = (char *)tword + sp->ts_twordlen - sp->ts_tcharlen;
|
||||
p = tword + sp->ts_twordlen - sp->ts_tcharlen;
|
||||
c = utf_ptr2char(p);
|
||||
if (utf_iscomposing(c)) {
|
||||
// Inserting a composing char doesn't
|
||||
@ -2310,7 +2310,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
fl = (int)strlen(ftp->ft_from);
|
||||
tl = (int)strlen(ftp->ft_to);
|
||||
if (fl != tl) {
|
||||
STRMOVE(p + tl, (char *)p + fl);
|
||||
STRMOVE(p + tl, p + fl);
|
||||
repextra += tl - fl;
|
||||
}
|
||||
memmove(p, ftp->ft_to, (size_t)tl);
|
||||
@ -2340,7 +2340,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
||||
tl = (int)strlen(ftp->ft_to);
|
||||
p = fword + sp->ts_fidx;
|
||||
if (fl != tl) {
|
||||
STRMOVE(p + fl, (char *)p + tl);
|
||||
STRMOVE(p + fl, p + tl);
|
||||
repextra -= tl - fl;
|
||||
}
|
||||
memmove(p, ftp->ft_from, (size_t)fl);
|
||||
@ -2402,7 +2402,7 @@ static void find_keepcap_word(slang_T *slang, char *fword, char *kword)
|
||||
int len;
|
||||
int c;
|
||||
idx_T lo, hi, m;
|
||||
char_u *p;
|
||||
char *p;
|
||||
char_u *byts = (char_u *)slang->sl_kbyts; // array with bytes of the words
|
||||
idx_T *idxs = slang->sl_kidxs; // array with indexes
|
||||
|
||||
@ -2443,19 +2443,19 @@ static void find_keepcap_word(slang_T *slang, char *fword, char *kword)
|
||||
// round[depth] == 1: Try using the folded-case character.
|
||||
// round[depth] == 2: Try using the upper-case character.
|
||||
flen = utf_ptr2len(fword + fwordidx[depth]);
|
||||
ulen = utf_ptr2len((char *)uword + uwordidx[depth]);
|
||||
ulen = utf_ptr2len(uword + uwordidx[depth]);
|
||||
if (round[depth] == 1) {
|
||||
p = (char_u *)fword + fwordidx[depth];
|
||||
p = fword + fwordidx[depth];
|
||||
l = flen;
|
||||
} else {
|
||||
p = (char_u *)uword + uwordidx[depth];
|
||||
p = uword + uwordidx[depth];
|
||||
l = ulen;
|
||||
}
|
||||
|
||||
for (tryidx = arridx[depth]; l > 0; l--) {
|
||||
// Perform a binary search in the list of accepted bytes.
|
||||
len = byts[tryidx++];
|
||||
c = *p++;
|
||||
c = (uint8_t)(*p++);
|
||||
lo = tryidx;
|
||||
hi = tryidx + len - 1;
|
||||
while (lo < hi) {
|
||||
@ -2512,7 +2512,7 @@ static void find_keepcap_word(slang_T *slang, char *fword, char *kword)
|
||||
static void score_comp_sal(suginfo_T *su)
|
||||
{
|
||||
langp_T *lp;
|
||||
char_u badsound[MAXWLEN];
|
||||
char badsound[MAXWLEN];
|
||||
int i;
|
||||
suggest_T *stp;
|
||||
suggest_T *sstp;
|
||||
@ -2525,7 +2525,7 @@ static void score_comp_sal(suginfo_T *su)
|
||||
lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);
|
||||
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
|
||||
// soundfold the bad word
|
||||
spell_soundfold(lp->lp_slang, (char *)su->su_fbadword, true, (char *)badsound);
|
||||
spell_soundfold(lp->lp_slang, su->su_fbadword, true, badsound);
|
||||
|
||||
for (i = 0; i < su->su_ga.ga_len; i++) {
|
||||
stp = &SUG(su->su_ga, i);
|
||||
@ -2568,11 +2568,11 @@ static void score_combine(suginfo_T *su)
|
||||
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
|
||||
// soundfold the bad word
|
||||
slang = lp->lp_slang;
|
||||
spell_soundfold(slang, (char *)su->su_fbadword, true, badsound);
|
||||
spell_soundfold(slang, su->su_fbadword, true, badsound);
|
||||
|
||||
for (int i = 0; i < su->su_ga.ga_len; i++) {
|
||||
stp = &SUG(su->su_ga, i);
|
||||
stp->st_altscore = stp_sal_score(stp, su, slang, (char_u *)badsound);
|
||||
stp->st_altscore = stp_sal_score(stp, su, slang, badsound);
|
||||
if (stp->st_altscore == SCORE_MAXMAX) {
|
||||
stp->st_score = (stp->st_score * 3 + SCORE_BIG) / 4;
|
||||
} else {
|
||||
@ -2593,7 +2593,7 @@ static void score_combine(suginfo_T *su)
|
||||
// Add the alternate score to su_sga.
|
||||
for (int i = 0; i < su->su_sga.ga_len; i++) {
|
||||
stp = &SUG(su->su_sga, i);
|
||||
stp->st_altscore = spell_edit_score(slang, (char_u *)su->su_badword, (char_u *)stp->st_word);
|
||||
stp->st_altscore = spell_edit_score(slang, su->su_badword, stp->st_word);
|
||||
if (stp->st_score == SCORE_MAXMAX) {
|
||||
stp->st_score = (SCORE_BIG * 7 + stp->st_altscore) / 8;
|
||||
} else {
|
||||
@ -2654,14 +2654,14 @@ static void score_combine(suginfo_T *su)
|
||||
/// badword.
|
||||
///
|
||||
/// @param badsound sound-folded badword
|
||||
static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *badsound)
|
||||
static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char *badsound)
|
||||
{
|
||||
char_u *p;
|
||||
char_u *pbad;
|
||||
char_u *pgood;
|
||||
char_u badsound2[MAXWLEN];
|
||||
char_u fword[MAXWLEN];
|
||||
char_u goodsound[MAXWLEN];
|
||||
char *p;
|
||||
char *pbad;
|
||||
char *pgood;
|
||||
char badsound2[MAXWLEN];
|
||||
char fword[MAXWLEN];
|
||||
char goodsound[MAXWLEN];
|
||||
char goodword[MAXWLEN];
|
||||
int lendiff;
|
||||
|
||||
@ -2670,7 +2670,7 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
|
||||
pbad = badsound;
|
||||
} else {
|
||||
// soundfold the bad word with more characters following
|
||||
(void)spell_casefold(curwin, su->su_badptr, stp->st_orglen, (char *)fword, MAXWLEN);
|
||||
(void)spell_casefold(curwin, su->su_badptr, stp->st_orglen, fword, MAXWLEN);
|
||||
|
||||
// When joining two words the sound often changes a lot. E.g., "t he"
|
||||
// sounds like "t h" while "the" sounds like "@". Avoid that by
|
||||
@ -2678,12 +2678,12 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
|
||||
// space.
|
||||
if (ascii_iswhite(su->su_badptr[su->su_badlen])
|
||||
&& *skiptowhite(stp->st_word) == NUL) {
|
||||
for (p = fword; *(p = (char_u *)skiptowhite((char *)p)) != NUL;) {
|
||||
STRMOVE(p, (char *)p + 1);
|
||||
for (p = fword; *(p = skiptowhite(p)) != NUL;) {
|
||||
STRMOVE(p, p + 1);
|
||||
}
|
||||
}
|
||||
|
||||
spell_soundfold(slang, (char *)fword, true, (char *)badsound2);
|
||||
spell_soundfold(slang, fword, true, badsound2);
|
||||
pbad = badsound2;
|
||||
}
|
||||
|
||||
@ -2693,15 +2693,15 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
|
||||
STRCPY(goodword, stp->st_word);
|
||||
xstrlcpy(goodword + stp->st_wordlen,
|
||||
su->su_badptr + su->su_badlen - lendiff, (size_t)lendiff + 1);
|
||||
pgood = (char_u *)goodword;
|
||||
pgood = goodword;
|
||||
} else {
|
||||
pgood = (char_u *)stp->st_word;
|
||||
pgood = stp->st_word;
|
||||
}
|
||||
|
||||
// Sound-fold the word and compute the score for the difference.
|
||||
spell_soundfold(slang, (char *)pgood, false, (char *)goodsound);
|
||||
spell_soundfold(slang, pgood, false, goodsound);
|
||||
|
||||
return soundalike_score((char *)goodsound, (char *)pbad);
|
||||
return soundalike_score(goodsound, pbad);
|
||||
}
|
||||
|
||||
/// structure used to store soundfolded words that add_sound_suggest() has
|
||||
@ -2737,7 +2737,7 @@ static void suggest_try_soundalike_prep(void)
|
||||
/// Note: This doesn't support postponed prefixes.
|
||||
static void suggest_try_soundalike(suginfo_T *su)
|
||||
{
|
||||
char_u salword[MAXWLEN];
|
||||
char salword[MAXWLEN];
|
||||
langp_T *lp;
|
||||
slang_T *slang;
|
||||
|
||||
@ -2748,7 +2748,7 @@ static void suggest_try_soundalike(suginfo_T *su)
|
||||
slang = lp->lp_slang;
|
||||
if (!GA_EMPTY(&slang->sl_sal) && slang->sl_sbyts != NULL) {
|
||||
// soundfold the bad word
|
||||
spell_soundfold(slang, (char *)su->su_fbadword, true, (char *)salword);
|
||||
spell_soundfold(slang, su->su_fbadword, true, salword);
|
||||
|
||||
// try all kinds of inserts/deletes/swaps/etc.
|
||||
// TODO(vim): also soundfold the next words, so that we can try joining
|
||||
@ -2756,7 +2756,7 @@ static void suggest_try_soundalike(suginfo_T *su)
|
||||
#ifdef SUGGEST_PROFILE
|
||||
prof_init();
|
||||
#endif
|
||||
suggest_trie_walk(su, lp, (char *)salword, true);
|
||||
suggest_trie_walk(su, lp, salword, true);
|
||||
#ifdef SUGGEST_PROFILE
|
||||
prof_report("soundalike");
|
||||
#endif
|
||||
@ -2802,9 +2802,9 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
|
||||
{
|
||||
slang_T *slang = lp->lp_slang; // language for sound folding
|
||||
int sfwordnr;
|
||||
char_u *nrline;
|
||||
char *nrline;
|
||||
int orgnr;
|
||||
char_u theword[MAXWLEN];
|
||||
char theword[MAXWLEN];
|
||||
int i;
|
||||
int wlen;
|
||||
char_u *byts;
|
||||
@ -2841,14 +2841,14 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
|
||||
}
|
||||
|
||||
// Find the word nr in the soundfold tree.
|
||||
sfwordnr = soundfold_find(slang, (char_u *)goodword);
|
||||
sfwordnr = soundfold_find(slang, goodword);
|
||||
if (sfwordnr < 0) {
|
||||
internal_error("add_sound_suggest()");
|
||||
return;
|
||||
}
|
||||
|
||||
// Go over the list of good words that produce this soundfold word
|
||||
nrline = (char_u *)ml_get_buf(slang->sl_sugbuf, (linenr_T)sfwordnr + 1, false);
|
||||
nrline = ml_get_buf(slang->sl_sugbuf, (linenr_T)sfwordnr + 1, false);
|
||||
orgnr = 0;
|
||||
while (*nrline != NUL) {
|
||||
// The wordnr was stored in a minimal nr of bytes as an offset to the
|
||||
@ -2888,7 +2888,7 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
|
||||
wordcount += wc;
|
||||
}
|
||||
|
||||
theword[wlen] = byts[n + i];
|
||||
theword[wlen] = (char)byts[n + i];
|
||||
n = idxs[n + i];
|
||||
}
|
||||
badword:
|
||||
@ -2896,8 +2896,8 @@ badword:
|
||||
|
||||
// Go over the possible flags and regions.
|
||||
for (; i <= byts[n] && byts[n + i] == NUL; i++) {
|
||||
char_u cword[MAXWLEN];
|
||||
char_u *p;
|
||||
char cword[MAXWLEN];
|
||||
char *p;
|
||||
int flags = (int)idxs[n + i];
|
||||
|
||||
// Skip words with the NOSUGGEST flag
|
||||
@ -2907,13 +2907,13 @@ badword:
|
||||
|
||||
if (flags & WF_KEEPCAP) {
|
||||
// Must find the word in the keep-case tree.
|
||||
find_keepcap_word(slang, (char *)theword, (char *)cword);
|
||||
find_keepcap_word(slang, theword, cword);
|
||||
p = cword;
|
||||
} else {
|
||||
flags |= su->su_badflags;
|
||||
if ((flags & WF_CAPMASK) != 0) {
|
||||
// Need to fix case according to "flags".
|
||||
make_case_word((char *)theword, (char *)cword, flags);
|
||||
make_case_word(theword, cword, flags);
|
||||
p = cword;
|
||||
} else {
|
||||
p = theword;
|
||||
@ -2924,7 +2924,7 @@ badword:
|
||||
if (sps_flags & SPS_DOUBLE) {
|
||||
// Add the suggestion if the score isn't too bad.
|
||||
if (score <= su->su_maxscore) {
|
||||
add_suggestion(su, &su->su_sga, (char *)p, su->su_badlen,
|
||||
add_suggestion(su, &su->su_sga, p, su->su_badlen,
|
||||
score, 0, false, slang, false);
|
||||
}
|
||||
} else {
|
||||
@ -2940,9 +2940,9 @@ badword:
|
||||
// lower to upper case. Helps for "tath" -> "Kath", which is
|
||||
// less common than "tath" -> "path". Don't do it when the
|
||||
// letter is the same, that has already been counted.
|
||||
gc = utf_ptr2char((char *)p);
|
||||
gc = utf_ptr2char(p);
|
||||
if (SPELL_ISUPPER(gc)) {
|
||||
bc = utf_ptr2char((char *)su->su_badword);
|
||||
bc = utf_ptr2char(su->su_badword);
|
||||
if (!SPELL_ISUPPER(bc)
|
||||
&& SPELL_TOFOLD(bc) != SPELL_TOFOLD(gc)) {
|
||||
goodscore += SCORE_ICASE / 2;
|
||||
@ -2958,10 +2958,9 @@ badword:
|
||||
// inefficient, using an array is quicker.
|
||||
limit = MAXSCORE(su->su_sfmaxscore - goodscore, score);
|
||||
if (limit > SCORE_LIMITMAX) {
|
||||
goodscore += spell_edit_score(slang, (char_u *)su->su_badword, p);
|
||||
goodscore += spell_edit_score(slang, su->su_badword, p);
|
||||
} else {
|
||||
goodscore += spell_edit_score_limit(slang, (char_u *)su->su_badword,
|
||||
p, limit);
|
||||
goodscore += spell_edit_score_limit(slang, su->su_badword, p, limit);
|
||||
}
|
||||
|
||||
// When going over the limit don't bother to do the rest.
|
||||
@ -2972,7 +2971,7 @@ badword:
|
||||
// Add the suggestion if the score isn't too bad.
|
||||
goodscore = RESCORE(goodscore, score);
|
||||
if (goodscore <= su->su_sfmaxscore) {
|
||||
add_suggestion(su, &su->su_ga, (char *)p, su->su_badlen,
|
||||
add_suggestion(su, &su->su_ga, p, su->su_badlen,
|
||||
goodscore, score, true, slang, true);
|
||||
}
|
||||
}
|
||||
@ -2982,13 +2981,13 @@ badword:
|
||||
}
|
||||
|
||||
/// Find word "word" in fold-case tree for "slang" and return the word number.
|
||||
static int soundfold_find(slang_T *slang, char_u *word)
|
||||
static int soundfold_find(slang_T *slang, char *word)
|
||||
{
|
||||
idx_T arridx = 0;
|
||||
int len;
|
||||
int wlen = 0;
|
||||
int c;
|
||||
char_u *ptr = word;
|
||||
char_u *ptr = (char_u *)word;
|
||||
char_u *byts;
|
||||
idx_T *idxs;
|
||||
int wordnr = 0;
|
||||
@ -3065,7 +3064,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
|
||||
hashitem_T *hi;
|
||||
|
||||
if (c1 >= 256) {
|
||||
buf[utf_char2bytes(c1, (char *)buf)] = 0;
|
||||
buf[utf_char2bytes(c1, buf)] = 0;
|
||||
hi = hash_find(&slang->sl_map_hash, buf);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
m1 = 0;
|
||||
@ -3080,7 +3079,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
|
||||
}
|
||||
|
||||
if (c2 >= 256) {
|
||||
buf[utf_char2bytes(c2, (char *)buf)] = 0;
|
||||
buf[utf_char2bytes(c2, buf)] = 0;
|
||||
hi = hash_find(&slang->sl_map_hash, buf);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
m2 = 0;
|
||||
@ -3244,7 +3243,7 @@ static void check_suggestions(suginfo_T *su, garray_T *gap)
|
||||
/// Add a word to be banned.
|
||||
static void add_banned(suginfo_T *su, char *word)
|
||||
{
|
||||
char_u *s;
|
||||
char *s;
|
||||
hash_T hash;
|
||||
hashitem_T *hi;
|
||||
|
||||
@ -3255,7 +3254,7 @@ static void add_banned(suginfo_T *su, char *word)
|
||||
return;
|
||||
}
|
||||
s = xmemdupz(word, word_len);
|
||||
hash_add_item(&su->su_banned, hi, (char *)s, hash);
|
||||
hash_add_item(&su->su_banned, hi, s, hash);
|
||||
}
|
||||
|
||||
/// Recompute the score for all suggestions if sound-folding is possible. This
|
||||
@ -3273,8 +3272,8 @@ static void rescore_suggestions(suginfo_T *su)
|
||||
static void rescore_one(suginfo_T *su, suggest_T *stp)
|
||||
{
|
||||
slang_T *slang = stp->st_slang;
|
||||
char_u sal_badword[MAXWLEN];
|
||||
char_u *p;
|
||||
char sal_badword[MAXWLEN];
|
||||
char *p;
|
||||
|
||||
// Only rescore suggestions that have no sal score yet and do have a
|
||||
// language.
|
||||
@ -3282,7 +3281,7 @@ static void rescore_one(suginfo_T *su, suggest_T *stp)
|
||||
if (slang == su->su_sallang) {
|
||||
p = su->su_sal_badword;
|
||||
} else {
|
||||
spell_soundfold(slang, (char *)su->su_fbadword, true, (char *)sal_badword);
|
||||
spell_soundfold(slang, su->su_fbadword, true, sal_badword);
|
||||
p = sal_badword;
|
||||
}
|
||||
|
||||
@ -3575,7 +3574,7 @@ static int soundalike_score(char *goodstart, char *badstart)
|
||||
/// The implementation of the algorithm comes from Aspell editdist.cpp,
|
||||
/// edit_distance(). It has been converted from C++ to C and modified to
|
||||
/// support multi-byte characters.
|
||||
static int spell_edit_score(slang_T *slang, const char_u *badword, const char_u *goodword)
|
||||
static int spell_edit_score(slang_T *slang, const char *badword, const char *goodword)
|
||||
{
|
||||
int *cnt;
|
||||
int j, i;
|
||||
@ -3592,12 +3591,12 @@ static int spell_edit_score(slang_T *slang, const char_u *badword, const char_u
|
||||
// Get the characters from the multi-byte strings and put them in an
|
||||
// int array for easy access.
|
||||
badlen = 0;
|
||||
for (const char *p = (char *)badword; *p != NUL;) {
|
||||
for (const char *p = badword; *p != NUL;) {
|
||||
wbadword[badlen++] = mb_cptr2char_adv(&p);
|
||||
}
|
||||
wbadword[badlen++] = 0;
|
||||
goodlen = 0;
|
||||
for (const char *p = (char *)goodword; *p != NUL;) {
|
||||
for (const char *p = goodword; *p != NUL;) {
|
||||
wgoodword[goodlen++] = mb_cptr2char_adv(&p);
|
||||
}
|
||||
wgoodword[goodlen++] = 0;
|
||||
@ -3673,14 +3672,14 @@ typedef struct {
|
||||
/// This uses a stack for the edits still to be tried.
|
||||
/// The idea comes from Aspell leditdist.cpp. Rewritten in C and added support
|
||||
/// for multi-byte characters.
|
||||
static int spell_edit_score_limit(slang_T *slang, char_u *badword, char_u *goodword, int limit)
|
||||
static int spell_edit_score_limit(slang_T *slang, char *badword, char *goodword, int limit)
|
||||
{
|
||||
return spell_edit_score_limit_w(slang, badword, goodword, limit);
|
||||
}
|
||||
|
||||
/// Multi-byte version of spell_edit_score_limit().
|
||||
/// Keep it in sync with the above!
|
||||
static int spell_edit_score_limit_w(slang_T *slang, const char_u *badword, const char_u *goodword,
|
||||
static int spell_edit_score_limit_w(slang_T *slang, const char *badword, const char *goodword,
|
||||
int limit)
|
||||
{
|
||||
limitscore_T stack[10]; // allow for over 3 * 2 edits
|
||||
@ -3698,12 +3697,12 @@ static int spell_edit_score_limit_w(slang_T *slang, const char_u *badword, const
|
||||
// Get the characters from the multi-byte strings and put them in an
|
||||
// int array for easy access.
|
||||
bi = 0;
|
||||
for (const char *p = (char *)badword; *p != NUL;) {
|
||||
for (const char *p = badword; *p != NUL;) {
|
||||
wbadword[bi++] = mb_cptr2char_adv(&p);
|
||||
}
|
||||
wbadword[bi++] = 0;
|
||||
gi = 0;
|
||||
for (const char *p = (char *)goodword; *p != NUL;) {
|
||||
for (const char *p = goodword; *p != NUL;) {
|
||||
wgoodword[gi++] = mb_cptr2char_adv(&p);
|
||||
}
|
||||
wgoodword[gi++] = 0;
|
||||
|
@ -582,7 +582,7 @@ void win_redr_ruler(win_T *wp, bool always)
|
||||
MAXSIZE_TEMP_ARRAY(content, 1);
|
||||
MAXSIZE_TEMP_ARRAY(chunk, 2);
|
||||
ADD_C(chunk, INTEGER_OBJ(attr));
|
||||
ADD_C(chunk, STRING_OBJ(cstr_as_string((char *)buffer)));
|
||||
ADD_C(chunk, STRING_OBJ(cstr_as_string(buffer)));
|
||||
ADD_C(content, ARRAY_OBJ(chunk));
|
||||
ui_call_msg_ruler(content);
|
||||
did_show_ext_ruler = true;
|
||||
|
@ -395,12 +395,12 @@ static int assert_equalfile(typval_T *argvars)
|
||||
char line2[200];
|
||||
ptrdiff_t lineidx = 0;
|
||||
if (fd1 == NULL) {
|
||||
snprintf(IObuff, IOSIZE, (char *)e_notread, fname1);
|
||||
snprintf(IObuff, IOSIZE, e_notread, fname1);
|
||||
} else {
|
||||
FILE *const fd2 = os_fopen(fname2, READBIN);
|
||||
if (fd2 == NULL) {
|
||||
fclose(fd1);
|
||||
snprintf(IObuff, IOSIZE, (char *)e_notread, fname2);
|
||||
snprintf(IObuff, IOSIZE, e_notread, fname2);
|
||||
} else {
|
||||
int64_t linecount = 1;
|
||||
for (int64_t count = 0;; count++) {
|
||||
|
@ -72,7 +72,7 @@ bool has_format_option(int x)
|
||||
void internal_format(int textwidth, int second_indent, int flags, bool format_only, int c)
|
||||
{
|
||||
int cc;
|
||||
int save_char = NUL;
|
||||
char save_char = NUL;
|
||||
bool haveto_redraw = false;
|
||||
const bool fo_ins_blank = has_format_option(FO_INS_BLANK);
|
||||
const bool fo_multibyte = has_format_option(FO_MBYTE_BREAK);
|
||||
@ -93,7 +93,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|
||||
&& !(State & VREPLACE_FLAG)) {
|
||||
cc = gchar_cursor();
|
||||
if (ascii_iswhite(cc)) {
|
||||
save_char = cc;
|
||||
save_char = (char)cc;
|
||||
pchar_cursor('x');
|
||||
}
|
||||
}
|
||||
@ -458,7 +458,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|
||||
}
|
||||
|
||||
if (save_char != NUL) { // put back space after cursor
|
||||
pchar_cursor((char_u)save_char);
|
||||
pchar_cursor(save_char);
|
||||
}
|
||||
|
||||
curwin->w_p_lbr = has_lbr;
|
||||
|
@ -298,8 +298,8 @@ const char *set_context_in_user_cmdarg(const char *cmd FUNC_ATTR_UNUSED, const c
|
||||
return arg;
|
||||
}
|
||||
if (context == EXPAND_MAPPINGS) {
|
||||
return (const char *)set_context_in_map_cmd(xp, "map", (char *)arg, forceit, false, false,
|
||||
CMD_map);
|
||||
return set_context_in_map_cmd(xp, "map", (char *)arg, forceit, false, false,
|
||||
CMD_map);
|
||||
}
|
||||
// Find start of last argument.
|
||||
const char *p = arg;
|
||||
@ -1749,8 +1749,8 @@ Dictionary commands_array(buf_T *buf)
|
||||
Dictionary d = ARRAY_DICT_INIT;
|
||||
ucmd_T *cmd = USER_CMD_GA(gap, i);
|
||||
|
||||
PUT(d, "name", STRING_OBJ(cstr_to_string((char *)cmd->uc_name)));
|
||||
PUT(d, "definition", STRING_OBJ(cstr_to_string((char *)cmd->uc_rep)));
|
||||
PUT(d, "name", STRING_OBJ(cstr_to_string(cmd->uc_name)));
|
||||
PUT(d, "definition", STRING_OBJ(cstr_to_string(cmd->uc_rep)));
|
||||
PUT(d, "script_id", INTEGER_OBJ(cmd->uc_script_ctx.sc_sid));
|
||||
PUT(d, "bang", BOOLEAN_OBJ(!!(cmd->uc_argt & EX_BANG)));
|
||||
PUT(d, "bar", BOOLEAN_OBJ(!!(cmd->uc_argt & EX_TRLBAR)));
|
||||
@ -1776,7 +1776,7 @@ Dictionary commands_array(buf_T *buf)
|
||||
PUT(d, "complete", (cmd_compl == NULL
|
||||
? NIL : STRING_OBJ(cstr_to_string(cmd_compl))));
|
||||
PUT(d, "complete_arg", cmd->uc_compl_arg == NULL
|
||||
? NIL : STRING_OBJ(cstr_to_string((char *)cmd->uc_compl_arg)));
|
||||
? NIL : STRING_OBJ(cstr_to_string(cmd->uc_compl_arg)));
|
||||
|
||||
Object obj = NIL;
|
||||
if (cmd->uc_argt & EX_COUNT) {
|
||||
@ -1812,7 +1812,7 @@ Dictionary commands_array(buf_T *buf)
|
||||
}
|
||||
PUT(d, "addr", obj);
|
||||
|
||||
PUT(rv, (char *)cmd->uc_name, DICTIONARY_OBJ(d));
|
||||
PUT(rv, cmd->uc_name, DICTIONARY_OBJ(d));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -195,7 +195,6 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
|
||||
#define CLEAR_FIELD(field) memset(&(field), 0, sizeof(field))
|
||||
#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr)))
|
||||
|
||||
// defines to avoid typecasts from (char_u *) to (char *) and back
|
||||
// (vim_strchr() is now in strings.c)
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
|
Loading…
Reference in New Issue
Block a user