mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
parent
29b80f6f2e
commit
bd22585061
@ -111,7 +111,7 @@
|
|||||||
(v).size = (v).size + len; \
|
(v).size = (v).size + len; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define kv_concat(v, str) kv_concat_len(v, str, STRLEN(str))
|
#define kv_concat(v, str) kv_concat_len(v, str, strlen(str))
|
||||||
#define kv_splice(v1, v0) kv_concat_len(v1, (v0).items, (v0).size)
|
#define kv_splice(v1, v0) kv_concat_len(v1, (v0).items, (v0).size)
|
||||||
|
|
||||||
#define kv_pushp(v) \
|
#define kv_pushp(v) \
|
||||||
|
@ -877,7 +877,7 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
|
|||||||
bool was_alloced = ml_line_alloced(); // check if oldp was allocated
|
bool was_alloced = ml_line_alloced(); // check if oldp was allocated
|
||||||
char *newp;
|
char *newp;
|
||||||
if (was_alloced) {
|
if (was_alloced) {
|
||||||
ml_add_deleted_len((char *)curbuf->b_ml.ml_line_ptr, oldlen);
|
ml_add_deleted_len(curbuf->b_ml.ml_line_ptr, oldlen);
|
||||||
newp = oldp; // use same allocated memory
|
newp = oldp; // use same allocated memory
|
||||||
} else { // need to allocate a new line
|
} else { // need to allocate a new line
|
||||||
newp = xmalloc((size_t)(oldlen + 1 - count));
|
newp = xmalloc((size_t)(oldlen + 1 - count));
|
||||||
|
@ -423,7 +423,7 @@ char *transstr(const char *const s, bool untab)
|
|||||||
///
|
///
|
||||||
/// When "buf" is NULL, return an allocated string.
|
/// When "buf" is NULL, return an allocated string.
|
||||||
/// Otherwise, put the result in buf, limited by buflen, and return buf.
|
/// Otherwise, put the result in buf, limited by buflen, and return buf.
|
||||||
char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
|
char_u *str_foldcase(char_u *str, int orglen, char *buf, int buflen)
|
||||||
FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
@ -431,7 +431,7 @@ char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
|
|||||||
int len = orglen;
|
int len = orglen;
|
||||||
|
|
||||||
#define GA_CHAR(i) ((char *)ga.ga_data)[i]
|
#define GA_CHAR(i) ((char *)ga.ga_data)[i]
|
||||||
#define GA_PTR(i) ((char_u *)ga.ga_data + (i))
|
#define GA_PTR(i) ((char *)ga.ga_data + (i))
|
||||||
#define STR_CHAR(i) (buf == NULL ? GA_CHAR(i) : buf[i])
|
#define STR_CHAR(i) (buf == NULL ? GA_CHAR(i) : buf[i])
|
||||||
#define STR_PTR(i) (buf == NULL ? GA_PTR(i) : buf + (i))
|
#define STR_PTR(i) (buf == NULL ? GA_PTR(i) : buf + (i))
|
||||||
|
|
||||||
@ -459,8 +459,8 @@ char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
|
|||||||
// Make each character lower case.
|
// Make each character lower case.
|
||||||
i = 0;
|
i = 0;
|
||||||
while (STR_CHAR(i) != NUL) {
|
while (STR_CHAR(i) != NUL) {
|
||||||
int c = utf_ptr2char((char *)STR_PTR(i));
|
int c = utf_ptr2char(STR_PTR(i));
|
||||||
int olen = utf_ptr2len((char *)STR_PTR(i));
|
int olen = utf_ptr2len(STR_PTR(i));
|
||||||
int lc = mb_tolower(c);
|
int lc = mb_tolower(c);
|
||||||
|
|
||||||
// Only replace the character when it is not an invalid
|
// Only replace the character when it is not an invalid
|
||||||
@ -494,17 +494,17 @@ char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void)utf_char2bytes(lc, (char *)STR_PTR(i));
|
(void)utf_char2bytes(lc, STR_PTR(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip to next multi-byte char
|
// skip to next multi-byte char
|
||||||
i += utfc_ptr2len((char *)STR_PTR(i));
|
i += utfc_ptr2len(STR_PTR(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return (char_u *)ga.ga_data;
|
return (char_u *)ga.ga_data;
|
||||||
}
|
}
|
||||||
return buf;
|
return (char_u *)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Catch 22: g_chartab[] can't be initialized before the options are
|
// Catch 22: g_chartab[] can't be initialized before the options are
|
||||||
|
@ -449,7 +449,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|
|||||||
|| xp->xp_context == EXPAND_MENUNAMES);
|
|| xp->xp_context == EXPAND_MENUNAMES);
|
||||||
if (emenu && menu_is_separator((char *)s)) {
|
if (emenu && menu_is_separator((char *)s)) {
|
||||||
STRCPY(buf + len, transchar('|'));
|
STRCPY(buf + len, transchar('|'));
|
||||||
l = (int)STRLEN(buf + len);
|
l = (int)strlen((char *)buf + len);
|
||||||
len += l;
|
len += l;
|
||||||
clen += l;
|
clen += l;
|
||||||
} else {
|
} else {
|
||||||
@ -462,7 +462,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|
|||||||
len += l;
|
len += l;
|
||||||
} else {
|
} else {
|
||||||
STRCPY(buf + len, transchar_byte(*s));
|
STRCPY(buf + len, transchar_byte(*s));
|
||||||
len += (int)STRLEN(buf + len);
|
len += (int)strlen((char *)buf + len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,12 +263,12 @@ static inline void ctx_save_funcs(Context *ctx, bool scriptonly)
|
|||||||
Error err = ERROR_INIT;
|
Error err = ERROR_INIT;
|
||||||
|
|
||||||
HASHTAB_ITER(func_tbl_get(), hi, {
|
HASHTAB_ITER(func_tbl_get(), hi, {
|
||||||
const char_u *const name = hi->hi_key;
|
const char *const name = hi->hi_key;
|
||||||
bool islambda = (STRNCMP(name, "<lambda>", 8) == 0);
|
bool islambda = (STRNCMP(name, "<lambda>", 8) == 0);
|
||||||
bool isscript = (name[0] == K_SPECIAL);
|
bool isscript = ((uint8_t)name[0] == K_SPECIAL);
|
||||||
|
|
||||||
if (!islambda && (!scriptonly || isscript)) {
|
if (!islambda && (!scriptonly || isscript)) {
|
||||||
size_t cmd_len = sizeof("func! ") + STRLEN(name);
|
size_t cmd_len = sizeof("func! ") + strlen(name);
|
||||||
char *cmd = xmalloc(cmd_len);
|
char *cmd = xmalloc(cmd_len);
|
||||||
snprintf(cmd, cmd_len, "func! %s", name);
|
snprintf(cmd, cmd_len, "func! %s", name);
|
||||||
String func_body = nvim_exec(VIML_INTERNAL_CALL, cstr_as_string(cmd),
|
String func_body = nvim_exec(VIML_INTERNAL_CALL, cstr_as_string(cmd),
|
||||||
|
@ -742,7 +742,7 @@ void ex_breaklist(exarg_T *eap)
|
|||||||
/// @param after after this line number
|
/// @param after after this line number
|
||||||
linenr_T dbg_find_breakpoint(bool file, char *fname, linenr_T after)
|
linenr_T dbg_find_breakpoint(bool file, char *fname, linenr_T after)
|
||||||
{
|
{
|
||||||
return debuggy_find(file, (char_u *)fname, after, &dbg_breakp, NULL);
|
return debuggy_find(file, fname, after, &dbg_breakp, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param file true for a file, false for a function
|
/// @param file true for a file, false for a function
|
||||||
@ -752,7 +752,7 @@ linenr_T dbg_find_breakpoint(bool file, char *fname, linenr_T after)
|
|||||||
/// @returns true if profiling is on for a function or sourced file.
|
/// @returns true if profiling is on for a function or sourced file.
|
||||||
bool has_profiling(bool file, char *fname, bool *fp)
|
bool has_profiling(bool file, char *fname, bool *fp)
|
||||||
{
|
{
|
||||||
return debuggy_find(file, (char_u *)fname, (linenr_T)0, &prof_ga, fp)
|
return debuggy_find(file, fname, (linenr_T)0, &prof_ga, fp)
|
||||||
!= (linenr_T)0;
|
!= (linenr_T)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,11 +763,11 @@ bool has_profiling(bool file, char *fname, bool *fp)
|
|||||||
/// @param after after this line number
|
/// @param after after this line number
|
||||||
/// @param gap either &dbg_breakp or &prof_ga
|
/// @param gap either &dbg_breakp or &prof_ga
|
||||||
/// @param fp if not NULL: return forceit
|
/// @param fp if not NULL: return forceit
|
||||||
static linenr_T debuggy_find(bool file, char_u *fname, linenr_T after, garray_T *gap, bool *fp)
|
static linenr_T debuggy_find(bool file, char *fname, linenr_T after, garray_T *gap, bool *fp)
|
||||||
{
|
{
|
||||||
struct debuggy *bp;
|
struct debuggy *bp;
|
||||||
linenr_T lnum = 0;
|
linenr_T lnum = 0;
|
||||||
char_u *name = fname;
|
char *name = fname;
|
||||||
int prev_got_int;
|
int prev_got_int;
|
||||||
|
|
||||||
// Return quickly when there are no breakpoints.
|
// Return quickly when there are no breakpoints.
|
||||||
@ -776,8 +776,8 @@ static linenr_T debuggy_find(bool file, char_u *fname, linenr_T after, garray_T
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Replace K_SNR in function name with "<SNR>".
|
// Replace K_SNR in function name with "<SNR>".
|
||||||
if (!file && fname[0] == K_SPECIAL) {
|
if (!file && (uint8_t)fname[0] == K_SPECIAL) {
|
||||||
name = xmalloc(STRLEN(fname) + 3);
|
name = xmalloc(strlen(fname) + 3);
|
||||||
STRCPY(name, "<SNR>");
|
STRCPY(name, "<SNR>");
|
||||||
STRCPY(name + 5, fname + 3);
|
STRCPY(name + 5, fname + 3);
|
||||||
}
|
}
|
||||||
@ -795,7 +795,7 @@ static linenr_T debuggy_find(bool file, char_u *fname, linenr_T after, garray_T
|
|||||||
// while matching should abort it.
|
// while matching should abort it.
|
||||||
prev_got_int = got_int;
|
prev_got_int = got_int;
|
||||||
got_int = false;
|
got_int = false;
|
||||||
if (vim_regexec_prog(&bp->dbg_prog, false, name, (colnr_T)0)) {
|
if (vim_regexec_prog(&bp->dbg_prog, false, (char_u *)name, (colnr_T)0)) {
|
||||||
lnum = bp->dbg_lnum;
|
lnum = bp->dbg_lnum;
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
*fp = bp->dbg_forceit;
|
*fp = bp->dbg_forceit;
|
||||||
|
@ -1215,8 +1215,7 @@ void ex_diffpatch(exarg_T *eap)
|
|||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
// Get the absolute path of the patchfile, changing directory below.
|
// Get the absolute path of the patchfile, changing directory below.
|
||||||
fullname = FullName_save(eap->arg, false);
|
fullname = FullName_save(eap->arg, false);
|
||||||
esc_name =
|
esc_name = vim_strsave_shellescape(fullname != NULL ? fullname : eap->arg, true, true);
|
||||||
(char *)vim_strsave_shellescape((char_u *)(fullname != NULL ? fullname : eap->arg), true, true);
|
|
||||||
#else
|
#else
|
||||||
esc_name = (char *)vim_strsave_shellescape(eap->arg, true, true);
|
esc_name = (char *)vim_strsave_shellescape(eap->arg, true, true);
|
||||||
#endif
|
#endif
|
||||||
|
@ -313,8 +313,8 @@ static bool use_cursor_line_sign(win_T *wp, linenr_T lnum)
|
|||||||
// @param sign_idxp Index of the displayed sign
|
// @param sign_idxp Index of the displayed sign
|
||||||
static void get_sign_display_info(bool nrcol, win_T *wp, linenr_T lnum, SignTextAttrs sattrs[],
|
static void get_sign_display_info(bool nrcol, win_T *wp, linenr_T lnum, SignTextAttrs sattrs[],
|
||||||
int row, int startrow, int filler_lines, int filler_todo,
|
int row, int startrow, int filler_lines, int filler_todo,
|
||||||
int *c_extrap, int *c_finalp, char_u *extra, size_t extra_size,
|
int *c_extrap, int *c_finalp, char *extra, size_t extra_size,
|
||||||
char_u **pp_extra, int *n_extrap, int *char_attrp, int sign_idx,
|
char **pp_extra, int *n_extrap, int *char_attrp, int sign_idx,
|
||||||
int cul_attr)
|
int cul_attr)
|
||||||
{
|
{
|
||||||
// Draw cells with the sign value or blank.
|
// Draw cells with the sign value or blank.
|
||||||
@ -334,7 +334,7 @@ static void get_sign_display_info(bool nrcol, win_T *wp, linenr_T lnum, SignText
|
|||||||
if (row == startrow + filler_lines && filler_todo <= 0) {
|
if (row == startrow + filler_lines && filler_todo <= 0) {
|
||||||
SignTextAttrs *sattr = sign_get_attr(sign_idx, sattrs, wp->w_scwidth);
|
SignTextAttrs *sattr = sign_get_attr(sign_idx, sattrs, wp->w_scwidth);
|
||||||
if (sattr != NULL) {
|
if (sattr != NULL) {
|
||||||
*pp_extra = (char_u *)sattr->text;
|
*pp_extra = sattr->text;
|
||||||
if (*pp_extra != NULL) {
|
if (*pp_extra != NULL) {
|
||||||
*c_extrap = NUL;
|
*c_extrap = NUL;
|
||||||
*c_finalp = NUL;
|
*c_finalp = NUL;
|
||||||
@ -348,16 +348,16 @@ static void get_sign_display_info(bool nrcol, win_T *wp, linenr_T lnum, SignText
|
|||||||
STRCAT(extra, *pp_extra);
|
STRCAT(extra, *pp_extra);
|
||||||
STRCAT(extra, " ");
|
STRCAT(extra, " ");
|
||||||
*pp_extra = extra;
|
*pp_extra = extra;
|
||||||
*n_extrap = (int)STRLEN(*pp_extra);
|
*n_extrap = (int)strlen(*pp_extra);
|
||||||
} else {
|
} else {
|
||||||
size_t symbol_blen = STRLEN(*pp_extra);
|
size_t symbol_blen = strlen(*pp_extra);
|
||||||
|
|
||||||
// TODO(oni-link): Is sign text already extended to
|
// TODO(oni-link): Is sign text already extended to
|
||||||
// full cell width?
|
// full cell width?
|
||||||
assert((size_t)win_signcol_width(wp) >= mb_string2cells((char *)(*pp_extra)));
|
assert((size_t)win_signcol_width(wp) >= mb_string2cells((char *)(*pp_extra)));
|
||||||
// symbol(s) bytes + (filling spaces) (one byte each)
|
// symbol(s) bytes + (filling spaces) (one byte each)
|
||||||
*n_extrap = (int)symbol_blen + win_signcol_width(wp) -
|
*n_extrap = (int)symbol_blen + win_signcol_width(wp) -
|
||||||
(int)mb_string2cells((char *)(*pp_extra));
|
(int)mb_string2cells(*pp_extra);
|
||||||
|
|
||||||
assert(extra_size > symbol_blen);
|
assert(extra_size > symbol_blen);
|
||||||
memset(extra, ' ', extra_size);
|
memset(extra, ' ', extra_size);
|
||||||
@ -508,16 +508,16 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
long vcol = 0; // virtual column (for tabs)
|
long vcol = 0; // virtual column (for tabs)
|
||||||
long vcol_sbr = -1; // virtual column after showbreak
|
long vcol_sbr = -1; // virtual column after showbreak
|
||||||
long vcol_prev = -1; // "vcol" of previous character
|
long vcol_prev = -1; // "vcol" of previous character
|
||||||
char_u *line; // current line
|
char *line; // current line
|
||||||
char_u *ptr; // current position in "line"
|
char *ptr; // current position in "line"
|
||||||
int row; // row in the window, excl w_winrow
|
int row; // row in the window, excl w_winrow
|
||||||
ScreenGrid *grid = &wp->w_grid; // grid specific to the window
|
ScreenGrid *grid = &wp->w_grid; // grid specific to the window
|
||||||
|
|
||||||
char_u extra[57]; // sign, line number and 'fdc' must
|
char_u extra[57]; // sign, line number and 'fdc' must
|
||||||
// fit in here
|
// fit in here
|
||||||
int n_extra = 0; // number of extra chars
|
int n_extra = 0; // number of extra chars
|
||||||
char_u *p_extra = NULL; // string of extra chars, plus NUL
|
char *p_extra = NULL; // string of extra chars, plus NUL
|
||||||
char_u *p_extra_free = NULL; // p_extra needs to be freed
|
char *p_extra_free = NULL; // p_extra needs to be freed
|
||||||
int c_extra = NUL; // extra chars, all the same
|
int c_extra = NUL; // extra chars, all the same
|
||||||
int c_final = NUL; // final char, mandatory if set
|
int c_final = NUL; // final char, mandatory if set
|
||||||
int extra_attr = 0; // attributes when n_extra != 0
|
int extra_attr = 0; // attributes when n_extra != 0
|
||||||
@ -565,7 +565,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
int *color_cols = NULL; // pointer to according columns array
|
int *color_cols = NULL; // pointer to according columns array
|
||||||
bool has_spell = false; // this buffer has spell checking
|
bool has_spell = false; // this buffer has spell checking
|
||||||
#define SPWORDLEN 150
|
#define SPWORDLEN 150
|
||||||
char_u nextline[SPWORDLEN * 2]; // text with start of the next line
|
char nextline[SPWORDLEN * 2]; // text with start of the next line
|
||||||
int nextlinecol = 0; // column where nextline[] starts
|
int nextlinecol = 0; // column where nextline[] starts
|
||||||
int nextline_idx = 0; // index in nextline[] where next line
|
int nextline_idx = 0; // index in nextline[] where next line
|
||||||
// starts
|
// starts
|
||||||
@ -707,8 +707,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
// Trick: skip a few chars for C/shell/Vim comments
|
// Trick: skip a few chars for C/shell/Vim comments
|
||||||
nextline[SPWORDLEN] = NUL;
|
nextline[SPWORDLEN] = NUL;
|
||||||
if (lnum < wp->w_buffer->b_ml.ml_line_count) {
|
if (lnum < wp->w_buffer->b_ml.ml_line_count) {
|
||||||
line = (char_u *)ml_get_buf(wp->w_buffer, lnum + 1, false);
|
line = ml_get_buf(wp->w_buffer, lnum + 1, false);
|
||||||
spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN);
|
spell_cat_line((char_u *)nextline + SPWORDLEN, (char_u *)line, SPWORDLEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When a word wrapped from the previous line the start of the current
|
// When a word wrapped from the previous line the start of the current
|
||||||
@ -887,13 +887,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
line_attr_lowprio_save = line_attr_lowprio;
|
line_attr_lowprio_save = line_attr_lowprio;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = end_fill ? (char_u *)"" : (char_u *)ml_get_buf(wp->w_buffer, lnum, false);
|
line = end_fill ? "" : ml_get_buf(wp->w_buffer, lnum, false);
|
||||||
ptr = line;
|
ptr = line;
|
||||||
|
|
||||||
if (has_spell && !number_only) {
|
if (has_spell && !number_only) {
|
||||||
// For checking first word with a capital skip white space.
|
// For checking first word with a capital skip white space.
|
||||||
if (cap_col == 0) {
|
if (cap_col == 0) {
|
||||||
cap_col = (int)getwhitecols((char *)line);
|
cap_col = (int)getwhitecols(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be able to spell-check over line boundaries copy the end of the
|
// To be able to spell-check over line boundaries copy the end of the
|
||||||
@ -904,7 +904,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
nextlinecol = MAXCOL;
|
nextlinecol = MAXCOL;
|
||||||
nextline_idx = 0;
|
nextline_idx = 0;
|
||||||
} else {
|
} else {
|
||||||
v = (long)STRLEN(line);
|
v = (long)strlen(line);
|
||||||
if (v < SPWORDLEN) {
|
if (v < SPWORDLEN) {
|
||||||
// Short line, use it completely and append the start of the
|
// Short line, use it completely and append the start of the
|
||||||
// next line.
|
// next line.
|
||||||
@ -932,7 +932,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
}
|
}
|
||||||
// find start of trailing whitespace
|
// find start of trailing whitespace
|
||||||
if (wp->w_p_lcs_chars.trail) {
|
if (wp->w_p_lcs_chars.trail) {
|
||||||
trailcol = (colnr_T)STRLEN(ptr);
|
trailcol = (colnr_T)strlen(ptr);
|
||||||
while (trailcol > (colnr_T)0 && ascii_iswhite(ptr[trailcol - 1])) {
|
while (trailcol > (colnr_T)0 && ascii_iswhite(ptr[trailcol - 1])) {
|
||||||
trailcol--;
|
trailcol--;
|
||||||
}
|
}
|
||||||
@ -962,19 +962,19 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
v = wp->w_leftcol;
|
v = wp->w_leftcol;
|
||||||
}
|
}
|
||||||
if (v > 0 && !number_only) {
|
if (v > 0 && !number_only) {
|
||||||
char_u *prev_ptr = ptr;
|
char *prev_ptr = ptr;
|
||||||
chartabsize_T cts;
|
chartabsize_T cts;
|
||||||
int charsize;
|
int charsize;
|
||||||
|
|
||||||
init_chartabsize_arg(&cts, wp, lnum, (colnr_T)vcol, (char *)line, (char *)ptr);
|
init_chartabsize_arg(&cts, wp, lnum, (colnr_T)vcol, line, ptr);
|
||||||
while (cts.cts_vcol < v && *cts.cts_ptr != NUL) {
|
while (cts.cts_vcol < v && *cts.cts_ptr != NUL) {
|
||||||
charsize = win_lbr_chartabsize(&cts, NULL);
|
charsize = win_lbr_chartabsize(&cts, NULL);
|
||||||
cts.cts_vcol += charsize;
|
cts.cts_vcol += charsize;
|
||||||
prev_ptr = (char_u *)cts.cts_ptr;
|
prev_ptr = cts.cts_ptr;
|
||||||
MB_PTR_ADV(cts.cts_ptr);
|
MB_PTR_ADV(cts.cts_ptr);
|
||||||
}
|
}
|
||||||
vcol = cts.cts_vcol;
|
vcol = cts.cts_vcol;
|
||||||
ptr = (char_u *)cts.cts_ptr;
|
ptr = cts.cts_ptr;
|
||||||
clear_chartabsize_arg(&cts);
|
clear_chartabsize_arg(&cts);
|
||||||
|
|
||||||
// When:
|
// When:
|
||||||
@ -997,7 +997,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
ptr = prev_ptr;
|
ptr = prev_ptr;
|
||||||
// If the character fits on the screen, don't need to skip it.
|
// If the character fits on the screen, don't need to skip it.
|
||||||
// Except for a TAB.
|
// Except for a TAB.
|
||||||
if (utf_ptr2cells((char *)ptr) >= charsize || *ptr == TAB) {
|
if (utf_ptr2cells(ptr) >= charsize || *ptr == TAB) {
|
||||||
n_skip = (int)(v - vcol);
|
n_skip = (int)(v - vcol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1027,14 +1027,14 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
len = spell_move_to(wp, FORWARD, true, true, &spell_hlf);
|
len = spell_move_to(wp, FORWARD, true, true, &spell_hlf);
|
||||||
|
|
||||||
// spell_move_to() may call ml_get() and make "line" invalid
|
// spell_move_to() may call ml_get() and make "line" invalid
|
||||||
line = (char_u *)ml_get_buf(wp->w_buffer, lnum, false);
|
line = ml_get_buf(wp->w_buffer, lnum, false);
|
||||||
ptr = line + linecol;
|
ptr = line + linecol;
|
||||||
|
|
||||||
if (len == 0 || (int)wp->w_cursor.col > ptr - line) {
|
if (len == 0 || (int)wp->w_cursor.col > ptr - line) {
|
||||||
// no bad word found at line start, don't check until end of a
|
// no bad word found at line start, don't check until end of a
|
||||||
// word
|
// word
|
||||||
spell_hlf = HLF_COUNT;
|
spell_hlf = HLF_COUNT;
|
||||||
word_end = (int)(spell_to_word_end(ptr, wp) - line + 1);
|
word_end = (int)(spell_to_word_end((char_u *)ptr, wp) - (char_u *)line + 1);
|
||||||
} else {
|
} else {
|
||||||
// bad word found, use attributes until end of word
|
// bad word found, use attributes until end of word
|
||||||
assert(len <= INT_MAX);
|
assert(len <= INT_MAX);
|
||||||
@ -1134,7 +1134,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
// already be in use.
|
// already be in use.
|
||||||
xfree(p_extra_free);
|
xfree(p_extra_free);
|
||||||
p_extra_free = xmalloc(MAX_MCO * (size_t)fdc + 1);
|
p_extra_free = xmalloc(MAX_MCO * (size_t)fdc + 1);
|
||||||
n_extra = (int)fill_foldcolumn(p_extra_free, wp, foldinfo, lnum);
|
n_extra = (int)fill_foldcolumn((char_u *)p_extra_free, wp, foldinfo, lnum);
|
||||||
p_extra_free[n_extra] = NUL;
|
p_extra_free[n_extra] = NUL;
|
||||||
p_extra = p_extra_free;
|
p_extra = p_extra_free;
|
||||||
c_extra = NUL;
|
c_extra = NUL;
|
||||||
@ -1154,7 +1154,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
if (wp->w_scwidth > 0) {
|
if (wp->w_scwidth > 0) {
|
||||||
get_sign_display_info(false, wp, lnum, sattrs, row,
|
get_sign_display_info(false, wp, lnum, sattrs, row,
|
||||||
startrow, filler_lines, filler_todo,
|
startrow, filler_lines, filler_todo,
|
||||||
&c_extra, &c_final, extra, sizeof(extra),
|
&c_extra, &c_final, (char *)extra, sizeof(extra),
|
||||||
&p_extra, &n_extra, &char_attr, sign_idx,
|
&p_extra, &n_extra, &char_attr, sign_idx,
|
||||||
sign_cul_attr);
|
sign_cul_attr);
|
||||||
sign_idx++;
|
sign_idx++;
|
||||||
@ -1179,7 +1179,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u' && num_signs > 0) {
|
if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u' && num_signs > 0) {
|
||||||
get_sign_display_info(true, wp, lnum, sattrs, row,
|
get_sign_display_info(true, wp, lnum, sattrs, row,
|
||||||
startrow, filler_lines, filler_todo,
|
startrow, filler_lines, filler_todo,
|
||||||
&c_extra, &c_final, extra, sizeof(extra),
|
&c_extra, &c_final, (char *)extra, sizeof(extra),
|
||||||
&p_extra, &n_extra, &char_attr, sign_idx,
|
&p_extra, &n_extra, &char_attr, sign_idx,
|
||||||
sign_cul_attr);
|
sign_cul_attr);
|
||||||
} else {
|
} else {
|
||||||
@ -1187,7 +1187,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
if (row == startrow + filler_lines) {
|
if (row == startrow + filler_lines) {
|
||||||
get_line_number_str(wp, lnum, (char_u *)extra, sizeof(extra));
|
get_line_number_str(wp, lnum, (char_u *)extra, sizeof(extra));
|
||||||
if (wp->w_skipcol > 0) {
|
if (wp->w_skipcol > 0) {
|
||||||
for (p_extra = extra; *p_extra == ' '; p_extra++) {
|
for (p_extra = (char *)extra; *p_extra == ' '; p_extra++) {
|
||||||
*p_extra = '-';
|
*p_extra = '-';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1201,7 +1201,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
*p2 = t;
|
*p2 = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p_extra = extra;
|
p_extra = (char *)extra;
|
||||||
c_extra = NUL;
|
c_extra = NUL;
|
||||||
} else {
|
} else {
|
||||||
c_extra = ' ';
|
c_extra = ' ';
|
||||||
@ -1292,18 +1292,18 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
}
|
}
|
||||||
char_attr = win_hl_attr(wp, HLF_DED);
|
char_attr = win_hl_attr(wp, HLF_DED);
|
||||||
}
|
}
|
||||||
char_u *const sbr = get_showbreak_value(wp);
|
char *const sbr = (char *)get_showbreak_value(wp);
|
||||||
if (*sbr != NUL && need_showbreak) {
|
if (*sbr != NUL && need_showbreak) {
|
||||||
// Draw 'showbreak' at the start of each broken line.
|
// Draw 'showbreak' at the start of each broken line.
|
||||||
p_extra = sbr;
|
p_extra = sbr;
|
||||||
c_extra = NUL;
|
c_extra = NUL;
|
||||||
c_final = NUL;
|
c_final = NUL;
|
||||||
n_extra = (int)STRLEN(sbr);
|
n_extra = (int)strlen(sbr);
|
||||||
char_attr = win_hl_attr(wp, HLF_AT);
|
char_attr = win_hl_attr(wp, HLF_AT);
|
||||||
if (wp->w_skipcol == 0 || !wp->w_p_wrap) {
|
if (wp->w_skipcol == 0 || !wp->w_p_wrap) {
|
||||||
need_showbreak = false;
|
need_showbreak = false;
|
||||||
}
|
}
|
||||||
vcol_sbr = vcol + mb_charlen(sbr);
|
vcol_sbr = vcol + mb_charlen((char_u *)sbr);
|
||||||
// Correct end of highlighted area for 'showbreak',
|
// Correct end of highlighted area for 'showbreak',
|
||||||
// required when 'linebreak' is also set.
|
// required when 'linebreak' is also set.
|
||||||
if (tocol == vcol) {
|
if (tocol == vcol) {
|
||||||
@ -1330,7 +1330,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
n_extra = saved_n_extra;
|
n_extra = saved_n_extra;
|
||||||
c_extra = saved_c_extra;
|
c_extra = saved_c_extra;
|
||||||
c_final = saved_c_final;
|
c_final = saved_c_final;
|
||||||
p_extra = saved_p_extra;
|
p_extra = (char *)saved_p_extra;
|
||||||
char_attr = saved_char_attr;
|
char_attr = saved_char_attr;
|
||||||
} else {
|
} else {
|
||||||
char_attr = 0;
|
char_attr = 0;
|
||||||
@ -1372,10 +1372,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
|
|
||||||
linenr_T lnume = lnum + foldinfo.fi_lines - 1;
|
linenr_T lnume = lnum + foldinfo.fi_lines - 1;
|
||||||
memset(buf_fold, ' ', FOLD_TEXT_LEN);
|
memset(buf_fold, ' ', FOLD_TEXT_LEN);
|
||||||
p_extra = (char_u *)get_foldtext(wp, lnum, lnume, foldinfo, (char *)buf_fold);
|
p_extra = get_foldtext(wp, lnum, lnume, foldinfo, (char *)buf_fold);
|
||||||
n_extra = (int)STRLEN(p_extra);
|
n_extra = (int)strlen(p_extra);
|
||||||
|
|
||||||
if (p_extra != buf_fold) {
|
if (p_extra != (char *)buf_fold) {
|
||||||
xfree(p_extra_free);
|
xfree(p_extra_free);
|
||||||
p_extra_free = p_extra;
|
p_extra_free = p_extra;
|
||||||
}
|
}
|
||||||
@ -1409,7 +1409,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
// handle Visual or match highlighting in this line
|
// handle Visual or match highlighting in this line
|
||||||
if (vcol == fromcol
|
if (vcol == fromcol
|
||||||
|| (vcol + 1 == fromcol && n_extra == 0
|
|| (vcol + 1 == fromcol && n_extra == 0
|
||||||
&& utf_ptr2cells((char *)ptr) > 1)
|
&& utf_ptr2cells(ptr) > 1)
|
||||||
|| ((int)vcol_prev == fromcol_prev
|
|| ((int)vcol_prev == fromcol_prev
|
||||||
&& vcol_prev < vcol // not at margin
|
&& vcol_prev < vcol // not at margin
|
||||||
&& vcol < tocol)) {
|
&& vcol < tocol)) {
|
||||||
@ -1503,16 +1503,16 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
mb_utf8 = check_mb_utf8(&c, u8cc);
|
mb_utf8 = check_mb_utf8(&c, u8cc);
|
||||||
} else {
|
} else {
|
||||||
assert(p_extra != NULL);
|
assert(p_extra != NULL);
|
||||||
c = *p_extra;
|
c = (uint8_t)(*p_extra);
|
||||||
mb_c = c;
|
mb_c = c;
|
||||||
// If the UTF-8 character is more than one byte:
|
// If the UTF-8 character is more than one byte:
|
||||||
// Decode it into "mb_c".
|
// Decode it into "mb_c".
|
||||||
mb_l = utfc_ptr2len((char *)p_extra);
|
mb_l = utfc_ptr2len(p_extra);
|
||||||
mb_utf8 = false;
|
mb_utf8 = false;
|
||||||
if (mb_l > n_extra) {
|
if (mb_l > n_extra) {
|
||||||
mb_l = 1;
|
mb_l = 1;
|
||||||
} else if (mb_l > 1) {
|
} else if (mb_l > 1) {
|
||||||
mb_c = utfc_ptr2char((char *)p_extra, u8cc);
|
mb_c = utfc_ptr2char(p_extra, u8cc);
|
||||||
mb_utf8 = true;
|
mb_utf8 = true;
|
||||||
c = 0xc0;
|
c = 0xc0;
|
||||||
}
|
}
|
||||||
@ -1556,14 +1556,14 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
XFREE_CLEAR(p_extra_free);
|
XFREE_CLEAR(p_extra_free);
|
||||||
|
|
||||||
// Get a character from the line itself.
|
// Get a character from the line itself.
|
||||||
c0 = c = *ptr;
|
c0 = c = (uint8_t)(*ptr);
|
||||||
mb_c = c;
|
mb_c = c;
|
||||||
// If the UTF-8 character is more than one byte: Decode it
|
// If the UTF-8 character is more than one byte: Decode it
|
||||||
// into "mb_c".
|
// into "mb_c".
|
||||||
mb_l = utfc_ptr2len((char *)ptr);
|
mb_l = utfc_ptr2len(ptr);
|
||||||
mb_utf8 = false;
|
mb_utf8 = false;
|
||||||
if (mb_l > 1) {
|
if (mb_l > 1) {
|
||||||
mb_c = utfc_ptr2char((char *)ptr, u8cc);
|
mb_c = utfc_ptr2char(ptr, u8cc);
|
||||||
// Overlong encoded ASCII or ASCII with composing char
|
// Overlong encoded ASCII or ASCII with composing char
|
||||||
// is displayed normally, except a NUL.
|
// is displayed normally, except a NUL.
|
||||||
if (mb_c < 0x80) {
|
if (mb_c < 0x80) {
|
||||||
@ -1594,11 +1594,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
rl_mirror((char *)extra);
|
rl_mirror((char *)extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_extra = extra;
|
p_extra = (char *)extra;
|
||||||
c = *p_extra;
|
c = (uint8_t)(*p_extra);
|
||||||
mb_c = mb_ptr2char_adv((const char_u **)&p_extra);
|
mb_c = mb_ptr2char_adv((const char_u **)&p_extra);
|
||||||
mb_utf8 = (c >= 0x80);
|
mb_utf8 = (c >= 0x80);
|
||||||
n_extra = (int)STRLEN(p_extra);
|
n_extra = (int)strlen(p_extra);
|
||||||
c_extra = NUL;
|
c_extra = NUL;
|
||||||
c_final = NUL;
|
c_final = NUL;
|
||||||
if (area_attr == 0 && search_attr == 0) {
|
if (area_attr == 0 && search_attr == 0) {
|
||||||
@ -1618,10 +1618,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
if (wp->w_p_rl) {
|
if (wp->w_p_rl) {
|
||||||
pc = prev_c;
|
pc = prev_c;
|
||||||
pc1 = prev_c1;
|
pc1 = prev_c1;
|
||||||
nc = utf_ptr2char((char *)ptr + mb_l);
|
nc = utf_ptr2char(ptr + mb_l);
|
||||||
prev_c1 = u8cc[0];
|
prev_c1 = u8cc[0];
|
||||||
} else {
|
} else {
|
||||||
pc = utfc_ptr2char((char *)ptr + mb_l, pcc);
|
pc = utfc_ptr2char(ptr + mb_l, pcc);
|
||||||
nc = prev_c;
|
nc = prev_c;
|
||||||
pc1 = pcc[0];
|
pc1 = pcc[0];
|
||||||
}
|
}
|
||||||
@ -1697,7 +1697,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
|
|
||||||
// Need to get the line again, a multi-line regexp may
|
// Need to get the line again, a multi-line regexp may
|
||||||
// have made it invalid.
|
// have made it invalid.
|
||||||
line = (char_u *)ml_get_buf(wp->w_buffer, lnum, false);
|
line = ml_get_buf(wp->w_buffer, lnum, false);
|
||||||
ptr = line + v;
|
ptr = line + v;
|
||||||
|
|
||||||
if (!attr_pri) {
|
if (!attr_pri) {
|
||||||
@ -1754,8 +1754,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
char_attr = hl_combine_attr(char_attr, syntax_attr);
|
char_attr = hl_combine_attr(char_attr, syntax_attr);
|
||||||
}
|
}
|
||||||
if (c != 0 && ((!has_syntax && !no_plain_buffer) || can_spell)) {
|
if (c != 0 && ((!has_syntax && !no_plain_buffer) || can_spell)) {
|
||||||
char_u *prev_ptr;
|
char *prev_ptr;
|
||||||
char_u *p;
|
char *p;
|
||||||
int len;
|
int len;
|
||||||
hlf_T spell_hlf = HLF_COUNT;
|
hlf_T spell_hlf = HLF_COUNT;
|
||||||
prev_ptr = ptr - mb_l;
|
prev_ptr = ptr - mb_l;
|
||||||
@ -1769,7 +1769,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
p = prev_ptr;
|
p = prev_ptr;
|
||||||
}
|
}
|
||||||
cap_col -= (int)(prev_ptr - line);
|
cap_col -= (int)(prev_ptr - line);
|
||||||
size_t tmplen = spell_check(wp, p, &spell_hlf, &cap_col, nochange);
|
size_t tmplen = spell_check(wp, (char_u *)p, &spell_hlf, &cap_col, nochange);
|
||||||
assert(tmplen <= INT_MAX);
|
assert(tmplen <= INT_MAX);
|
||||||
len = (int)tmplen;
|
len = (int)tmplen;
|
||||||
word_end = (int)v + len;
|
word_end = (int)v + len;
|
||||||
@ -1829,11 +1829,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
// Found last space before word: check for line break.
|
// Found last space before word: check for line break.
|
||||||
if (wp->w_p_lbr && c0 == c && vim_isbreak(c)
|
if (wp->w_p_lbr && c0 == c && vim_isbreak(c)
|
||||||
&& !vim_isbreak((int)(*ptr))) {
|
&& !vim_isbreak((int)(*ptr))) {
|
||||||
int mb_off = utf_head_off((char *)line, (char *)ptr - 1);
|
int mb_off = utf_head_off(line, ptr - 1);
|
||||||
char_u *p = ptr - (mb_off + 1);
|
char *p = ptr - (mb_off + 1);
|
||||||
chartabsize_T cts;
|
chartabsize_T cts;
|
||||||
|
|
||||||
init_chartabsize_arg(&cts, wp, lnum, (colnr_T)vcol, (char *)line, (char *)p);
|
init_chartabsize_arg(&cts, wp, lnum, (colnr_T)vcol, line, p);
|
||||||
n_extra = win_lbr_chartabsize(&cts, NULL) - 1;
|
n_extra = win_lbr_chartabsize(&cts, NULL) - 1;
|
||||||
|
|
||||||
// We have just drawn the showbreak value, no need to add
|
// We have just drawn the showbreak value, no need to add
|
||||||
@ -1979,7 +1979,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
memset(p, ' ', (size_t)len);
|
memset(p, ' ', (size_t)len);
|
||||||
p[len] = NUL;
|
p[len] = NUL;
|
||||||
xfree(p_extra_free);
|
xfree(p_extra_free);
|
||||||
p_extra_free = p;
|
p_extra_free = (char *)p;
|
||||||
for (i = 0; i < tab_len; i++) {
|
for (i = 0; i < tab_len; i++) {
|
||||||
if (*p == NUL) {
|
if (*p == NUL) {
|
||||||
tab_len = i;
|
tab_len = i;
|
||||||
@ -2065,7 +2065,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
&& tocol != MAXCOL && vcol < tocol) {
|
&& tocol != MAXCOL && vcol < tocol) {
|
||||||
n_extra = 0;
|
n_extra = 0;
|
||||||
} else {
|
} else {
|
||||||
p_extra = at_end_str;
|
p_extra = (char *)at_end_str;
|
||||||
n_extra = 1;
|
n_extra = 1;
|
||||||
c_extra = NUL;
|
c_extra = NUL;
|
||||||
c_final = NUL;
|
c_final = NUL;
|
||||||
@ -2083,28 +2083,28 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
mb_c = c;
|
mb_c = c;
|
||||||
mb_utf8 = check_mb_utf8(&c, u8cc);
|
mb_utf8 = check_mb_utf8(&c, u8cc);
|
||||||
} else if (c != NUL) {
|
} else if (c != NUL) {
|
||||||
p_extra = transchar_buf(wp->w_buffer, c);
|
p_extra = (char *)transchar_buf(wp->w_buffer, c);
|
||||||
if (n_extra == 0) {
|
if (n_extra == 0) {
|
||||||
n_extra = byte2cells(c) - 1;
|
n_extra = byte2cells(c) - 1;
|
||||||
}
|
}
|
||||||
if ((dy_flags & DY_UHEX) && wp->w_p_rl) {
|
if ((dy_flags & DY_UHEX) && wp->w_p_rl) {
|
||||||
rl_mirror((char *)p_extra); // reverse "<12>"
|
rl_mirror(p_extra); // reverse "<12>"
|
||||||
}
|
}
|
||||||
c_extra = NUL;
|
c_extra = NUL;
|
||||||
c_final = NUL;
|
c_final = NUL;
|
||||||
if (wp->w_p_lbr) {
|
if (wp->w_p_lbr) {
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
c = *p_extra;
|
c = (uint8_t)(*p_extra);
|
||||||
p = xmalloc((size_t)n_extra + 1);
|
p = xmalloc((size_t)n_extra + 1);
|
||||||
memset(p, ' ', (size_t)n_extra);
|
memset(p, ' ', (size_t)n_extra);
|
||||||
STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1); // NOLINT(runtime/printf)
|
STRNCPY(p, p_extra + 1, strlen(p_extra) - 1); // NOLINT(runtime/printf)
|
||||||
p[n_extra] = NUL;
|
p[n_extra] = NUL;
|
||||||
xfree(p_extra_free);
|
xfree(p_extra_free);
|
||||||
p_extra_free = p_extra = p;
|
p_extra_free = p_extra = (char *)p;
|
||||||
} else {
|
} else {
|
||||||
n_extra = byte2cells(c) - 1;
|
n_extra = byte2cells(c) - 1;
|
||||||
c = *p_extra++;
|
c = (uint8_t)(*p_extra++);
|
||||||
}
|
}
|
||||||
n_attr = n_extra + 1;
|
n_attr = n_extra + 1;
|
||||||
extra_attr = win_hl_attr(wp, HLF_8);
|
extra_attr = win_hl_attr(wp, HLF_8);
|
||||||
@ -2616,7 +2616,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
|| *ptr != NUL
|
|| *ptr != NUL
|
||||||
|| filler_todo > 0
|
|| filler_todo > 0
|
||||||
|| (wp->w_p_list && wp->w_p_lcs_chars.eol != NUL
|
|| (wp->w_p_list && wp->w_p_lcs_chars.eol != NUL
|
||||||
&& p_extra != at_end_str)
|
&& p_extra != (char *)at_end_str)
|
||||||
|| (n_extra != 0
|
|| (n_extra != 0
|
||||||
&& (c_extra != NUL || *p_extra != NUL)))) {
|
&& (c_extra != NUL || *p_extra != NUL)))) {
|
||||||
bool wrap = wp->w_p_wrap // Wrapping enabled.
|
bool wrap = wp->w_p_wrap // Wrapping enabled.
|
||||||
@ -2686,7 +2686,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
// reset the drawing state for the start of a wrapped line
|
// reset the drawing state for the start of a wrapped line
|
||||||
draw_state = WL_START;
|
draw_state = WL_START;
|
||||||
saved_n_extra = n_extra;
|
saved_n_extra = n_extra;
|
||||||
saved_p_extra = p_extra;
|
saved_p_extra = (char_u *)p_extra;
|
||||||
saved_c_extra = c_extra;
|
saved_c_extra = c_extra;
|
||||||
saved_c_final = c_final;
|
saved_c_final = c_final;
|
||||||
saved_char_attr = char_attr;
|
saved_char_attr = char_attr;
|
||||||
@ -2705,7 +2705,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
} // for every character in the line
|
} // for every character in the line
|
||||||
|
|
||||||
// After an empty line check first word for capital.
|
// After an empty line check first word for capital.
|
||||||
if (*skipwhite((char *)line) == NUL) {
|
if (*skipwhite(line) == NUL) {
|
||||||
capcol_lnum = lnum + 1;
|
capcol_lnum = lnum + 1;
|
||||||
cap_col = 0;
|
cap_col = 0;
|
||||||
}
|
}
|
||||||
|
@ -4593,7 +4593,7 @@ static bool ins_tab(void)
|
|||||||
// Delete following spaces.
|
// Delete following spaces.
|
||||||
i = cursor->col - fpos.col;
|
i = cursor->col - fpos.col;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
STRMOVE(ptr, ptr + i);
|
STRMOVE(ptr, (char *)ptr + i);
|
||||||
// correct replace stack.
|
// correct replace stack.
|
||||||
if ((State & REPLACE_FLAG)
|
if ((State & REPLACE_FLAG)
|
||||||
&& !(State & VREPLACE_FLAG)) {
|
&& !(State & VREPLACE_FLAG)) {
|
||||||
|
@ -407,11 +407,11 @@ void eval_init(void)
|
|||||||
|
|
||||||
// add to v: scope dict, unless the value is not always available
|
// add to v: scope dict, unless the value is not always available
|
||||||
if (p->vv_type != VAR_UNKNOWN) {
|
if (p->vv_type != VAR_UNKNOWN) {
|
||||||
hash_add(&vimvarht, p->vv_di.di_key);
|
hash_add(&vimvarht, (char *)p->vv_di.di_key);
|
||||||
}
|
}
|
||||||
if (p->vv_flags & VV_COMPAT) {
|
if (p->vv_flags & VV_COMPAT) {
|
||||||
// add to compat scope dict
|
// add to compat scope dict
|
||||||
hash_add(&compat_hashtab, p->vv_di.di_key);
|
hash_add(&compat_hashtab, (char *)p->vv_di.di_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
|
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
|
||||||
@ -1012,7 +1012,7 @@ void prepare_vimvar(int idx, typval_T *save_tv)
|
|||||||
{
|
{
|
||||||
*save_tv = vimvars[idx].vv_tv;
|
*save_tv = vimvars[idx].vv_tv;
|
||||||
if (vimvars[idx].vv_type == VAR_UNKNOWN) {
|
if (vimvars[idx].vv_type == VAR_UNKNOWN) {
|
||||||
hash_add(&vimvarht, vimvars[idx].vv_di.di_key);
|
hash_add(&vimvarht, (char *)vimvars[idx].vv_di.di_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2143,9 +2143,9 @@ char *get_user_var_name(expand_T *xp, int idx)
|
|||||||
hi++;
|
hi++;
|
||||||
}
|
}
|
||||||
if (STRNCMP("g:", xp->xp_pattern, 2) == 0) {
|
if (STRNCMP("g:", xp->xp_pattern, 2) == 0) {
|
||||||
return cat_prefix_varname('g', (char *)hi->hi_key);
|
return cat_prefix_varname('g', hi->hi_key);
|
||||||
}
|
}
|
||||||
return (char *)hi->hi_key;
|
return hi->hi_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// b: variables
|
// b: variables
|
||||||
@ -2159,7 +2159,7 @@ char *get_user_var_name(expand_T *xp, int idx)
|
|||||||
while (HASHITEM_EMPTY(hi)) {
|
while (HASHITEM_EMPTY(hi)) {
|
||||||
hi++;
|
hi++;
|
||||||
}
|
}
|
||||||
return cat_prefix_varname('b', (char *)hi->hi_key);
|
return cat_prefix_varname('b', hi->hi_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// w: variables
|
// w: variables
|
||||||
@ -2173,7 +2173,7 @@ char *get_user_var_name(expand_T *xp, int idx)
|
|||||||
while (HASHITEM_EMPTY(hi)) {
|
while (HASHITEM_EMPTY(hi)) {
|
||||||
hi++;
|
hi++;
|
||||||
}
|
}
|
||||||
return cat_prefix_varname('w', (char *)hi->hi_key);
|
return cat_prefix_varname('w', hi->hi_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// t: variables
|
// t: variables
|
||||||
@ -2187,7 +2187,7 @@ char *get_user_var_name(expand_T *xp, int idx)
|
|||||||
while (HASHITEM_EMPTY(hi)) {
|
while (HASHITEM_EMPTY(hi)) {
|
||||||
hi++;
|
hi++;
|
||||||
}
|
}
|
||||||
return cat_prefix_varname('t', (char *)hi->hi_key);
|
return cat_prefix_varname('t', hi->hi_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// v: variables
|
// v: variables
|
||||||
@ -7947,7 +7947,7 @@ const void *var_shada_iter(const void *const iter, const char **const name, typv
|
|||||||
hi = globvarht.ht_array;
|
hi = globvarht.ht_array;
|
||||||
while ((size_t)(hi - hifirst) < hinum
|
while ((size_t)(hi - hifirst) < hinum
|
||||||
&& (HASHITEM_EMPTY(hi)
|
&& (HASHITEM_EMPTY(hi)
|
||||||
|| !(var_flavour((char *)hi->hi_key) & flavour))) {
|
|| !(var_flavour(hi->hi_key) & flavour))) {
|
||||||
hi++;
|
hi++;
|
||||||
}
|
}
|
||||||
if ((size_t)(hi - hifirst) == hinum) {
|
if ((size_t)(hi - hifirst) == hinum) {
|
||||||
@ -7959,7 +7959,7 @@ const void *var_shada_iter(const void *const iter, const char **const name, typv
|
|||||||
*name = (char *)TV_DICT_HI2DI(hi)->di_key;
|
*name = (char *)TV_DICT_HI2DI(hi)->di_key;
|
||||||
tv_copy(&TV_DICT_HI2DI(hi)->di_tv, rettv);
|
tv_copy(&TV_DICT_HI2DI(hi)->di_tv, rettv);
|
||||||
while ((size_t)(++hi - hifirst) < hinum) {
|
while ((size_t)(++hi - hifirst) < hinum) {
|
||||||
if (!HASHITEM_EMPTY(hi) && (var_flavour((char *)hi->hi_key) & flavour)) {
|
if (!HASHITEM_EMPTY(hi) && (var_flavour(hi->hi_key) & flavour)) {
|
||||||
return hi;
|
return hi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8352,7 +8352,7 @@ repeat:
|
|||||||
if (c != NUL) {
|
if (c != NUL) {
|
||||||
(*fnamep)[*fnamelen] = NUL;
|
(*fnamep)[*fnamelen] = NUL;
|
||||||
}
|
}
|
||||||
p = (char *)vim_strsave_shellescape((char_u *)(*fnamep), false, false);
|
p = vim_strsave_shellescape(*fnamep, false, false);
|
||||||
if (c != NUL) {
|
if (c != NUL) {
|
||||||
(*fnamep)[*fnamelen] = (char)c;
|
(*fnamep)[*fnamelen] = (char)c;
|
||||||
}
|
}
|
||||||
|
@ -136,9 +136,9 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
|
|||||||
typval_T key_tv = {
|
typval_T key_tv = {
|
||||||
.v_type = VAR_STRING,
|
.v_type = VAR_STRING,
|
||||||
.vval = { .v_string =
|
.vval = { .v_string =
|
||||||
(char *)(v.data.d.hi ==
|
(v.data.d.hi ==
|
||||||
NULL ? v.data.d.dict->dv_hashtab.ht_array : (v.data.d.hi -
|
NULL ? v.data.d.dict->dv_hashtab.ht_array : (v.data.d.hi -
|
||||||
1))->hi_key },
|
1))->hi_key },
|
||||||
};
|
};
|
||||||
char *const key = encode_tv2string(&key_tv, NULL);
|
char *const key = encode_tv2string(&key_tv, NULL);
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, key_msg, key);
|
vim_snprintf((char *)IObuff, IOSIZE, key_msg, key);
|
||||||
|
@ -47,7 +47,7 @@ static inline ListReaderState encode_init_lrstate(const list_T *const list)
|
|||||||
.offset = 0,
|
.offset = 0,
|
||||||
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
|
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
|
||||||
? 0
|
? 0
|
||||||
: STRLEN(TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string)),
|
: strlen(TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7996,8 +7996,7 @@ static void f_shellescape(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
const bool do_special = non_zero_arg(&argvars[1]);
|
const bool do_special = non_zero_arg(&argvars[1]);
|
||||||
|
|
||||||
rettv->vval.v_string =
|
rettv->vval.v_string =
|
||||||
(char *)vim_strsave_shellescape((const char_u *)tv_get_string(&argvars[0]), do_special,
|
vim_strsave_shellescape(tv_get_string(&argvars[0]), do_special, do_special);
|
||||||
do_special);
|
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2098,7 +2098,7 @@ char **tv_dict_to_env(dict_T *denv)
|
|||||||
TV_DICT_ITER(denv, var, {
|
TV_DICT_ITER(denv, var, {
|
||||||
const char *str = tv_get_string(&var->di_tv);
|
const char *str = tv_get_string(&var->di_tv);
|
||||||
assert(str);
|
assert(str);
|
||||||
size_t len = STRLEN(var->di_key) + strlen(str) + strlen("=") + 1;
|
size_t len = strlen((char *)var->di_key) + strlen(str) + strlen("=") + 1;
|
||||||
env[i] = xmalloc(len);
|
env[i] = xmalloc(len);
|
||||||
snprintf(env[i], len, "%s=%s", (char *)var->di_key, str);
|
snprintf(env[i], len, "%s=%s", (char *)var->di_key, str);
|
||||||
i++;
|
i++;
|
||||||
@ -2230,7 +2230,7 @@ int tv_dict_add(dict_T *const d, dictitem_T *const item)
|
|||||||
if (tv_dict_wrong_func_name(d, &item->di_tv, (const char *)item->di_key)) {
|
if (tv_dict_wrong_func_name(d, &item->di_tv, (const char *)item->di_key)) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
return hash_add(&d->dv_hashtab, item->di_key);
|
return hash_add(&d->dv_hashtab, (char *)item->di_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a list entry to dictionary
|
/// Add a list entry to dictionary
|
||||||
@ -2586,7 +2586,7 @@ dict_T *tv_dict_copy(const vimconv_T *const conv, dict_T *const orig, const bool
|
|||||||
if (conv == NULL || conv->vc_type == CONV_NONE) {
|
if (conv == NULL || conv->vc_type == CONV_NONE) {
|
||||||
new_di = tv_dict_item_alloc((const char *)di->di_key);
|
new_di = tv_dict_item_alloc((const char *)di->di_key);
|
||||||
} else {
|
} else {
|
||||||
size_t len = STRLEN(di->di_key);
|
size_t len = strlen((char *)di->di_key);
|
||||||
char *const key = (char *)string_convert(conv, (char *)di->di_key, &len);
|
char *const key = (char *)string_convert(conv, (char *)di->di_key, &len);
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
new_di = tv_dict_item_alloc_len((const char *)di->di_key, len);
|
new_di = tv_dict_item_alloc_len((const char *)di->di_key, len);
|
||||||
|
@ -339,7 +339,7 @@ struct ufunc {
|
|||||||
funccall_T *uf_scoped; ///< l: local variables for closure
|
funccall_T *uf_scoped; ///< l: local variables for closure
|
||||||
char_u *uf_name_exp; ///< if "uf_name[]" starts with SNR the name with
|
char_u *uf_name_exp; ///< if "uf_name[]" starts with SNR the name with
|
||||||
///< "<SNR>" as a string, otherwise NULL
|
///< "<SNR>" as a string, otherwise NULL
|
||||||
char_u uf_name[]; ///< Name of function (actual size equals name);
|
char uf_name[]; ///< Name of function (actual size equals name);
|
||||||
///< can start with <SNR>123_
|
///< can start with <SNR>123_
|
||||||
///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
|
///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
|
||||||
};
|
};
|
||||||
|
@ -595,7 +595,7 @@ ufunc_T *find_func(const char_u *name)
|
|||||||
/// Takes care of script-local function names.
|
/// Takes care of script-local function names.
|
||||||
static void cat_func_name(char_u *buf, ufunc_T *fp)
|
static void cat_func_name(char_u *buf, ufunc_T *fp)
|
||||||
{
|
{
|
||||||
if (fp->uf_name[0] == K_SPECIAL) {
|
if ((uint8_t)fp->uf_name[0] == K_SPECIAL) {
|
||||||
STRCPY(buf, "<SNR>");
|
STRCPY(buf, "<SNR>");
|
||||||
STRCAT(buf, fp->uf_name + 3);
|
STRCAT(buf, fp->uf_name + 3);
|
||||||
} else {
|
} else {
|
||||||
@ -610,7 +610,7 @@ static void add_nr_var(dict_T *dp, dictitem_T *v, char *name, varnumber_T nr)
|
|||||||
STRCPY(v->di_key, name);
|
STRCPY(v->di_key, name);
|
||||||
#endif
|
#endif
|
||||||
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
|
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
|
||||||
hash_add(&dp->dv_hashtab, v->di_key);
|
hash_add(&dp->dv_hashtab, (char *)v->di_key);
|
||||||
v->di_tv.v_type = VAR_NUMBER;
|
v->di_tv.v_type = VAR_NUMBER;
|
||||||
v->di_tv.v_lock = VAR_FIXED;
|
v->di_tv.v_lock = VAR_FIXED;
|
||||||
v->di_tv.vval.v_number = nr;
|
v->di_tv.vval.v_number = nr;
|
||||||
@ -906,7 +906,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
|
|||||||
STRCPY(name, "self");
|
STRCPY(name, "self");
|
||||||
#endif
|
#endif
|
||||||
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
|
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
|
||||||
hash_add(&fc->l_vars.dv_hashtab, v->di_key);
|
hash_add(&fc->l_vars.dv_hashtab, (char *)v->di_key);
|
||||||
v->di_tv.v_type = VAR_DICT;
|
v->di_tv.v_type = VAR_DICT;
|
||||||
v->di_tv.v_lock = VAR_UNLOCKED;
|
v->di_tv.v_lock = VAR_UNLOCKED;
|
||||||
v->di_tv.vval.v_dict = selfdict;
|
v->di_tv.vval.v_dict = selfdict;
|
||||||
@ -932,7 +932,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
|
|||||||
STRCPY(name, "000");
|
STRCPY(name, "000");
|
||||||
#endif
|
#endif
|
||||||
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
|
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
|
||||||
hash_add(&fc->l_avars.dv_hashtab, v->di_key);
|
hash_add(&fc->l_avars.dv_hashtab, (char *)v->di_key);
|
||||||
v->di_tv.v_type = VAR_LIST;
|
v->di_tv.v_type = VAR_LIST;
|
||||||
v->di_tv.v_lock = VAR_FIXED;
|
v->di_tv.v_lock = VAR_FIXED;
|
||||||
v->di_tv.vval.v_list = &fc->l_varlist;
|
v->di_tv.vval.v_list = &fc->l_varlist;
|
||||||
@ -1010,9 +1010,9 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
|
|||||||
// Named arguments can be accessed without the "a:" prefix in lambda
|
// Named arguments can be accessed without the "a:" prefix in lambda
|
||||||
// expressions. Add to the l: dict.
|
// expressions. Add to the l: dict.
|
||||||
tv_copy(&v->di_tv, &v->di_tv);
|
tv_copy(&v->di_tv, &v->di_tv);
|
||||||
hash_add(&fc->l_vars.dv_hashtab, v->di_key);
|
hash_add(&fc->l_vars.dv_hashtab, (char *)v->di_key);
|
||||||
} else {
|
} else {
|
||||||
hash_add(&fc->l_avars.dv_hashtab, v->di_key);
|
hash_add(&fc->l_avars.dv_hashtab, (char *)v->di_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ai >= 0 && ai < MAX_FUNC_ARGS) {
|
if (ai >= 0 && ai < MAX_FUNC_ARGS) {
|
||||||
@ -1318,7 +1318,7 @@ void free_all_functions(void)
|
|||||||
// Only free functions that are not refcounted, those are
|
// Only free functions that are not refcounted, those are
|
||||||
// supposed to be freed when no longer referenced.
|
// supposed to be freed when no longer referenced.
|
||||||
fp = HI2UF(hi);
|
fp = HI2UF(hi);
|
||||||
if (func_name_refcount(fp->uf_name)) {
|
if (func_name_refcount((char_u *)fp->uf_name)) {
|
||||||
skipped++;
|
skipped++;
|
||||||
} else {
|
} else {
|
||||||
used = func_hashtab.ht_used;
|
used = func_hashtab.ht_used;
|
||||||
@ -1344,7 +1344,7 @@ void free_all_functions(void)
|
|||||||
// Only free functions that are not refcounted, those are
|
// Only free functions that are not refcounted, those are
|
||||||
// supposed to be freed when no longer referenced.
|
// supposed to be freed when no longer referenced.
|
||||||
fp = HI2UF(hi);
|
fp = HI2UF(hi);
|
||||||
if (func_name_refcount(fp->uf_name)) {
|
if (func_name_refcount((char_u *)fp->uf_name)) {
|
||||||
skipped++;
|
skipped++;
|
||||||
} else {
|
} else {
|
||||||
func_free(fp);
|
func_free(fp);
|
||||||
@ -1654,7 +1654,7 @@ theend:
|
|||||||
|
|
||||||
char_u *printable_func_name(ufunc_T *fp)
|
char_u *printable_func_name(ufunc_T *fp)
|
||||||
{
|
{
|
||||||
return fp->uf_name_exp != NULL ? fp->uf_name_exp : fp->uf_name;
|
return fp->uf_name_exp != NULL ? fp->uf_name_exp : (char_u *)fp->uf_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List the head of the function: "name(arg1, arg2)".
|
/// List the head of the function: "name(arg1, arg2)".
|
||||||
@ -1970,7 +1970,7 @@ static void list_functions(regmatch_T *regmatch)
|
|||||||
if ((fp->uf_flags & FC_DEAD) == 0
|
if ((fp->uf_flags & FC_DEAD) == 0
|
||||||
&& (regmatch == NULL
|
&& (regmatch == NULL
|
||||||
? (!message_filtered((char *)fp->uf_name)
|
? (!message_filtered((char *)fp->uf_name)
|
||||||
&& !func_name_refcount(fp->uf_name))
|
&& !func_name_refcount((char_u *)fp->uf_name))
|
||||||
: (!isdigit(*fp->uf_name)
|
: (!isdigit(*fp->uf_name)
|
||||||
&& vim_regexec(regmatch, (char *)fp->uf_name, 0)))) {
|
&& vim_regexec(regmatch, (char *)fp->uf_name, 0)))) {
|
||||||
list_func_head(fp, false, false);
|
list_func_head(fp, false, false);
|
||||||
@ -2590,7 +2590,7 @@ void ex_function(exarg_T *eap)
|
|||||||
set_ufunc_name(fp, name);
|
set_ufunc_name(fp, name);
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
hi = hash_find(&func_hashtab, name);
|
hi = hash_find(&func_hashtab, name);
|
||||||
hi->hi_key = UF2HIKEY(fp);
|
hi->hi_key = (char *)UF2HIKEY(fp);
|
||||||
} else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) {
|
} else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) {
|
||||||
xfree(fp);
|
xfree(fp);
|
||||||
goto erret;
|
goto erret;
|
||||||
@ -2718,7 +2718,7 @@ char *get_user_func_name(expand_T *xp, int idx)
|
|||||||
return ""; // don't show dict and lambda functions
|
return ""; // don't show dict and lambda functions
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRLEN(fp->uf_name) + 4 >= IOSIZE) {
|
if (strlen(fp->uf_name) + 4 >= IOSIZE) {
|
||||||
return (char *)fp->uf_name; // Prevent overflow.
|
return (char *)fp->uf_name; // Prevent overflow.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2802,7 +2802,7 @@ void ex_delfunction(exarg_T *eap)
|
|||||||
// it and the refcount is more than one, it should be kept.
|
// it and the refcount is more than one, it should be kept.
|
||||||
// A numbered function or lambda should be kept if the refcount is
|
// A numbered function or lambda should be kept if the refcount is
|
||||||
// one or more.
|
// one or more.
|
||||||
if (fp->uf_refcount > (func_name_refcount(fp->uf_name) ? 0 : 1)) {
|
if (fp->uf_refcount > (func_name_refcount((char_u *)fp->uf_name) ? 0 : 1)) {
|
||||||
// Function is still referenced somewhere. Don't free it but
|
// Function is still referenced somewhere. Don't free it but
|
||||||
// do remove it from the hashtable.
|
// do remove it from the hashtable.
|
||||||
if (func_remove(fp)) {
|
if (func_remove(fp)) {
|
||||||
@ -3320,7 +3320,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv)
|
|||||||
/// @return the name of the executed function.
|
/// @return the name of the executed function.
|
||||||
char_u *func_name(void *cookie)
|
char_u *func_name(void *cookie)
|
||||||
{
|
{
|
||||||
return ((funccall_T *)cookie)->func->uf_name;
|
return (char_u *)((funccall_T *)cookie)->func->uf_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the address holding the next breakpoint line for a funccall cookie.
|
/// @return the address holding the next breakpoint line for a funccall cookie.
|
||||||
@ -3579,7 +3579,7 @@ bool set_ref_in_functions(int copyID)
|
|||||||
if (!HASHITEM_EMPTY(hi)) {
|
if (!HASHITEM_EMPTY(hi)) {
|
||||||
todo--;
|
todo--;
|
||||||
fp = HI2UF(hi);
|
fp = HI2UF(hi);
|
||||||
if (!func_name_refcount(fp->uf_name)
|
if (!func_name_refcount((char_u *)fp->uf_name)
|
||||||
&& set_ref_in_func(NULL, fp, copyID)) {
|
&& set_ref_in_func(NULL, fp, copyID)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -3648,5 +3648,5 @@ char_u *register_luafunc(LuaRef ref)
|
|||||||
hash_add(&func_hashtab, UF2HIKEY(fp));
|
hash_add(&func_hashtab, UF2HIKEY(fp));
|
||||||
|
|
||||||
// coverity[leaked_storage]
|
// coverity[leaked_storage]
|
||||||
return fp->uf_name;
|
return (char_u *)fp->uf_name;
|
||||||
}
|
}
|
||||||
|
@ -1174,7 +1174,7 @@ void delete_var(hashtab_T *ht, hashitem_T *hi)
|
|||||||
static void list_one_var(dictitem_T *v, const char *prefix, int *first)
|
static void list_one_var(dictitem_T *v, const char *prefix, int *first)
|
||||||
{
|
{
|
||||||
char *const s = encode_tv2echo(&v->di_tv, NULL);
|
char *const s = encode_tv2echo(&v->di_tv, NULL);
|
||||||
list_one_var_a(prefix, (const char *)v->di_key, (ptrdiff_t)STRLEN(v->di_key),
|
list_one_var_a(prefix, (const char *)v->di_key, (ptrdiff_t)strlen((char *)v->di_key),
|
||||||
v->di_tv.v_type, (s == NULL ? "" : s), first);
|
v->di_tv.v_type, (s == NULL ? "" : s), first);
|
||||||
xfree(s);
|
xfree(s);
|
||||||
}
|
}
|
||||||
@ -1342,7 +1342,7 @@ void set_var_const(const char *name, const size_t name_len, typval_T *const tv,
|
|||||||
|
|
||||||
v = xmalloc(sizeof(dictitem_T) + strlen(varname));
|
v = xmalloc(sizeof(dictitem_T) + strlen(varname));
|
||||||
STRCPY(v->di_key, varname);
|
STRCPY(v->di_key, varname);
|
||||||
if (hash_add(ht, v->di_key) == FAIL) {
|
if (hash_add(ht, (char *)v->di_key) == FAIL) {
|
||||||
xfree(v);
|
xfree(v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -825,7 +825,7 @@ void ex_retab(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
if (ml_replace(lnum, new_line, false) == OK) {
|
if (ml_replace(lnum, new_line, false) == OK) {
|
||||||
// "new_line" may have been copied
|
// "new_line" may have been copied
|
||||||
new_line = (char *)curbuf->b_ml.ml_line_ptr;
|
new_line = curbuf->b_ml.ml_line_ptr;
|
||||||
extmark_splice_cols(curbuf, lnum - 1, 0, (colnr_T)old_len,
|
extmark_splice_cols(curbuf, lnum - 1, 0, (colnr_T)old_len,
|
||||||
(colnr_T)new_len - 1, kExtmarkUndo);
|
(colnr_T)new_len - 1, kExtmarkUndo);
|
||||||
}
|
}
|
||||||
@ -1214,7 +1214,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
|||||||
}
|
}
|
||||||
// Add quotes around the command, for shells that need them.
|
// Add quotes around the command, for shells that need them.
|
||||||
if (*p_shq != NUL) {
|
if (*p_shq != NUL) {
|
||||||
newcmd = xmalloc(strlen(prevcmd) + 2 * STRLEN(p_shq) + 1);
|
newcmd = xmalloc(strlen(prevcmd) + 2 * strlen(p_shq) + 1);
|
||||||
STRCPY(newcmd, p_shq);
|
STRCPY(newcmd, p_shq);
|
||||||
STRCAT(newcmd, prevcmd);
|
STRCAT(newcmd, prevcmd);
|
||||||
STRCAT(newcmd, p_shq);
|
STRCAT(newcmd, p_shq);
|
||||||
@ -2033,7 +2033,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
|
|||||||
p = p_dir;
|
p = p_dir;
|
||||||
copy_option_part(&p, dir, MAXPATHL, ",");
|
copy_option_part(&p, dir, MAXPATHL, ",");
|
||||||
}
|
}
|
||||||
swapname = (char *)makeswapname((char_u *)fname, (char_u *)ffname, curbuf, (char_u *)dir);
|
swapname = makeswapname(fname, ffname, curbuf, dir);
|
||||||
xfree(dir);
|
xfree(dir);
|
||||||
if (os_path_exists(swapname)) {
|
if (os_path_exists(swapname)) {
|
||||||
if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
|
if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
|
||||||
|
@ -3980,7 +3980,7 @@ void separate_nextcmd(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(eap->argt & EX_NOTRLCOM)) { // remove trailing spaces
|
if (!(eap->argt & EX_NOTRLCOM)) { // remove trailing spaces
|
||||||
del_trailing_spaces((char_u *)eap->arg);
|
del_trailing_spaces(eap->arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4425,7 +4425,7 @@ static void ex_colorscheme(exarg_T *eap)
|
|||||||
} else {
|
} else {
|
||||||
msg("default");
|
msg("default");
|
||||||
}
|
}
|
||||||
} else if (load_colors((char_u *)eap->arg) == FAIL) {
|
} else if (load_colors(eap->arg) == FAIL) {
|
||||||
semsg(_("E185: Cannot find color scheme '%s'"), eap->arg);
|
semsg(_("E185: Cannot find color scheme '%s'"), eap->arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6715,7 +6715,7 @@ char_u *eval_vars(char_u *src, const char_u *srcstart, size_t *usedlen, linenr_T
|
|||||||
// Note: In "\\%" the % is also not recognized!
|
// Note: In "\\%" the % is also not recognized!
|
||||||
if (src > srcstart && src[-1] == '\\') {
|
if (src > srcstart && src[-1] == '\\') {
|
||||||
*usedlen = 0;
|
*usedlen = 0;
|
||||||
STRMOVE(src - 1, src); // remove backslash
|
STRMOVE(src - 1, (char *)src); // remove backslash
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ char_u *vim_findfile_stopdir(char_u *buf)
|
|||||||
if (r_ptr[0] == '\\' && r_ptr[1] == ';') {
|
if (r_ptr[0] == '\\' && r_ptr[1] == ';') {
|
||||||
// Overwrite the escape char,
|
// Overwrite the escape char,
|
||||||
// use strlen(r_ptr) to move the trailing '\0'.
|
// use strlen(r_ptr) to move the trailing '\0'.
|
||||||
STRMOVE(r_ptr, r_ptr + 1);
|
STRMOVE(r_ptr, (char *)r_ptr + 1);
|
||||||
r_ptr++;
|
r_ptr++;
|
||||||
}
|
}
|
||||||
r_ptr++;
|
r_ptr++;
|
||||||
|
@ -201,15 +201,15 @@ void hash_debug_results(void)
|
|||||||
///
|
///
|
||||||
/// @return OK if success.
|
/// @return OK if success.
|
||||||
/// FAIL if key already present
|
/// FAIL if key already present
|
||||||
int hash_add(hashtab_T *ht, char_u *key)
|
int hash_add(hashtab_T *ht, char *key)
|
||||||
{
|
{
|
||||||
hash_T hash = hash_hash(key);
|
hash_T hash = hash_hash((char_u *)key);
|
||||||
hashitem_T *hi = hash_lookup(ht, (const char *)key, STRLEN(key), hash);
|
hashitem_T *hi = hash_lookup(ht, key, strlen(key), hash);
|
||||||
if (!HASHITEM_EMPTY(hi)) {
|
if (!HASHITEM_EMPTY(hi)) {
|
||||||
internal_error("hash_add()");
|
internal_error("hash_add()");
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
hash_add_item(ht, hi, key, hash);
|
hash_add_item(ht, hi, (char_u *)key, hash);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ void hash_add_item(hashtab_T *ht, hashitem_T *hi, char_u *key, hash_T hash)
|
|||||||
if (hi->hi_key == NULL) {
|
if (hi->hi_key == NULL) {
|
||||||
ht->ht_filled++;
|
ht->ht_filled++;
|
||||||
}
|
}
|
||||||
hi->hi_key = key;
|
hi->hi_key = (char *)key;
|
||||||
hi->hi_hash = hash;
|
hi->hi_hash = hash;
|
||||||
|
|
||||||
// When the space gets low may resize the array.
|
// When the space gets low may resize the array.
|
||||||
@ -449,5 +449,5 @@ hash_T hash_hash_len(const char *key, const size_t len)
|
|||||||
const char_u *_hash_key_removed(void)
|
const char_u *_hash_key_removed(void)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
return HI_KEY_REMOVED;
|
return (char_u *)HI_KEY_REMOVED;
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ typedef size_t hash_T;
|
|||||||
|
|
||||||
/// The address of "hash_removed" is used as a magic number
|
/// The address of "hash_removed" is used as a magic number
|
||||||
/// for hi_key to indicate a removed item.
|
/// for hi_key to indicate a removed item.
|
||||||
#define HI_KEY_REMOVED ((char_u *)&hash_removed)
|
#define HI_KEY_REMOVED (&hash_removed)
|
||||||
#define HASHITEM_EMPTY(hi) ((hi)->hi_key == NULL \
|
#define HASHITEM_EMPTY(hi) ((hi)->hi_key == NULL \
|
||||||
|| (hi)->hi_key == (char_u *)&hash_removed)
|
|| (hi)->hi_key == &hash_removed)
|
||||||
|
|
||||||
/// Hashtable item.
|
/// Hashtable item.
|
||||||
///
|
///
|
||||||
@ -45,7 +45,7 @@ typedef struct hashitem_S {
|
|||||||
/// NULL : Item was never used.
|
/// NULL : Item was never used.
|
||||||
/// HI_KEY_REMOVED : Item was removed.
|
/// HI_KEY_REMOVED : Item was removed.
|
||||||
/// (Any other pointer value) : Item is currently being used.
|
/// (Any other pointer value) : Item is currently being used.
|
||||||
char_u *hi_key;
|
char *hi_key;
|
||||||
} hashitem_T;
|
} hashitem_T;
|
||||||
|
|
||||||
/// Initial size for a hashtable.
|
/// Initial size for a hashtable.
|
||||||
|
@ -590,7 +590,7 @@ void init_highlight(bool both, bool reset)
|
|||||||
// Value of g:colors_name could be freed in load_colors() and make
|
// Value of g:colors_name could be freed in load_colors() and make
|
||||||
// p invalid, so copy it.
|
// p invalid, so copy it.
|
||||||
char *copy_p = xstrdup(p);
|
char *copy_p = xstrdup(p);
|
||||||
bool okay = load_colors((char_u *)copy_p);
|
bool okay = load_colors(copy_p);
|
||||||
xfree(copy_p);
|
xfree(copy_p);
|
||||||
if (okay) {
|
if (okay) {
|
||||||
return;
|
return;
|
||||||
@ -638,8 +638,9 @@ void init_highlight(bool both, bool reset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Load color file "name".
|
/// Load color file "name".
|
||||||
/// Return OK for success, FAIL for failure.
|
///
|
||||||
int load_colors(char_u *name)
|
/// @return OK for success, FAIL for failure.
|
||||||
|
int load_colors(char *name)
|
||||||
{
|
{
|
||||||
char_u *buf;
|
char_u *buf;
|
||||||
int retval = FAIL;
|
int retval = FAIL;
|
||||||
@ -653,9 +654,9 @@ int load_colors(char_u *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
recursive = true;
|
recursive = true;
|
||||||
size_t buflen = STRLEN(name) + 12;
|
size_t buflen = strlen(name) + 12;
|
||||||
buf = xmalloc(buflen);
|
buf = xmalloc(buflen);
|
||||||
apply_autocmds(EVENT_COLORSCHEMEPRE, (char *)name, curbuf->b_fname, false, curbuf);
|
apply_autocmds(EVENT_COLORSCHEMEPRE, name, curbuf->b_fname, false, curbuf);
|
||||||
snprintf((char *)buf, buflen, "colors/%s.vim", name);
|
snprintf((char *)buf, buflen, "colors/%s.vim", name);
|
||||||
retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
|
retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
|
||||||
if (retval == FAIL) {
|
if (retval == FAIL) {
|
||||||
@ -664,7 +665,7 @@ int load_colors(char_u *name)
|
|||||||
}
|
}
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
if (retval == OK) {
|
if (retval == OK) {
|
||||||
apply_autocmds(EVENT_COLORSCHEME, (char *)name, curbuf->b_fname, false, curbuf);
|
apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, false, curbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive = false;
|
recursive = false;
|
||||||
|
@ -561,7 +561,7 @@ int set_indent(int size, int flags)
|
|||||||
} else {
|
} else {
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
}
|
}
|
||||||
line_len = (int)STRLEN(p) + 1;
|
line_len = (int)strlen(p) + 1;
|
||||||
|
|
||||||
// If 'preserveindent' and 'expandtab' are both set keep the original
|
// If 'preserveindent' and 'expandtab' are both set keep the original
|
||||||
// characters and allocate accordingly. We will fill the rest with spaces
|
// characters and allocate accordingly. We will fill the rest with spaces
|
||||||
|
@ -242,7 +242,7 @@ static const char_u *cin_skipcomment(const char_u *s)
|
|||||||
// Perl/shell # comment comment continues until eol. Require a space
|
// Perl/shell # comment comment continues until eol. Require a space
|
||||||
// before # to avoid recognizing $#array.
|
// before # to avoid recognizing $#array.
|
||||||
if (curbuf->b_ind_hash_comment != 0 && s != prev_s && *s == '#') {
|
if (curbuf->b_ind_hash_comment != 0 && s != prev_s && *s == '#') {
|
||||||
s += STRLEN(s);
|
s += strlen((char *)s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*s != '/') {
|
if (*s != '/') {
|
||||||
@ -250,7 +250,7 @@ static const char_u *cin_skipcomment(const char_u *s)
|
|||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
if (*s == '/') { // slash-slash comment continues till eol
|
if (*s == '/') { // slash-slash comment continues till eol
|
||||||
s += STRLEN(s);
|
s += strlen((char *)s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*s != '*') {
|
if (*s != '*') {
|
||||||
@ -697,7 +697,7 @@ static int cin_get_equal_amount(linenr_T lnum)
|
|||||||
|
|
||||||
if (lnum > 1) {
|
if (lnum > 1) {
|
||||||
line = (char_u *)ml_get(lnum - 1);
|
line = (char_u *)ml_get(lnum - 1);
|
||||||
if (*line != NUL && line[STRLEN(line) - 1] == '\\') {
|
if (*line != NUL && line[strlen((char *)line) - 1] == '\\') {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,7 +750,7 @@ static int cin_ispreproc_cont(const char_u **pp, linenr_T *lnump, int *amount)
|
|||||||
int retval = false;
|
int retval = false;
|
||||||
int candidate_amount = *amount;
|
int candidate_amount = *amount;
|
||||||
|
|
||||||
if (*line != NUL && line[STRLEN(line) - 1] == '\\') {
|
if (*line != NUL && line[strlen((char *)line) - 1] == '\\') {
|
||||||
candidate_amount = get_indent_lnum(lnum);
|
candidate_amount = get_indent_lnum(lnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,7 +764,7 @@ static int cin_ispreproc_cont(const char_u **pp, linenr_T *lnump, int *amount)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
line = (char_u *)ml_get(--lnum);
|
line = (char_u *)ml_get(--lnum);
|
||||||
if (*line == NUL || line[STRLEN(line) - 1] != '\\') {
|
if (*line == NUL || line[strlen((char *)line) - 1] != '\\') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -915,7 +915,7 @@ static int cin_isfuncdecl(const char_u **sp, linenr_T first_lnum, linenr_T min_l
|
|||||||
// defined(y)
|
// defined(y)
|
||||||
lnum = first_lnum - 1;
|
lnum = first_lnum - 1;
|
||||||
s = (char_u *)ml_get(lnum);
|
s = (char_u *)ml_get(lnum);
|
||||||
if (*s == NUL || s[STRLEN(s) - 1] != '\\') {
|
if (*s == NUL || s[strlen((char *)s) - 1] != '\\') {
|
||||||
retval = true;
|
retval = true;
|
||||||
}
|
}
|
||||||
goto done;
|
goto done;
|
||||||
@ -1306,14 +1306,14 @@ static int cin_ends_in(const char_u *s, const char_u *find, const char_u *ignore
|
|||||||
{
|
{
|
||||||
const char_u *p = s;
|
const char_u *p = s;
|
||||||
const char_u *r;
|
const char_u *r;
|
||||||
int len = (int)STRLEN(find);
|
int len = (int)strlen((char *)find);
|
||||||
|
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
p = cin_skipcomment(p);
|
p = cin_skipcomment(p);
|
||||||
if (STRNCMP(p, find, len) == 0) {
|
if (STRNCMP(p, find, len) == 0) {
|
||||||
r = (char_u *)skipwhite((char *)p + len);
|
r = (char_u *)skipwhite((char *)p + len);
|
||||||
if (ignore != NULL && STRNCMP(r, ignore, STRLEN(ignore)) == 0) {
|
if (ignore != NULL && STRNCMP(r, ignore, strlen((char *)ignore)) == 0) {
|
||||||
r = (char_u *)skipwhite((char *)r + STRLEN(ignore));
|
r = (char_u *)skipwhite((char *)r + strlen((char *)ignore));
|
||||||
}
|
}
|
||||||
if (cin_nocode(r)) {
|
if (cin_nocode(r)) {
|
||||||
return true;
|
return true;
|
||||||
@ -2897,7 +2897,7 @@ int get_c_indent(void)
|
|||||||
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
|
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
|
||||||
&& terminated == ',')) {
|
&& terminated == ',')) {
|
||||||
if (lookfor != LOOKFOR_ENUM_OR_INIT
|
if (lookfor != LOOKFOR_ENUM_OR_INIT
|
||||||
&& (*skipwhite((char *)l) == '[' || l[STRLEN(l) - 1] == '[')) {
|
&& (*skipwhite((char *)l) == '[' || l[strlen((char *)l) - 1] == '[')) {
|
||||||
amount += ind_continuation;
|
amount += ind_continuation;
|
||||||
}
|
}
|
||||||
// If we're in the middle of a paren thing, Go back to the line
|
// If we're in the middle of a paren thing, Go back to the line
|
||||||
@ -2945,7 +2945,7 @@ int get_c_indent(void)
|
|||||||
if (terminated == ',') {
|
if (terminated == ',') {
|
||||||
while (curwin->w_cursor.lnum > 1) {
|
while (curwin->w_cursor.lnum > 1) {
|
||||||
l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
|
l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
|
||||||
if (*l == NUL || l[STRLEN(l) - 1] != '\\') {
|
if (*l == NUL || l[strlen((char *)l) - 1] != '\\') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
curwin->w_cursor.lnum--;
|
curwin->w_cursor.lnum--;
|
||||||
@ -3104,7 +3104,7 @@ int get_c_indent(void)
|
|||||||
l = (char_u *)get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
amount = cur_amount;
|
amount = cur_amount;
|
||||||
|
|
||||||
n = (int)STRLEN(l);
|
n = (int)strlen((char *)l);
|
||||||
if (terminated == ','
|
if (terminated == ','
|
||||||
&& (*skipwhite((char *)l) == ']'
|
&& (*skipwhite((char *)l) == ']'
|
||||||
|| (n >= 2 && l[n - 2] == ']'))) {
|
|| (n >= 2 && l[n - 2] == ']'))) {
|
||||||
@ -3153,7 +3153,7 @@ int get_c_indent(void)
|
|||||||
} else {
|
} else {
|
||||||
if (lookfor == LOOKFOR_INITIAL
|
if (lookfor == LOOKFOR_INITIAL
|
||||||
&& *l != NUL
|
&& *l != NUL
|
||||||
&& l[STRLEN(l) - 1] == '\\') {
|
&& l[strlen((char *)l) - 1] == '\\') {
|
||||||
// XXX
|
// XXX
|
||||||
cont_amount = cin_get_equal_amount(curwin->w_cursor.lnum);
|
cont_amount = cin_get_equal_amount(curwin->w_cursor.lnum);
|
||||||
}
|
}
|
||||||
@ -3435,7 +3435,7 @@ term_again:
|
|||||||
// } foo,
|
// } foo,
|
||||||
// bar;
|
// bar;
|
||||||
if (cin_ends_in(l, (char_u *)",", NULL)
|
if (cin_ends_in(l, (char_u *)",", NULL)
|
||||||
|| (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\')) {
|
|| (*l != NUL && (n = l[strlen((char *)l) - 1]) == '\\')) {
|
||||||
// take us back to opening paren
|
// take us back to opening paren
|
||||||
if (find_last_paren(l, '(', ')')
|
if (find_last_paren(l, '(', ')')
|
||||||
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
|
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
|
||||||
@ -3449,7 +3449,7 @@ term_again:
|
|||||||
// here;
|
// here;
|
||||||
while (n == 0 && curwin->w_cursor.lnum > 1) {
|
while (n == 0 && curwin->w_cursor.lnum > 1) {
|
||||||
l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
|
l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
|
||||||
if (*l == NUL || l[STRLEN(l) - 1] != '\\') {
|
if (*l == NUL || l[strlen((char *)l) - 1] != '\\') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
curwin->w_cursor.lnum--;
|
curwin->w_cursor.lnum--;
|
||||||
@ -3535,7 +3535,7 @@ term_again:
|
|||||||
if (cin_ends_in(l, (char_u *)";", NULL)) {
|
if (cin_ends_in(l, (char_u *)";", NULL)) {
|
||||||
l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
|
l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
|
||||||
if (cin_ends_in(l, (char_u *)",", NULL)
|
if (cin_ends_in(l, (char_u *)",", NULL)
|
||||||
|| (*l != NUL && l[STRLEN(l) - 1] == '\\')) {
|
|| (*l != NUL && l[strlen((char *)l) - 1] == '\\')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
l = (char_u *)get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
@ -3567,7 +3567,7 @@ term_again:
|
|||||||
// here";
|
// here";
|
||||||
if (cur_curpos.lnum > 1) {
|
if (cur_curpos.lnum > 1) {
|
||||||
l = (char_u *)ml_get(cur_curpos.lnum - 1);
|
l = (char_u *)ml_get(cur_curpos.lnum - 1);
|
||||||
if (*l != NUL && l[STRLEN(l) - 1] == '\\') {
|
if (*l != NUL && l[strlen((char *)l) - 1] == '\\') {
|
||||||
cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1);
|
cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1);
|
||||||
if (cur_amount > 0) {
|
if (cur_amount > 0) {
|
||||||
amount = cur_amount;
|
amount = cur_amount;
|
||||||
|
@ -889,7 +889,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
|||||||
size_t dlen = 0;
|
size_t dlen = 0;
|
||||||
const char_u *src;
|
const char_u *src;
|
||||||
const char_u *const end = (char_u *)from + from_len - 1;
|
const char_u *const end = (char_u *)from + from_len - 1;
|
||||||
char_u *result; // buffer for resulting string
|
char *result; // buffer for resulting string
|
||||||
|
|
||||||
const bool do_backslash = !(cpo_flags & FLAG_CPO_BSLASH); // backslash is a special character
|
const bool do_backslash = !(cpo_flags & FLAG_CPO_BSLASH); // backslash is a special character
|
||||||
const bool do_special = !(flags & REPTERM_NO_SPECIAL);
|
const bool do_special = !(flags & REPTERM_NO_SPECIAL);
|
||||||
@ -906,12 +906,12 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
|||||||
// Check for #n at start only: function key n
|
// Check for #n at start only: function key n
|
||||||
if ((flags & REPTERM_FROM_PART) && from_len > 1 && src[0] == '#'
|
if ((flags & REPTERM_FROM_PART) && from_len > 1 && src[0] == '#'
|
||||||
&& ascii_isdigit(src[1])) { // function key
|
&& ascii_isdigit(src[1])) { // function key
|
||||||
result[dlen++] = K_SPECIAL;
|
result[dlen++] = (char)K_SPECIAL;
|
||||||
result[dlen++] = 'k';
|
result[dlen++] = 'k';
|
||||||
if (src[1] == '0') {
|
if (src[1] == '0') {
|
||||||
result[dlen++] = ';'; // #0 is F10 is "k;"
|
result[dlen++] = ';'; // #0 is F10 is "k;"
|
||||||
} else {
|
} else {
|
||||||
result[dlen++] = src[1]; // #3 is F3 is "k3"
|
result[dlen++] = (char)src[1]; // #3 is F3 is "k3"
|
||||||
}
|
}
|
||||||
src += 2;
|
src += 2;
|
||||||
}
|
}
|
||||||
@ -931,18 +931,18 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
|||||||
emsg(_(e_usingsid));
|
emsg(_(e_usingsid));
|
||||||
} else {
|
} else {
|
||||||
src += 5;
|
src += 5;
|
||||||
result[dlen++] = K_SPECIAL;
|
result[dlen++] = (char)K_SPECIAL;
|
||||||
result[dlen++] = KS_EXTRA;
|
result[dlen++] = (char)KS_EXTRA;
|
||||||
result[dlen++] = KE_SNR;
|
result[dlen++] = KE_SNR;
|
||||||
snprintf((char *)result + dlen, buf_len - dlen, "%" PRId64,
|
snprintf(result + dlen, buf_len - dlen, "%" PRId64,
|
||||||
(int64_t)current_sctx.sc_sid);
|
(int64_t)current_sctx.sc_sid);
|
||||||
dlen += STRLEN(result + dlen);
|
dlen += strlen(result + dlen);
|
||||||
result[dlen++] = '_';
|
result[dlen++] = '_';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
slen = trans_special(&src, (size_t)(end - src) + 1, result + dlen,
|
slen = trans_special(&src, (size_t)(end - src) + 1, (char_u *)result + dlen,
|
||||||
FSK_KEYCODE | ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY),
|
FSK_KEYCODE | ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY),
|
||||||
true, did_simplify);
|
true, did_simplify);
|
||||||
if (slen) {
|
if (slen) {
|
||||||
@ -952,17 +952,18 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (do_special) {
|
if (do_special) {
|
||||||
char_u *p, *s, len;
|
char *p, *s;
|
||||||
|
int len;
|
||||||
|
|
||||||
// Replace <Leader> by the value of "mapleader".
|
// Replace <Leader> by the value of "mapleader".
|
||||||
// Replace <LocalLeader> by the value of "maplocalleader".
|
// Replace <LocalLeader> by the value of "maplocalleader".
|
||||||
// If "mapleader" or "maplocalleader" isn't set use a backslash.
|
// If "mapleader" or "maplocalleader" isn't set use a backslash.
|
||||||
if (end - src >= 7 && STRNICMP(src, "<Leader>", 8) == 0) {
|
if (end - src >= 7 && STRNICMP(src, "<Leader>", 8) == 0) {
|
||||||
len = 8;
|
len = 8;
|
||||||
p = get_var_value("g:mapleader");
|
p = (char *)get_var_value("g:mapleader");
|
||||||
} else if (end - src >= 12 && STRNICMP(src, "<LocalLeader>", 13) == 0) {
|
} else if (end - src >= 12 && STRNICMP(src, "<LocalLeader>", 13) == 0) {
|
||||||
len = 13;
|
len = 13;
|
||||||
p = get_var_value("g:maplocalleader");
|
p = (char *)get_var_value("g:maplocalleader");
|
||||||
} else {
|
} else {
|
||||||
len = 0;
|
len = 0;
|
||||||
p = NULL;
|
p = NULL;
|
||||||
@ -970,8 +971,8 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
|||||||
|
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
// Allow up to 8 * 6 characters for "mapleader".
|
// Allow up to 8 * 6 characters for "mapleader".
|
||||||
if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) {
|
if (p == NULL || *p == NUL || strlen(p) > 8 * 6) {
|
||||||
s = (char_u *)"\\";
|
s = "\\";
|
||||||
} else {
|
} else {
|
||||||
s = p;
|
s = p;
|
||||||
}
|
}
|
||||||
@ -992,7 +993,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
|||||||
src++; // skip CTRL-V or backslash
|
src++; // skip CTRL-V or backslash
|
||||||
if (src > end) {
|
if (src > end) {
|
||||||
if (flags & REPTERM_FROM_PART) {
|
if (flags & REPTERM_FROM_PART) {
|
||||||
result[dlen++] = key;
|
result[dlen++] = (char)key;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1003,11 +1004,11 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
|||||||
// If the character is K_SPECIAL, replace it with K_SPECIAL
|
// If the character is K_SPECIAL, replace it with K_SPECIAL
|
||||||
// KS_SPECIAL KE_FILLER.
|
// KS_SPECIAL KE_FILLER.
|
||||||
if (*src == K_SPECIAL) {
|
if (*src == K_SPECIAL) {
|
||||||
result[dlen++] = K_SPECIAL;
|
result[dlen++] = (char)K_SPECIAL;
|
||||||
result[dlen++] = KS_SPECIAL;
|
result[dlen++] = (char)KS_SPECIAL;
|
||||||
result[dlen++] = KE_FILLER;
|
result[dlen++] = KE_FILLER;
|
||||||
} else {
|
} else {
|
||||||
result[dlen++] = *src;
|
result[dlen++] = (char)(*src);
|
||||||
}
|
}
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ static size_t line_len(const char *s)
|
|||||||
if (end) {
|
if (end) {
|
||||||
return (size_t)(end - s);
|
return (size_t)(end - s);
|
||||||
}
|
}
|
||||||
return STRLEN(s);
|
return strlen(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as matching_chars but ignore whitespace
|
/// Same as matching_chars but ignore whitespace
|
||||||
|
@ -597,9 +597,10 @@ static void check_cur_search_hl(win_T *wp, match_T *shl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Prepare for 'hlsearch' and match highlighting in one window line.
|
/// Prepare for 'hlsearch' and match highlighting in one window line.
|
||||||
/// Return true if there is such highlighting and set "search_attr" to the
|
///
|
||||||
/// current highlight attribute.
|
/// @return true if there is such highlighting and set "search_attr" to the
|
||||||
bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **line,
|
/// current highlight attribute.
|
||||||
|
bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char **line,
|
||||||
match_T *search_hl, int *search_attr, bool *search_attr_from_match)
|
match_T *search_hl, int *search_attr, bool *search_attr_from_match)
|
||||||
{
|
{
|
||||||
matchitem_T *cur = wp->w_match_head; // points to the match list
|
matchitem_T *cur = wp->w_match_head; // points to the match list
|
||||||
@ -630,7 +631,7 @@ bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **l
|
|||||||
|
|
||||||
// Need to get the line again, a multi-line regexp may have made it
|
// Need to get the line again, a multi-line regexp may have made it
|
||||||
// invalid.
|
// invalid.
|
||||||
*line = (char_u *)ml_get_buf(wp->w_buffer, lnum, false);
|
*line = ml_get_buf(wp->w_buffer, lnum, false);
|
||||||
|
|
||||||
if (shl->lnum != 0 && shl->lnum <= lnum) {
|
if (shl->lnum != 0 && shl->lnum <= lnum) {
|
||||||
if (shl->lnum == lnum) {
|
if (shl->lnum == lnum) {
|
||||||
@ -653,7 +654,7 @@ bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **l
|
|||||||
// Highlight one character for an empty match.
|
// Highlight one character for an empty match.
|
||||||
if (shl->startcol == shl->endcol) {
|
if (shl->startcol == shl->endcol) {
|
||||||
if ((*line)[shl->endcol] != NUL) {
|
if ((*line)[shl->endcol] != NUL) {
|
||||||
shl->endcol += utfc_ptr2len((char *)(*line) + shl->endcol);
|
shl->endcol += utfc_ptr2len(*line + shl->endcol);
|
||||||
} else {
|
} else {
|
||||||
shl->endcol++;
|
shl->endcol++;
|
||||||
}
|
}
|
||||||
@ -680,7 +681,7 @@ bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **l
|
|||||||
/// "on_last_col" is set to true with non-zero search_attr and the next column
|
/// "on_last_col" is set to true with non-zero search_attr and the next column
|
||||||
/// is endcol.
|
/// is endcol.
|
||||||
/// Return the updated search_attr.
|
/// Return the updated search_attr.
|
||||||
int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match_T *search_hl,
|
int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char **line, match_T *search_hl,
|
||||||
int *has_match_conc, int *match_conc, int lcs_eol_one, bool *on_last_col,
|
int *has_match_conc, int *match_conc, int lcs_eol_one, bool *on_last_col,
|
||||||
bool *search_attr_from_match)
|
bool *search_attr_from_match)
|
||||||
{
|
{
|
||||||
@ -709,7 +710,7 @@ int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match
|
|||||||
if (shl->startcol != MAXCOL
|
if (shl->startcol != MAXCOL
|
||||||
&& col >= shl->startcol
|
&& col >= shl->startcol
|
||||||
&& col < shl->endcol) {
|
&& col < shl->endcol) {
|
||||||
int next_col = col + utfc_ptr2len((char *)(*line) + col);
|
int next_col = col + utfc_ptr2len(*line + col);
|
||||||
|
|
||||||
if (shl->endcol < next_col) {
|
if (shl->endcol < next_col) {
|
||||||
shl->endcol = next_col;
|
shl->endcol = next_col;
|
||||||
@ -740,7 +741,7 @@ int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match
|
|||||||
|
|
||||||
// Need to get the line again, a multi-line regexp
|
// Need to get the line again, a multi-line regexp
|
||||||
// may have made it invalid.
|
// may have made it invalid.
|
||||||
*line = (char_u *)ml_get_buf(wp->w_buffer, lnum, false);
|
*line = ml_get_buf(wp->w_buffer, lnum, false);
|
||||||
|
|
||||||
if (shl->lnum == lnum) {
|
if (shl->lnum == lnum) {
|
||||||
shl->startcol = shl->rm.startpos[0].col;
|
shl->startcol = shl->rm.startpos[0].col;
|
||||||
@ -757,7 +758,7 @@ int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match
|
|||||||
|
|
||||||
if (shl->startcol == shl->endcol) {
|
if (shl->startcol == shl->endcol) {
|
||||||
// highlight empty match, try again after it
|
// highlight empty match, try again after it
|
||||||
char *p = (char *)(*line) + shl->endcol;
|
char *p = *line + shl->endcol;
|
||||||
|
|
||||||
if (*p == NUL) {
|
if (*p == NUL) {
|
||||||
shl->endcol++;
|
shl->endcol++;
|
||||||
|
@ -1987,7 +1987,7 @@ void mb_check_adjust_col(void *win_)
|
|||||||
// Column 0 is always valid.
|
// Column 0 is always valid.
|
||||||
if (oldcol != 0) {
|
if (oldcol != 0) {
|
||||||
char *p = ml_get_buf(win->w_buffer, win->w_cursor.lnum, false);
|
char *p = ml_get_buf(win->w_buffer, win->w_cursor.lnum, false);
|
||||||
colnr_T len = (colnr_T)STRLEN(p);
|
colnr_T len = (colnr_T)strlen(p);
|
||||||
|
|
||||||
// Empty line or invalid column?
|
// Empty line or invalid column?
|
||||||
if (len == 0 || oldcol < 0) {
|
if (len == 0 || oldcol < 0) {
|
||||||
@ -2127,7 +2127,7 @@ char *enc_canonize(char *enc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy "enc" to allocated memory, with room for two '-'
|
// copy "enc" to allocated memory, with room for two '-'
|
||||||
char *r = xmalloc(STRLEN(enc) + 3);
|
char *r = xmalloc(strlen(enc) + 3);
|
||||||
// Make it all lower case and replace '_' with '-'.
|
// Make it all lower case and replace '_' with '-'.
|
||||||
p = r;
|
p = r;
|
||||||
for (s = enc; *s != NUL; s++) {
|
for (s = enc; *s != NUL; s++) {
|
||||||
@ -2492,7 +2492,7 @@ char_u *string_convert_ext(const vimconv_T *const vcp, char_u *ptr, size_t *lenp
|
|||||||
|
|
||||||
size_t len;
|
size_t len;
|
||||||
if (lenp == NULL) {
|
if (lenp == NULL) {
|
||||||
len = STRLEN(ptr);
|
len = strlen((char *)ptr);
|
||||||
} else {
|
} else {
|
||||||
len = *lenp;
|
len = *lenp;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ struct block0 {
|
|||||||
char_u b0_pid[4]; // process id of creator (or 0)
|
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_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_u b0_hname[B0_HNAME_SIZE]; // host name (if it has a name)
|
||||||
char_u b0_fname[B0_FNAME_SIZE_ORG]; // name of file being edited
|
char b0_fname[B0_FNAME_SIZE_ORG]; // name of file being edited
|
||||||
long b0_magic_long; // check for byte order of long
|
long b0_magic_long; // check for byte order of long
|
||||||
int b0_magic_int; // check for byte order of int
|
int b0_magic_int; // check for byte order of int
|
||||||
int16_t b0_magic_short; // check for byte order of short
|
int16_t b0_magic_short; // check for byte order of short
|
||||||
@ -302,7 +302,7 @@ int ml_open(buf_T *buf)
|
|||||||
|
|
||||||
if (!buf->b_spell) {
|
if (!buf->b_spell) {
|
||||||
b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0;
|
b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0;
|
||||||
b0p->b0_flags = (uint8_t)(get_fileformat(buf) + 1);
|
b0p->b0_flags = (char)(get_fileformat(buf) + 1);
|
||||||
set_b0_fname(b0p, buf);
|
set_b0_fname(b0p, buf);
|
||||||
(void)os_get_username((char *)b0p->b0_uname, B0_UNAME_SIZE);
|
(void)os_get_username((char *)b0p->b0_uname, B0_UNAME_SIZE);
|
||||||
b0p->b0_uname[B0_UNAME_SIZE - 1] = NUL;
|
b0p->b0_uname[B0_UNAME_SIZE - 1] = NUL;
|
||||||
@ -639,7 +639,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf)
|
|||||||
// If there is no user name or it is too long, don't use "~/"
|
// If there is no user name or it is too long, don't use "~/"
|
||||||
int retval = os_get_username(uname, B0_UNAME_SIZE);
|
int retval = os_get_username(uname, B0_UNAME_SIZE);
|
||||||
size_t ulen = strlen(uname);
|
size_t ulen = strlen(uname);
|
||||||
size_t flen = STRLEN(b0p->b0_fname);
|
size_t flen = strlen(b0p->b0_fname);
|
||||||
if (retval == FAIL || ulen + flen > B0_FNAME_SIZE_CRYPT - 1) {
|
if (retval == FAIL || ulen + flen > B0_FNAME_SIZE_CRYPT - 1) {
|
||||||
STRLCPY(b0p->b0_fname, buf->b_ffname, B0_FNAME_SIZE_CRYPT);
|
STRLCPY(b0p->b0_fname, buf->b_ffname, B0_FNAME_SIZE_CRYPT);
|
||||||
} else {
|
} else {
|
||||||
@ -679,7 +679,7 @@ static void set_b0_dir_flag(ZERO_BL *b0p, buf_T *buf)
|
|||||||
if (same_directory((char_u *)buf->b_ml.ml_mfp->mf_fname, (char_u *)buf->b_ffname)) {
|
if (same_directory((char_u *)buf->b_ml.ml_mfp->mf_fname, (char_u *)buf->b_ffname)) {
|
||||||
b0p->b0_flags |= B0_SAME_DIR;
|
b0p->b0_flags |= B0_SAME_DIR;
|
||||||
} else {
|
} else {
|
||||||
b0p->b0_flags &= (uint8_t) ~B0_SAME_DIR;
|
b0p->b0_flags = (char)(b0p->b0_flags & ~B0_SAME_DIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,8 +689,8 @@ static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf)
|
|||||||
const int size = B0_FNAME_SIZE_NOCRYPT;
|
const int size = B0_FNAME_SIZE_NOCRYPT;
|
||||||
|
|
||||||
int n = (int)strlen(buf->b_p_fenc);
|
int n = (int)strlen(buf->b_p_fenc);
|
||||||
if ((int)STRLEN(b0p->b0_fname) + n + 1 > size) {
|
if ((int)strlen(b0p->b0_fname) + n + 1 > size) {
|
||||||
b0p->b0_flags &= (uint8_t) ~B0_HAS_FENC;
|
b0p->b0_flags = (char)(b0p->b0_flags & ~B0_HAS_FENC);
|
||||||
} else {
|
} else {
|
||||||
memmove((char *)b0p->b0_fname + size - n,
|
memmove((char *)b0p->b0_fname + size - n,
|
||||||
buf->b_p_fenc, (size_t)n);
|
buf->b_p_fenc, (size_t)n);
|
||||||
@ -923,8 +923,8 @@ void ml_recover(bool checkext)
|
|||||||
if (b0p->b0_flags & B0_HAS_FENC) {
|
if (b0p->b0_flags & B0_HAS_FENC) {
|
||||||
int fnsize = B0_FNAME_SIZE_NOCRYPT;
|
int fnsize = B0_FNAME_SIZE_NOCRYPT;
|
||||||
|
|
||||||
for (p = (char *)b0p->b0_fname + fnsize; (char_u *)p > b0p->b0_fname && p[-1] != NUL; p--) {}
|
for (p = (char *)b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) {}
|
||||||
b0_fenc = xstrnsave(p, (size_t)(b0p->b0_fname + fnsize - (char_u *)p));
|
b0_fenc = xstrnsave(p, (size_t)(b0p->b0_fname + fnsize - p));
|
||||||
}
|
}
|
||||||
|
|
||||||
mf_put(mfp, hp, false, false); // release block 0
|
mf_put(mfp, hp, false, false); // release block 0
|
||||||
@ -1603,7 +1603,7 @@ static int recov_file_names(char **names, char *path, int prepend_dot)
|
|||||||
names[num_names] = concat_fnames(path, ".sw?", false);
|
names[num_names] = concat_fnames(path, ".sw?", false);
|
||||||
if (num_names >= 1) { // check if we have the same name twice
|
if (num_names >= 1) { // check if we have the same name twice
|
||||||
char *p = names[num_names - 1];
|
char *p = names[num_names - 1];
|
||||||
int i = (int)STRLEN(names[num_names - 1]) - (int)STRLEN(names[num_names]);
|
int i = (int)strlen(names[num_names - 1]) - (int)strlen(names[num_names]);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
p += i; // file name has been expanded to full path
|
p += i; // file name has been expanded to full path
|
||||||
}
|
}
|
||||||
@ -1822,16 +1822,16 @@ errorret:
|
|||||||
DATA_BL *dp = hp->bh_data;
|
DATA_BL *dp = hp->bh_data;
|
||||||
|
|
||||||
char *ptr = (char *)dp + (dp->db_index[lnum - buf->b_ml.ml_locked_low] & DB_INDEX_MASK);
|
char *ptr = (char *)dp + (dp->db_index[lnum - buf->b_ml.ml_locked_low] & DB_INDEX_MASK);
|
||||||
buf->b_ml.ml_line_ptr = (char_u *)ptr;
|
buf->b_ml.ml_line_ptr = ptr;
|
||||||
buf->b_ml.ml_line_lnum = lnum;
|
buf->b_ml.ml_line_lnum = lnum;
|
||||||
buf->b_ml.ml_flags &= ~ML_LINE_DIRTY;
|
buf->b_ml.ml_flags &= ~ML_LINE_DIRTY;
|
||||||
}
|
}
|
||||||
if (will_change) {
|
if (will_change) {
|
||||||
buf->b_ml.ml_flags |= (ML_LOCKED_DIRTY | ML_LOCKED_POS);
|
buf->b_ml.ml_flags |= (ML_LOCKED_DIRTY | ML_LOCKED_POS);
|
||||||
ml_add_deleted_len_buf(buf, (char *)buf->b_ml.ml_line_ptr, -1);
|
ml_add_deleted_len_buf(buf, buf->b_ml.ml_line_ptr, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (char *)buf->b_ml.ml_line_ptr;
|
return buf->b_ml.ml_line_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a line that was just obtained by a call to ml_get
|
/// Check if a line that was just obtained by a call to ml_get
|
||||||
@ -1866,7 +1866,7 @@ int ml_append(linenr_T lnum, char *line, colnr_T len, bool newfile)
|
|||||||
if (curbuf->b_ml.ml_line_lnum != 0) {
|
if (curbuf->b_ml.ml_line_lnum != 0) {
|
||||||
ml_flush_line(curbuf);
|
ml_flush_line(curbuf);
|
||||||
}
|
}
|
||||||
return ml_append_int(curbuf, lnum, (char_u *)line, len, newfile, false);
|
return ml_append_int(curbuf, lnum, line, len, newfile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like ml_append() but for an arbitrary buffer. The buffer must already have
|
/// Like ml_append() but for an arbitrary buffer. The buffer must already have
|
||||||
@ -1886,7 +1886,7 @@ int ml_append_buf(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, bool new
|
|||||||
if (buf->b_ml.ml_line_lnum != 0) {
|
if (buf->b_ml.ml_line_lnum != 0) {
|
||||||
ml_flush_line(buf);
|
ml_flush_line(buf);
|
||||||
}
|
}
|
||||||
return ml_append_int(buf, lnum, line, len, newfile, false);
|
return ml_append_int(buf, lnum, (char *)line, len, newfile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param lnum append after this line (can be 0)
|
/// @param lnum append after this line (can be 0)
|
||||||
@ -1894,8 +1894,7 @@ int ml_append_buf(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, bool new
|
|||||||
/// @param len length of line, including NUL, or 0
|
/// @param len length of line, including NUL, or 0
|
||||||
/// @param newfile flag, see above
|
/// @param newfile flag, see above
|
||||||
/// @param mark mark the new line
|
/// @param mark mark the new line
|
||||||
static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, bool newfile,
|
static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, bool newfile, int mark)
|
||||||
int mark)
|
|
||||||
{
|
{
|
||||||
// lnum out of range
|
// lnum out of range
|
||||||
if (lnum > buf->b_ml.ml_line_count || buf->b_ml.ml_mfp == NULL) {
|
if (lnum > buf->b_ml.ml_line_count || buf->b_ml.ml_mfp == NULL) {
|
||||||
@ -1907,7 +1906,7 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
len = (colnr_T)STRLEN(line) + 1; // space needed for the text
|
len = (colnr_T)strlen(line) + 1; // space needed for the text
|
||||||
}
|
}
|
||||||
int space_needed = len + (int)INDEX_SIZE; // space needed for text + index
|
int space_needed = len + (int)INDEX_SIZE; // space needed for text + index
|
||||||
|
|
||||||
@ -2312,7 +2311,7 @@ void ml_add_deleted_len_buf(buf_T *buf, char *ptr, ssize_t len)
|
|||||||
if (inhibit_delete_count) {
|
if (inhibit_delete_count) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ssize_t maxlen = (ssize_t)STRLEN(ptr);
|
ssize_t maxlen = (ssize_t)strlen(ptr);
|
||||||
if (len == -1 || len > maxlen) {
|
if (len == -1 || len > maxlen) {
|
||||||
len = maxlen;
|
len = maxlen;
|
||||||
}
|
}
|
||||||
@ -2362,7 +2361,7 @@ int ml_replace_buf(buf_T *buf, linenr_T lnum, char *line, bool copy)
|
|||||||
if (buf->b_ml.ml_line_lnum != lnum) { // other line buffered
|
if (buf->b_ml.ml_line_lnum != lnum) { // other line buffered
|
||||||
ml_flush_line(buf); // flush it
|
ml_flush_line(buf); // flush it
|
||||||
} else if (buf->b_ml.ml_flags & ML_LINE_DIRTY) { // same line allocated
|
} else if (buf->b_ml.ml_flags & ML_LINE_DIRTY) { // same line allocated
|
||||||
ml_add_deleted_len_buf(buf, (char *)buf->b_ml.ml_line_ptr, -1);
|
ml_add_deleted_len_buf(buf, buf->b_ml.ml_line_ptr, -1);
|
||||||
readlen = false; // already added the length
|
readlen = false; // already added the length
|
||||||
|
|
||||||
xfree(buf->b_ml.ml_line_ptr); // free it
|
xfree(buf->b_ml.ml_line_ptr); // free it
|
||||||
@ -2372,7 +2371,7 @@ int ml_replace_buf(buf_T *buf, linenr_T lnum, char *line, bool copy)
|
|||||||
ml_add_deleted_len_buf(buf, ml_get_buf(buf, lnum, false), -1);
|
ml_add_deleted_len_buf(buf, ml_get_buf(buf, lnum, false), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->b_ml.ml_line_ptr = (char_u *)line;
|
buf->b_ml.ml_line_ptr = line;
|
||||||
buf->b_ml.ml_line_lnum = lnum;
|
buf->b_ml.ml_line_lnum = lnum;
|
||||||
buf->b_ml.ml_flags = (buf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY;
|
buf->b_ml.ml_flags = (buf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY;
|
||||||
|
|
||||||
@ -2634,7 +2633,7 @@ static void ml_flush_line(buf_T *buf)
|
|||||||
buf->flush_count++;
|
buf->flush_count++;
|
||||||
|
|
||||||
linenr_T lnum = buf->b_ml.ml_line_lnum;
|
linenr_T lnum = buf->b_ml.ml_line_lnum;
|
||||||
char_u *new_line = buf->b_ml.ml_line_ptr;
|
char *new_line = buf->b_ml.ml_line_ptr;
|
||||||
|
|
||||||
bhdr_T *hp = ml_find_line(buf, lnum, ML_FIND);
|
bhdr_T *hp = ml_find_line(buf, lnum, ML_FIND);
|
||||||
if (hp == NULL) {
|
if (hp == NULL) {
|
||||||
@ -2650,7 +2649,7 @@ static void ml_flush_line(buf_T *buf)
|
|||||||
} else { // text of previous line follows
|
} else { // text of previous line follows
|
||||||
old_len = (int)(dp->db_index[idx - 1] & DB_INDEX_MASK) - start;
|
old_len = (int)(dp->db_index[idx - 1] & DB_INDEX_MASK) - start;
|
||||||
}
|
}
|
||||||
colnr_T new_len = (colnr_T)STRLEN(new_line) + 1;
|
colnr_T new_len = (colnr_T)strlen(new_line) + 1;
|
||||||
int extra = new_len - old_len; // negative if lines gets smaller
|
int extra = new_len - old_len; // negative if lines gets smaller
|
||||||
|
|
||||||
// if new line fits in data block, replace directly
|
// if new line fits in data block, replace directly
|
||||||
@ -3021,41 +3020,41 @@ int resolve_symlink(const char *fname, char *buf)
|
|||||||
/// Make swap file name out of the file name and a directory name.
|
/// Make swap file name out of the file name and a directory name.
|
||||||
///
|
///
|
||||||
/// @return pointer to allocated memory or NULL.
|
/// @return pointer to allocated memory or NULL.
|
||||||
char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name)
|
char *makeswapname(char *fname, char *ffname, buf_T *buf, char *dir_name)
|
||||||
{
|
{
|
||||||
char_u *fname_res = fname;
|
char *fname_res = fname;
|
||||||
#ifdef HAVE_READLINK
|
#ifdef HAVE_READLINK
|
||||||
char_u fname_buf[MAXPATHL];
|
char fname_buf[MAXPATHL];
|
||||||
|
|
||||||
// Expand symlink in the file name, so that we put the swap file with the
|
// Expand symlink in the file name, so that we put the swap file with the
|
||||||
// actual file instead of with the symlink.
|
// actual file instead of with the symlink.
|
||||||
if (resolve_symlink((char *)fname, (char *)fname_buf) == OK) {
|
if (resolve_symlink(fname, (char *)fname_buf) == OK) {
|
||||||
fname_res = fname_buf;
|
fname_res = fname_buf;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
int len = (int)STRLEN(dir_name);
|
int len = (int)strlen(dir_name);
|
||||||
|
|
||||||
char_u *s = dir_name + len;
|
char *s = dir_name + len;
|
||||||
if (after_pathsep((char *)dir_name, (char *)s)
|
if (after_pathsep(dir_name, s)
|
||||||
&& len > 1
|
&& len > 1
|
||||||
&& s[-1] == s[-2]) { // Ends with '//', Use Full path
|
&& s[-1] == s[-2]) { // Ends with '//', Use Full path
|
||||||
char_u *r = NULL;
|
char *r = NULL;
|
||||||
s = (char_u *)make_percent_swname((char *)dir_name, (char *)fname_res);
|
s = make_percent_swname(dir_name, fname_res);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
r = (char_u *)modname((char *)s, ".swp", false);
|
r = modname(s, ".swp", false);
|
||||||
xfree(s);
|
xfree(s);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepend a '.' to the swap file name for the current directory.
|
// Prepend a '.' to the swap file name for the current directory.
|
||||||
char_u *r = (char_u *)modname((char *)fname_res, ".swp",
|
char_u *r = (char_u *)modname(fname_res, ".swp",
|
||||||
dir_name[0] == '.' && dir_name[1] == NUL);
|
dir_name[0] == '.' && dir_name[1] == NUL);
|
||||||
if (r == NULL) { // out of memory
|
if (r == NULL) { // out of memory
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = (char_u *)get_file_in_dir((char *)r, (char *)dir_name);
|
s = get_file_in_dir((char *)r, dir_name);
|
||||||
xfree(r);
|
xfree(r);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -3221,8 +3220,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
|
|||||||
(void)copy_option_part(dirp, dir_name, dir_len, ",");
|
(void)copy_option_part(dirp, dir_name, dir_len, ",");
|
||||||
|
|
||||||
// we try different names until we find one that does not exist yet
|
// we try different names until we find one that does not exist yet
|
||||||
char *fname = (char *)makeswapname((char_u *)buf_fname, (char_u *)buf->b_ffname, buf,
|
char *fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);
|
||||||
(char_u *)dir_name);
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (fname == NULL) { // must be out of memory
|
if (fname == NULL) { // must be out of memory
|
||||||
@ -3576,7 +3574,7 @@ void ml_setflags(buf_T *buf)
|
|||||||
if (hp->bh_bnum == 0) {
|
if (hp->bh_bnum == 0) {
|
||||||
b0p = hp->bh_data;
|
b0p = hp->bh_data;
|
||||||
b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0;
|
b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0;
|
||||||
b0p->b0_flags = (uint8_t)((b0p->b0_flags & ~B0_FF_MASK) | (uint8_t)(get_fileformat(buf) + 1));
|
b0p->b0_flags = (char)((b0p->b0_flags & ~B0_FF_MASK) | (uint8_t)(get_fileformat(buf) + 1));
|
||||||
add_b0_fenc(b0p, buf);
|
add_b0_fenc(b0p, buf);
|
||||||
hp->bh_flags |= BH_DIRTY;
|
hp->bh_flags |= BH_DIRTY;
|
||||||
mf_sync(buf->b_ml.ml_mfp, MFS_ZERO);
|
mf_sync(buf->b_ml.ml_mfp, MFS_ZERO);
|
||||||
@ -3628,7 +3626,7 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype)
|
|||||||
buf->b_ml.ml_usedchunks = 1;
|
buf->b_ml.ml_usedchunks = 1;
|
||||||
buf->b_ml.ml_chunksize[0].mlcs_numlines = 1;
|
buf->b_ml.ml_chunksize[0].mlcs_numlines = 1;
|
||||||
buf->b_ml.ml_chunksize[0].mlcs_totalsize =
|
buf->b_ml.ml_chunksize[0].mlcs_totalsize =
|
||||||
(long)STRLEN(buf->b_ml.ml_line_ptr) + 1;
|
(long)strlen(buf->b_ml.ml_line_ptr) + 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ typedef struct memline {
|
|||||||
int ml_flags;
|
int ml_flags;
|
||||||
|
|
||||||
linenr_T ml_line_lnum; // line number of cached line, 0 if not valid
|
linenr_T ml_line_lnum; // line number of cached line, 0 if not valid
|
||||||
char_u *ml_line_ptr; // pointer to cached line
|
char *ml_line_ptr; // pointer to cached line
|
||||||
size_t ml_line_offset; // cached byte offset of ml_line_lnum
|
size_t ml_line_offset; // cached byte offset of ml_line_lnum
|
||||||
int ml_line_offset_ff; // fileformat of cached line
|
int ml_line_offset_ff; // fileformat of cached line
|
||||||
|
|
||||||
|
@ -923,7 +923,7 @@ char *msg_may_trunc(bool force, char *s)
|
|||||||
|
|
||||||
room = (Rows - cmdline_row - 1) * Columns + sc_col - 1;
|
room = (Rows - cmdline_row - 1) * Columns + sc_col - 1;
|
||||||
if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
|
if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
|
||||||
&& (int)STRLEN(s) - room > 0) {
|
&& (int)strlen(s) - room > 0) {
|
||||||
int size = vim_strsize(s);
|
int size = vim_strsize(s);
|
||||||
|
|
||||||
// There may be room anyway when there are multibyte chars.
|
// There may be room anyway when there are multibyte chars.
|
||||||
|
@ -1911,7 +1911,7 @@ bool add_to_showcmd(int c)
|
|||||||
if (*p == ' ') {
|
if (*p == ' ') {
|
||||||
STRCPY(p, "<20>");
|
STRCPY(p, "<20>");
|
||||||
}
|
}
|
||||||
size_t old_len = STRLEN(showcmd_buf);
|
size_t old_len = strlen(showcmd_buf);
|
||||||
size_t extra_len = strlen(p);
|
size_t extra_len = strlen(p);
|
||||||
size_t limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN - 1 : SHOWCMD_COLS;
|
size_t limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN - 1 : SHOWCMD_COLS;
|
||||||
if (old_len + extra_len > limit) {
|
if (old_len + extra_len > limit) {
|
||||||
@ -3498,7 +3498,7 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
p = vim_strsave_fnameescape((const char *)ptr, VSE_NONE);
|
p = vim_strsave_fnameescape((const char *)ptr, VSE_NONE);
|
||||||
} else {
|
} else {
|
||||||
// Escape the argument properly for a shell command
|
// Escape the argument properly for a shell command
|
||||||
p = (char *)vim_strsave_shellescape((char_u *)ptr, true, true);
|
p = vim_strsave_shellescape(ptr, true, true);
|
||||||
}
|
}
|
||||||
xfree(ptr);
|
xfree(ptr);
|
||||||
char *newbuf = xrealloc(buf, strlen(buf) + strlen(p) + 1);
|
char *newbuf = xrealloc(buf, strlen(buf) + strlen(p) + 1);
|
||||||
|
@ -771,7 +771,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
char *s = NULL;
|
char *s = NULL;
|
||||||
char_u *oldval = NULL; // previous value if *varp
|
char_u *oldval = NULL; // previous value if *varp
|
||||||
char *newval;
|
char *newval;
|
||||||
char_u *origval = NULL;
|
char *origval = NULL;
|
||||||
char_u *origval_l = NULL;
|
char_u *origval_l = NULL;
|
||||||
char_u *origval_g = NULL;
|
char_u *origval_g = NULL;
|
||||||
char *saved_origval = NULL;
|
char *saved_origval = NULL;
|
||||||
@ -807,9 +807,9 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
// When setting the local value of a global option, the old value may be
|
// When setting the local value of a global option, the old value may be
|
||||||
// the global value.
|
// the global value.
|
||||||
if (((int)options[opt_idx].indir & PV_BOTH) && (opt_flags & OPT_LOCAL)) {
|
if (((int)options[opt_idx].indir & PV_BOTH) && (opt_flags & OPT_LOCAL)) {
|
||||||
origval = *(char_u **)get_varp(&options[opt_idx]);
|
origval = *(char **)get_varp(&options[opt_idx]);
|
||||||
} else {
|
} else {
|
||||||
origval = oldval;
|
origval = (char *)oldval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextchar == '&') { // set to default val
|
if (nextchar == '&') { // set to default val
|
||||||
@ -857,8 +857,8 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xfree(oldval);
|
xfree(oldval);
|
||||||
if (origval == oldval) {
|
if ((char_u *)origval == oldval) {
|
||||||
origval = *(char_u **)varp;
|
origval = *(char **)varp;
|
||||||
}
|
}
|
||||||
if (origval_l == oldval) {
|
if (origval_l == oldval) {
|
||||||
origval_l = *(char_u **)varp;
|
origval_l = *(char_u **)varp;
|
||||||
@ -905,7 +905,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
// get a bit too much
|
// get a bit too much
|
||||||
newlen = (unsigned)strlen(arg) + 1;
|
newlen = (unsigned)strlen(arg) + 1;
|
||||||
if (op != OP_NONE) {
|
if (op != OP_NONE) {
|
||||||
newlen += (unsigned)STRLEN(origval) + 1;
|
newlen += (unsigned)strlen(origval) + 1;
|
||||||
}
|
}
|
||||||
newval = xmalloc(newlen);
|
newval = xmalloc(newlen);
|
||||||
s = newval;
|
s = newval;
|
||||||
@ -947,7 +947,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
xfree(newval);
|
xfree(newval);
|
||||||
newlen = (unsigned)strlen(s) + 1;
|
newlen = (unsigned)strlen(s) + 1;
|
||||||
if (op != OP_NONE) {
|
if (op != OP_NONE) {
|
||||||
newlen += (unsigned)STRLEN(origval) + 1;
|
newlen += (unsigned)strlen(origval) + 1;
|
||||||
}
|
}
|
||||||
newval = xmalloc(newlen);
|
newval = xmalloc(newlen);
|
||||||
STRCPY(newval, s);
|
STRCPY(newval, s);
|
||||||
@ -958,8 +958,8 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
// and when adding to avoid duplicates
|
// and when adding to avoid duplicates
|
||||||
int len = 0;
|
int len = 0;
|
||||||
if (op == OP_REMOVING || (flags & P_NODUP)) {
|
if (op == OP_REMOVING || (flags & P_NODUP)) {
|
||||||
len = (int)STRLEN(newval);
|
len = (int)strlen(newval);
|
||||||
s = find_dup_item((char *)origval, newval, flags);
|
s = find_dup_item(origval, newval, flags);
|
||||||
|
|
||||||
// do not add if already there
|
// do not add if already there
|
||||||
if ((op == OP_ADDING || op == OP_PREPENDING) && s != NULL) {
|
if ((op == OP_ADDING || op == OP_PREPENDING) && s != NULL) {
|
||||||
@ -969,7 +969,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
|
|
||||||
// if no duplicate, move pointer to end of original value
|
// if no duplicate, move pointer to end of original value
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
s = (char *)origval + (int)STRLEN(origval);
|
s = origval + (int)strlen(origval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,7 +977,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
if (op == OP_ADDING || op == OP_PREPENDING) {
|
if (op == OP_ADDING || op == OP_PREPENDING) {
|
||||||
comma = ((flags & P_COMMA) && *origval != NUL && *newval != NUL);
|
comma = ((flags & P_COMMA) && *origval != NUL && *newval != NUL);
|
||||||
if (op == OP_ADDING) {
|
if (op == OP_ADDING) {
|
||||||
len = (int)STRLEN(origval);
|
len = (int)strlen(origval);
|
||||||
// Strip a trailing comma, would get 2.
|
// Strip a trailing comma, would get 2.
|
||||||
if (comma && len > 1
|
if (comma && len > 1
|
||||||
&& (flags & P_ONECOMMA) == P_ONECOMMA
|
&& (flags & P_ONECOMMA) == P_ONECOMMA
|
||||||
@ -1003,7 +1003,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
if (*s) {
|
if (*s) {
|
||||||
// may need to remove a comma
|
// may need to remove a comma
|
||||||
if (flags & P_COMMA) {
|
if (flags & P_COMMA) {
|
||||||
if (s == (char *)origval) {
|
if (s == origval) {
|
||||||
// include comma after string
|
// include comma after string
|
||||||
if (s[len] == ',') {
|
if (s[len] == ',') {
|
||||||
len++;
|
len++;
|
||||||
@ -1014,7 +1014,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STRMOVE(newval + (s - (char *)origval), s + len);
|
STRMOVE(newval + (s - origval), s + len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1050,7 +1050,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
|
|||||||
*(char_u **)(varp) = (char_u *)newval;
|
*(char_u **)(varp) = (char_u *)newval;
|
||||||
|
|
||||||
// origval may be freed by did_set_string_option(), make a copy.
|
// origval may be freed by did_set_string_option(), make a copy.
|
||||||
saved_origval = (origval != NULL) ? xstrdup((char *)origval) : NULL;
|
saved_origval = (origval != NULL) ? xstrdup(origval) : NULL;
|
||||||
saved_origval_l = (origval_l != NULL) ? xstrdup((char *)origval_l) : NULL;
|
saved_origval_l = (origval_l != NULL) ? xstrdup((char *)origval_l) : NULL;
|
||||||
saved_origval_g = (origval_g != NULL) ? xstrdup((char *)origval_g) : NULL;
|
saved_origval_g = (origval_g != NULL) ? xstrdup((char *)origval_g) : NULL;
|
||||||
|
|
||||||
|
@ -1521,7 +1521,7 @@ void simplify_filename(char_u *filename)
|
|||||||
// At this point "p" is pointing to the char following a single "/"
|
// At this point "p" is pointing to the char following a single "/"
|
||||||
// or "p" is at the "start" of the (absolute or relative) path name.
|
// or "p" is at the "start" of the (absolute or relative) path name.
|
||||||
if (vim_ispathsep(*p)) {
|
if (vim_ispathsep(*p)) {
|
||||||
STRMOVE(p, p + 1); // remove duplicate "/"
|
STRMOVE(p, (char *)p + 1); // remove duplicate "/"
|
||||||
} else if (p[0] == '.'
|
} else if (p[0] == '.'
|
||||||
&& (vim_ispathsep(p[1]) || p[1] == NUL)) {
|
&& (vim_ispathsep(p[1]) || p[1] == NUL)) {
|
||||||
if (p == start && relative) {
|
if (p == start && relative) {
|
||||||
@ -1539,7 +1539,7 @@ void simplify_filename(char_u *filename)
|
|||||||
} else if (p > start) {
|
} else if (p > start) {
|
||||||
p--; // strip preceding path separator
|
p--; // strip preceding path separator
|
||||||
}
|
}
|
||||||
STRMOVE(p, tail);
|
STRMOVE(p, (char *)tail);
|
||||||
}
|
}
|
||||||
} else if (p[0] == '.' && p[1] == '.'
|
} else if (p[0] == '.' && p[1] == '.'
|
||||||
&& (vim_ispathsep(p[2]) || p[2] == NUL)) {
|
&& (vim_ispathsep(p[2]) || p[2] == NUL)) {
|
||||||
@ -1638,16 +1638,16 @@ void simplify_filename(char_u *filename)
|
|||||||
if (p > start && tail[-1] == '.') {
|
if (p > start && tail[-1] == '.') {
|
||||||
p--;
|
p--;
|
||||||
}
|
}
|
||||||
STRMOVE(p, tail); // strip previous component
|
STRMOVE(p, (char *)tail); // strip previous component
|
||||||
}
|
}
|
||||||
|
|
||||||
components--;
|
components--;
|
||||||
}
|
}
|
||||||
} else if (p == start && !relative) { // leading "/.." or "/../"
|
} else if (p == start && !relative) { // leading "/.." or "/../"
|
||||||
STRMOVE(p, tail); // strip ".." or "../"
|
STRMOVE(p, (char *)tail); // strip ".." or "../"
|
||||||
} else {
|
} else {
|
||||||
if (p == start + 2 && p[-2] == '.') { // leading "./../"
|
if (p == start + 2 && p[-2] == '.') { // leading "./../"
|
||||||
STRMOVE(p - 2, p); // strip leading "./"
|
STRMOVE(p - 2, (char *)p); // strip leading "./"
|
||||||
tail -= 2;
|
tail -= 2;
|
||||||
}
|
}
|
||||||
p = tail; // skip to char after ".." or "../"
|
p = tail; // skip to char after ".." or "../"
|
||||||
|
@ -444,7 +444,7 @@ static void prof_sort_list(FILE *fd, ufunc_T **sorttab, int st_len, char *title,
|
|||||||
fp = sorttab[i];
|
fp = sorttab[i];
|
||||||
prof_func_line(fd, fp->uf_tm_count, &fp->uf_tm_total, &fp->uf_tm_self,
|
prof_func_line(fd, fp->uf_tm_count, &fp->uf_tm_total, &fp->uf_tm_self,
|
||||||
prefer_self);
|
prefer_self);
|
||||||
if (fp->uf_name[0] == K_SPECIAL) {
|
if ((uint8_t)fp->uf_name[0] == K_SPECIAL) {
|
||||||
fprintf(fd, " <SNR>%s()\n", fp->uf_name + 3);
|
fprintf(fd, " <SNR>%s()\n", fp->uf_name + 3);
|
||||||
} else {
|
} else {
|
||||||
fprintf(fd, " %s()\n", fp->uf_name);
|
fprintf(fd, " %s()\n", fp->uf_name);
|
||||||
@ -615,7 +615,7 @@ static void func_dump_profile(FILE *fd)
|
|||||||
if (fp->uf_prof_initialized) {
|
if (fp->uf_prof_initialized) {
|
||||||
sorttab[st_len++] = fp;
|
sorttab[st_len++] = fp;
|
||||||
|
|
||||||
if (fp->uf_name[0] == K_SPECIAL) {
|
if ((uint8_t)fp->uf_name[0] == K_SPECIAL) {
|
||||||
fprintf(fd, "FUNCTION <SNR>%s()\n", fp->uf_name + 3);
|
fprintf(fd, "FUNCTION <SNR>%s()\n", fp->uf_name + 3);
|
||||||
} else {
|
} else {
|
||||||
fprintf(fd, "FUNCTION %s()\n", fp->uf_name);
|
fprintf(fd, "FUNCTION %s()\n", fp->uf_name);
|
||||||
|
@ -4242,7 +4242,7 @@ static char *make_get_auname(cmdidx_T cmdidx)
|
|||||||
static char *make_get_fullcmd(const char *makecmd, const char *fname)
|
static char *make_get_fullcmd(const char *makecmd, const char *fname)
|
||||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
size_t len = STRLEN(p_shq) * 2 + strlen(makecmd) + 1;
|
size_t len = strlen(p_shq) * 2 + strlen(makecmd) + 1;
|
||||||
if (*p_sp != NUL) {
|
if (*p_sp != NUL) {
|
||||||
len += strlen(p_sp) + strlen(fname) + 3;
|
len += strlen(p_sp) + strlen(fname) + 3;
|
||||||
}
|
}
|
||||||
|
@ -1226,7 +1226,7 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
|
|||||||
linenr_T clnum = start_lnum;
|
linenr_T clnum = start_lnum;
|
||||||
colnr_T ccol = start_col;
|
colnr_T ccol = start_col;
|
||||||
int len;
|
int len;
|
||||||
char_u *p;
|
char *p;
|
||||||
|
|
||||||
if (bytelen != NULL) {
|
if (bytelen != NULL) {
|
||||||
*bytelen = 0;
|
*bytelen = 0;
|
||||||
@ -1235,7 +1235,7 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
|
|||||||
// Since getting one line may invalidate the other, need to make copy.
|
// Since getting one line may invalidate the other, need to make copy.
|
||||||
// Slow!
|
// Slow!
|
||||||
if (rex.line != reg_tofree) {
|
if (rex.line != reg_tofree) {
|
||||||
len = (int)STRLEN(rex.line);
|
len = (int)strlen((char *)rex.line);
|
||||||
if (reg_tofree == NULL || len >= (int)reg_tofreelen) {
|
if (reg_tofree == NULL || len >= (int)reg_tofreelen) {
|
||||||
len += 50; // get some extra
|
len += 50; // get some extra
|
||||||
xfree(reg_tofree);
|
xfree(reg_tofree);
|
||||||
@ -1248,16 +1248,16 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the line to compare with.
|
// Get the line to compare with.
|
||||||
p = reg_getline(clnum);
|
p = (char *)reg_getline(clnum);
|
||||||
assert(p);
|
assert(p);
|
||||||
|
|
||||||
if (clnum == end_lnum) {
|
if (clnum == end_lnum) {
|
||||||
len = end_col - ccol;
|
len = end_col - ccol;
|
||||||
} else {
|
} else {
|
||||||
len = (int)STRLEN(p + ccol);
|
len = (int)strlen(p + ccol);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cstrncmp((char *)p + ccol, (char *)rex.input, &len) != 0) {
|
if (cstrncmp(p + ccol, (char *)rex.input, &len) != 0) {
|
||||||
return RA_NOMATCH; // doesn't match
|
return RA_NOMATCH; // doesn't match
|
||||||
}
|
}
|
||||||
if (bytelen != NULL) {
|
if (bytelen != NULL) {
|
||||||
@ -1649,7 +1649,7 @@ int vim_regsub(regmatch_T *rmp, char_u *source, typval_T *expr, char_u *dest, in
|
|||||||
rex.reg_maxline = 0;
|
rex.reg_maxline = 0;
|
||||||
rex.reg_buf = curbuf;
|
rex.reg_buf = curbuf;
|
||||||
rex.reg_line_lbr = true;
|
rex.reg_line_lbr = true;
|
||||||
int result = vim_regsub_both(source, expr, dest, destlen, flags);
|
int result = vim_regsub_both((char *)source, expr, (char *)dest, destlen, flags);
|
||||||
|
|
||||||
rex_in_use = rex_in_use_save;
|
rex_in_use = rex_in_use_save;
|
||||||
if (rex_in_use) {
|
if (rex_in_use) {
|
||||||
@ -1677,7 +1677,7 @@ int vim_regsub_multi(regmmatch_T *rmp, linenr_T lnum, char_u *source, char_u *de
|
|||||||
rex.reg_firstlnum = lnum;
|
rex.reg_firstlnum = lnum;
|
||||||
rex.reg_maxline = curbuf->b_ml.ml_line_count - lnum;
|
rex.reg_maxline = curbuf->b_ml.ml_line_count - lnum;
|
||||||
rex.reg_line_lbr = false;
|
rex.reg_line_lbr = false;
|
||||||
int result = vim_regsub_both(source, NULL, dest, destlen, flags);
|
int result = vim_regsub_both((char *)source, NULL, (char *)dest, destlen, flags);
|
||||||
|
|
||||||
rex_in_use = rex_in_use_save;
|
rex_in_use = rex_in_use_save;
|
||||||
if (rex_in_use) {
|
if (rex_in_use) {
|
||||||
@ -1700,11 +1700,11 @@ void free_resub_eval_result(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int destlen, int flags)
|
static int vim_regsub_both(char *source, typval_T *expr, char *dest, int destlen, int flags)
|
||||||
{
|
{
|
||||||
char_u *src;
|
char *src;
|
||||||
char_u *dst;
|
char *dst;
|
||||||
char_u *s;
|
char *s;
|
||||||
int c;
|
int c;
|
||||||
int cc;
|
int cc;
|
||||||
int no = -1;
|
int no = -1;
|
||||||
@ -1780,14 +1780,14 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
funcexe.fe_argv_func = fill_submatch_list;
|
funcexe.fe_argv_func = fill_submatch_list;
|
||||||
funcexe.fe_evaluate = true;
|
funcexe.fe_evaluate = true;
|
||||||
if (expr->v_type == VAR_FUNC) {
|
if (expr->v_type == VAR_FUNC) {
|
||||||
s = (char_u *)expr->vval.v_string;
|
s = expr->vval.v_string;
|
||||||
call_func((char *)s, -1, &rettv, 1, argv, &funcexe);
|
call_func(s, -1, &rettv, 1, argv, &funcexe);
|
||||||
} else if (expr->v_type == VAR_PARTIAL) {
|
} else if (expr->v_type == VAR_PARTIAL) {
|
||||||
partial_T *partial = expr->vval.v_partial;
|
partial_T *partial = expr->vval.v_partial;
|
||||||
|
|
||||||
s = (char_u *)partial_name(partial);
|
s = partial_name(partial);
|
||||||
funcexe.fe_partial = partial;
|
funcexe.fe_partial = partial;
|
||||||
call_func((char *)s, -1, &rettv, 1, argv, &funcexe);
|
call_func(s, -1, &rettv, 1, argv, &funcexe);
|
||||||
}
|
}
|
||||||
if (tv_list_len(&matchList.sl_list) > 0) {
|
if (tv_list_len(&matchList.sl_list) > 0) {
|
||||||
// fill_submatch_list() was called.
|
// fill_submatch_list() was called.
|
||||||
@ -1805,14 +1805,14 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
}
|
}
|
||||||
tv_clear(&rettv);
|
tv_clear(&rettv);
|
||||||
} else {
|
} else {
|
||||||
eval_result[nested] = eval_to_string((char *)source + 2, NULL, true);
|
eval_result[nested] = eval_to_string(source + 2, NULL, true);
|
||||||
}
|
}
|
||||||
nesting--;
|
nesting--;
|
||||||
|
|
||||||
if (eval_result[nested] != NULL) {
|
if (eval_result[nested] != NULL) {
|
||||||
int had_backslash = false;
|
int had_backslash = false;
|
||||||
|
|
||||||
for (s = (char_u *)eval_result[nested]; *s != NUL; MB_PTR_ADV(s)) {
|
for (s = eval_result[nested]; *s != NUL; MB_PTR_ADV(s)) {
|
||||||
// Change NL to CR, so that it becomes a line break,
|
// Change NL to CR, so that it becomes a line break,
|
||||||
// unless called from vim_regexec_nl().
|
// unless called from vim_regexec_nl().
|
||||||
// Skip over a backslashed character.
|
// Skip over a backslashed character.
|
||||||
@ -1833,9 +1833,9 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
}
|
}
|
||||||
if (had_backslash && (flags & REGSUB_BACKSLASH)) {
|
if (had_backslash && (flags & REGSUB_BACKSLASH)) {
|
||||||
// Backslashes will be consumed, need to double them.
|
// Backslashes will be consumed, need to double them.
|
||||||
s = vim_strsave_escaped((char_u *)eval_result[nested], (char_u *)"\\");
|
s = (char *)vim_strsave_escaped((char_u *)eval_result[nested], (char_u *)"\\");
|
||||||
xfree(eval_result[nested]);
|
xfree(eval_result[nested]);
|
||||||
eval_result[nested] = (char *)s;
|
eval_result[nested] = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
dst += strlen(eval_result[nested]);
|
dst += strlen(eval_result[nested]);
|
||||||
@ -1847,7 +1847,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ((c = *src++) != NUL) {
|
while ((c = (uint8_t)(*src++)) != NUL) {
|
||||||
if (c == '&' && (flags & REGSUB_MAGIC)) {
|
if (c == '&' && (flags & REGSUB_MAGIC)) {
|
||||||
no = 0;
|
no = 0;
|
||||||
} else if (c == '\\' && *src != NUL) {
|
} else if (c == '\\' && *src != NUL) {
|
||||||
@ -1885,7 +1885,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
iemsg("vim_regsub_both(): not enough space");
|
iemsg("vim_regsub_both(): not enough space");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*dst++ = (char_u)c;
|
*dst++ = (char)c;
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
} else {
|
} else {
|
||||||
@ -1922,10 +1922,10 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
}
|
}
|
||||||
c = *src++;
|
c = (uint8_t)(*src++);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c = utf_ptr2char((char *)src - 1);
|
c = utf_ptr2char(src - 1);
|
||||||
}
|
}
|
||||||
// Write to buffer, if copy is set.
|
// Write to buffer, if copy is set.
|
||||||
if (func_one != NULL) {
|
if (func_one != NULL) {
|
||||||
@ -1937,7 +1937,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
cc = c;
|
cc = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
int totlen = utfc_ptr2len((char *)src - 1);
|
int totlen = utfc_ptr2len(src - 1);
|
||||||
int charlen = utf_char2len(cc);
|
int charlen = utf_char2len(cc);
|
||||||
|
|
||||||
if (copy) {
|
if (copy) {
|
||||||
@ -1945,10 +1945,10 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
iemsg("vim_regsub_both(): not enough space");
|
iemsg("vim_regsub_both(): not enough space");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
utf_char2bytes(cc, (char *)dst);
|
utf_char2bytes(cc, dst);
|
||||||
}
|
}
|
||||||
dst += charlen - 1;
|
dst += charlen - 1;
|
||||||
int clen = utf_ptr2len((char *)src - 1);
|
int clen = utf_ptr2len(src - 1);
|
||||||
|
|
||||||
// If the character length is shorter than "totlen", there
|
// If the character length is shorter than "totlen", there
|
||||||
// are composing characters; copy them as-is.
|
// are composing characters; copy them as-is.
|
||||||
@ -1970,20 +1970,20 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
if (clnum < 0 || rex.reg_mmatch->endpos[no].lnum < 0) {
|
if (clnum < 0 || rex.reg_mmatch->endpos[no].lnum < 0) {
|
||||||
s = NULL;
|
s = NULL;
|
||||||
} else {
|
} else {
|
||||||
s = reg_getline(clnum) + rex.reg_mmatch->startpos[no].col;
|
s = (char *)reg_getline(clnum) + rex.reg_mmatch->startpos[no].col;
|
||||||
if (rex.reg_mmatch->endpos[no].lnum == clnum) {
|
if (rex.reg_mmatch->endpos[no].lnum == clnum) {
|
||||||
len = rex.reg_mmatch->endpos[no].col
|
len = rex.reg_mmatch->endpos[no].col
|
||||||
- rex.reg_mmatch->startpos[no].col;
|
- rex.reg_mmatch->startpos[no].col;
|
||||||
} else {
|
} else {
|
||||||
len = (int)STRLEN(s);
|
len = (int)strlen(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s = (char_u *)rex.reg_match->startp[no];
|
s = rex.reg_match->startp[no];
|
||||||
if (rex.reg_match->endp[no] == NULL) {
|
if (rex.reg_match->endp[no] == NULL) {
|
||||||
s = NULL;
|
s = NULL;
|
||||||
} else {
|
} else {
|
||||||
len = (int)(rex.reg_match->endp[no] - (char *)s);
|
len = (int)(rex.reg_match->endp[no] - s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
@ -2001,11 +2001,11 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
*dst = CAR;
|
*dst = CAR;
|
||||||
}
|
}
|
||||||
dst++;
|
dst++;
|
||||||
s = reg_getline(++clnum);
|
s = (char *)reg_getline(++clnum);
|
||||||
if (rex.reg_mmatch->endpos[no].lnum == clnum) {
|
if (rex.reg_mmatch->endpos[no].lnum == clnum) {
|
||||||
len = rex.reg_mmatch->endpos[no].col;
|
len = rex.reg_mmatch->endpos[no].col;
|
||||||
} else {
|
} else {
|
||||||
len = (int)STRLEN(s);
|
len = (int)strlen(s);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -2031,7 +2031,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
}
|
}
|
||||||
dst += 2;
|
dst += 2;
|
||||||
} else {
|
} else {
|
||||||
c = utf_ptr2char((char *)s);
|
c = utf_ptr2char(s);
|
||||||
|
|
||||||
if (func_one != (fptr_T)NULL) {
|
if (func_one != (fptr_T)NULL) {
|
||||||
// Turbo C complains without the typecast
|
// Turbo C complains without the typecast
|
||||||
@ -2049,7 +2049,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
|
|
||||||
// Copy composing characters separately, one
|
// Copy composing characters separately, one
|
||||||
// at a time.
|
// at a time.
|
||||||
l = utf_ptr2len((char *)s) - 1;
|
l = utf_ptr2len(s) - 1;
|
||||||
|
|
||||||
s += l;
|
s += l;
|
||||||
len -= l;
|
len -= l;
|
||||||
@ -2059,7 +2059,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
|
|||||||
iemsg("vim_regsub_both(): not enough space");
|
iemsg("vim_regsub_both(): not enough space");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
utf_char2bytes(cc, (char *)dst);
|
utf_char2bytes(cc, dst);
|
||||||
}
|
}
|
||||||
dst += charlen - 1;
|
dst += charlen - 1;
|
||||||
}
|
}
|
||||||
|
@ -2928,9 +2928,9 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
|
|||||||
longest = NULL;
|
longest = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
for (; scan != NULL; scan = regnext(scan)) {
|
for (; scan != NULL; scan = regnext(scan)) {
|
||||||
if (OP(scan) == EXACTLY && STRLEN(OPERAND(scan)) >= (size_t)len) {
|
if (OP(scan) == EXACTLY && strlen((char *)OPERAND(scan)) >= (size_t)len) {
|
||||||
longest = OPERAND(scan);
|
longest = OPERAND(scan);
|
||||||
len = (int)STRLEN(OPERAND(scan));
|
len = (int)strlen((char *)OPERAND(scan));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r->regmust = longest;
|
r->regmust = longest;
|
||||||
@ -3658,7 +3658,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
pos = &fm->mark;
|
pos = &fm->mark;
|
||||||
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
|
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||||
&& pos->col == MAXCOL
|
&& pos->col == MAXCOL
|
||||||
? (colnr_T)STRLEN(reg_getline(pos->lnum - rex.reg_firstlnum))
|
? (colnr_T)strlen((char *)reg_getline(pos->lnum - rex.reg_firstlnum))
|
||||||
: pos->col;
|
: pos->col;
|
||||||
|
|
||||||
if (pos->lnum == rex.lnum + rex.reg_firstlnum
|
if (pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||||
@ -3976,7 +3976,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
len = 1; // matched a single byte above
|
len = 1; // matched a single byte above
|
||||||
} else {
|
} else {
|
||||||
// Need to match first byte again for multi-byte.
|
// Need to match first byte again for multi-byte.
|
||||||
len = (int)STRLEN(opnd);
|
len = (int)strlen((char *)opnd);
|
||||||
if (cstrncmp((char *)opnd, (char *)rex.input, &len) != 0) {
|
if (cstrncmp((char *)opnd, (char *)rex.input, &len) != 0) {
|
||||||
status = RA_NOMATCH;
|
status = RA_NOMATCH;
|
||||||
}
|
}
|
||||||
@ -4257,7 +4257,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
no = op - ZREF;
|
no = op - ZREF;
|
||||||
if (re_extmatch_in != NULL
|
if (re_extmatch_in != NULL
|
||||||
&& re_extmatch_in->matches[no] != NULL) {
|
&& re_extmatch_in->matches[no] != NULL) {
|
||||||
int len = (int)STRLEN(re_extmatch_in->matches[no]);
|
int len = (int)strlen((char *)re_extmatch_in->matches[no]);
|
||||||
if (cstrncmp((char *)re_extmatch_in->matches[no], (char *)rex.input, &len) != 0) {
|
if (cstrncmp((char *)re_extmatch_in->matches[no], (char *)rex.input, &len) != 0) {
|
||||||
status = RA_NOMATCH;
|
status = RA_NOMATCH;
|
||||||
} else {
|
} else {
|
||||||
@ -4683,7 +4683,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
if (limit > 0
|
if (limit > 0
|
||||||
&& ((rp->rs_un.regsave.rs_u.pos.lnum
|
&& ((rp->rs_un.regsave.rs_u.pos.lnum
|
||||||
< behind_pos.rs_u.pos.lnum
|
< behind_pos.rs_u.pos.lnum
|
||||||
? (colnr_T)STRLEN(rex.line)
|
? (colnr_T)strlen((char *)rex.line)
|
||||||
: behind_pos.rs_u.pos.col)
|
: behind_pos.rs_u.pos.col)
|
||||||
- rp->rs_un.regsave.rs_u.pos.col >= limit)) {
|
- rp->rs_un.regsave.rs_u.pos.col >= limit)) {
|
||||||
no = FAIL;
|
no = FAIL;
|
||||||
@ -4696,7 +4696,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
} else {
|
} else {
|
||||||
reg_restore(&rp->rs_un.regsave, &backpos);
|
reg_restore(&rp->rs_un.regsave, &backpos);
|
||||||
rp->rs_un.regsave.rs_u.pos.col =
|
rp->rs_un.regsave.rs_u.pos.col =
|
||||||
(colnr_T)STRLEN(rex.line);
|
(colnr_T)strlen((char *)rex.line);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const char_u *const line =
|
const char_u *const line =
|
||||||
@ -4787,7 +4787,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
if (rex.line == NULL) {
|
if (rex.line == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rex.input = rex.line + STRLEN(rex.line);
|
rex.input = rex.line + strlen((char *)rex.line);
|
||||||
fast_breakcheck();
|
fast_breakcheck();
|
||||||
} else {
|
} else {
|
||||||
MB_PTR_BACK(rex.line, rex.input);
|
MB_PTR_BACK(rex.line, rex.input);
|
||||||
|
@ -361,7 +361,7 @@ static void nfa_regcomp_start(char_u *expr, int re_flags)
|
|||||||
nstate = 0;
|
nstate = 0;
|
||||||
istate = 0;
|
istate = 0;
|
||||||
// A reasonable estimation for maximum size
|
// A reasonable estimation for maximum size
|
||||||
nstate_max = (STRLEN(expr) + 1) * 25;
|
nstate_max = (strlen((char *)expr) + 1) * 25;
|
||||||
|
|
||||||
// Some items blow up in size, such as [A-z]. Add more space for that.
|
// Some items blow up in size, such as [A-z]. Add more space for that.
|
||||||
// When it is still not enough realloc_post_list() will be used.
|
// When it is still not enough realloc_post_list() will be used.
|
||||||
@ -5418,7 +5418,7 @@ static int match_zref(int subidx, int *bytelen)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = (int)STRLEN(re_extmatch_in->matches[subidx]);
|
len = (int)strlen((char *)re_extmatch_in->matches[subidx]);
|
||||||
if (cstrncmp((char *)re_extmatch_in->matches[subidx], (char *)rex.input, &len) == 0) {
|
if (cstrncmp((char *)re_extmatch_in->matches[subidx], (char *)rex.input, &len) == 0) {
|
||||||
*bytelen = len;
|
*bytelen = len;
|
||||||
return true;
|
return true;
|
||||||
@ -5537,7 +5537,7 @@ static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T
|
|||||||
rex.line = reg_getline(++rex.lnum);
|
rex.line = reg_getline(++rex.lnum);
|
||||||
rex.input = rex.line;
|
rex.input = rex.line;
|
||||||
} else {
|
} else {
|
||||||
rex.input = rex.line + STRLEN(rex.line);
|
rex.input = rex.line + strlen((char *)rex.line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((int)(rex.input - rex.line) >= state->val) {
|
if ((int)(rex.input - rex.line) >= state->val) {
|
||||||
@ -6864,7 +6864,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
|
|||||||
pos_T *pos = &fm->mark;
|
pos_T *pos = &fm->mark;
|
||||||
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
|
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||||
&& pos->col == MAXCOL
|
&& pos->col == MAXCOL
|
||||||
? (colnr_T)STRLEN(reg_getline(pos->lnum - rex.reg_firstlnum))
|
? (colnr_T)strlen((char *)reg_getline(pos->lnum - rex.reg_firstlnum))
|
||||||
: pos->col;
|
: pos->col;
|
||||||
|
|
||||||
result = pos->lnum == rex.lnum + rex.reg_firstlnum
|
result = pos->lnum == rex.lnum + rex.reg_firstlnum
|
||||||
|
@ -105,8 +105,7 @@ estack_T *estack_push(etype_T type, char *name, linenr_T lnum)
|
|||||||
void estack_push_ufunc(ufunc_T *ufunc, linenr_T lnum)
|
void estack_push_ufunc(ufunc_T *ufunc, linenr_T lnum)
|
||||||
{
|
{
|
||||||
estack_T *entry = estack_push(ETYPE_UFUNC,
|
estack_T *entry = estack_push(ETYPE_UFUNC,
|
||||||
(char *)(ufunc->uf_name_exp != NULL
|
ufunc->uf_name_exp != NULL ? (char *)ufunc->uf_name_exp : ufunc->uf_name,
|
||||||
? ufunc->uf_name_exp : ufunc->uf_name),
|
|
||||||
lnum);
|
lnum);
|
||||||
if (entry != NULL) {
|
if (entry != NULL) {
|
||||||
entry->es_info.ufunc = ufunc;
|
entry->es_info.ufunc = ufunc;
|
||||||
|
@ -137,7 +137,7 @@ typedef struct matchinf_S {
|
|||||||
// mi_capflags
|
// mi_capflags
|
||||||
|
|
||||||
// case-folded text
|
// case-folded text
|
||||||
char_u mi_fword[MAXWLEN + 1]; // mi_word case-folded
|
char mi_fword[MAXWLEN + 1]; // mi_word case-folded
|
||||||
int mi_fwordlen; // nr of valid bytes in mi_fword
|
int mi_fwordlen; // nr of valid bytes in mi_fword
|
||||||
|
|
||||||
// for when checking word after a prefix
|
// for when checking word after a prefix
|
||||||
@ -300,9 +300,9 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
|
|||||||
MB_PTR_ADV(mi.mi_fend);
|
MB_PTR_ADV(mi.mi_fend);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
|
(void)spell_casefold(wp, ptr, (int)(mi.mi_fend - ptr), (char_u *)mi.mi_fword,
|
||||||
MAXWLEN + 1);
|
MAXWLEN + 1);
|
||||||
mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
|
mi.mi_fwordlen = (int)strlen(mi.mi_fword);
|
||||||
|
|
||||||
if (camel_case && mi.mi_fwordlen > 0) {
|
if (camel_case && mi.mi_fwordlen > 0) {
|
||||||
// introduce a fake word end space into the folded word.
|
// introduce a fake word end space into the folded word.
|
||||||
@ -388,14 +388,14 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
|
|||||||
mi.mi_lp = LANGP_ENTRY(wp->w_s->b_langp, 0);
|
mi.mi_lp = LANGP_ENTRY(wp->w_s->b_langp, 0);
|
||||||
if (mi.mi_lp->lp_slang->sl_fidxs != NULL) {
|
if (mi.mi_lp->lp_slang->sl_fidxs != NULL) {
|
||||||
p = mi.mi_word;
|
p = mi.mi_word;
|
||||||
fp = mi.mi_fword;
|
fp = (char_u *)mi.mi_fword;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
MB_PTR_ADV(p);
|
MB_PTR_ADV(p);
|
||||||
MB_PTR_ADV(fp);
|
MB_PTR_ADV(fp);
|
||||||
if (p >= mi.mi_end) {
|
if (p >= mi.mi_end) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mi.mi_compoff = (int)(fp - mi.mi_fword);
|
mi.mi_compoff = (int)(fp - (char_u *)mi.mi_fword);
|
||||||
find_word(&mi, FIND_COMPOUND);
|
find_word(&mi, FIND_COMPOUND);
|
||||||
if (mi.mi_result != SP_BAD) {
|
if (mi.mi_result != SP_BAD) {
|
||||||
mi.mi_end = p;
|
mi.mi_end = p;
|
||||||
@ -453,7 +453,7 @@ static void find_word(matchinf_T *mip, int mode)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check for case-folded in case-folded tree.
|
// Check for case-folded in case-folded tree.
|
||||||
ptr = mip->mi_fword;
|
ptr = (char_u *)mip->mi_fword;
|
||||||
flen = mip->mi_fwordlen; // available case-folded bytes
|
flen = mip->mi_fwordlen; // available case-folded bytes
|
||||||
byts = slang->sl_fbyts;
|
byts = slang->sl_fbyts;
|
||||||
idxs = slang->sl_fidxs;
|
idxs = slang->sl_fidxs;
|
||||||
@ -749,7 +749,7 @@ static void find_word(matchinf_T *mip, int mode)
|
|||||||
STRLCPY(fword, ptr, endlen[endidxcnt] + 1);
|
STRLCPY(fword, ptr, endlen[endidxcnt] + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!can_compound(slang, fword, mip->mi_compflags)) {
|
if (!can_compound(slang, (char *)fword, mip->mi_compflags)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (slang->sl_comprules != NULL
|
} else if (slang->sl_comprules != NULL
|
||||||
@ -786,12 +786,12 @@ static void find_word(matchinf_T *mip, int mode)
|
|||||||
// byte length in keep-case word. Length may change when
|
// byte length in keep-case word. Length may change when
|
||||||
// folding case. This can be slow, take a shortcut when
|
// folding case. This can be slow, take a shortcut when
|
||||||
// the case-folded word is equal to the keep-case word.
|
// the case-folded word is equal to the keep-case word.
|
||||||
p = mip->mi_fword;
|
p = (char_u *)mip->mi_fword;
|
||||||
if (STRNCMP(ptr, p, wlen) != 0) {
|
if (STRNCMP(ptr, p, wlen) != 0) {
|
||||||
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
|
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
|
||||||
MB_PTR_ADV(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
mip->mi_compoff = (int)(p - mip->mi_fword);
|
mip->mi_compoff = (int)(p - (char_u *)mip->mi_fword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
@ -925,9 +925,9 @@ bool match_checkcompoundpattern(char_u *ptr, int wlen, garray_T *gap)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if "flags" is a valid sequence of compound flags and "word"
|
/// @return true if "flags" is a valid sequence of compound flags and "word"
|
||||||
// does not have too many syllables.
|
/// does not have too many syllables.
|
||||||
bool can_compound(slang_T *slang, const char_u *word, const char_u *flags)
|
bool can_compound(slang_T *slang, const char *word, const uint8_t *flags)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char_u uflags[MAXWLEN * 2] = { 0 };
|
char_u uflags[MAXWLEN * 2] = { 0 };
|
||||||
@ -950,8 +950,8 @@ bool can_compound(slang_T *slang, const char_u *word, const char_u *flags)
|
|||||||
// are too many syllables AND the number of compound words is above
|
// are too many syllables AND the number of compound words is above
|
||||||
// COMPOUNDWORDMAX then compounding is not allowed.
|
// COMPOUNDWORDMAX then compounding is not allowed.
|
||||||
if (slang->sl_compsylmax < MAXWLEN
|
if (slang->sl_compsylmax < MAXWLEN
|
||||||
&& count_syllables(slang, word) > slang->sl_compsylmax) {
|
&& count_syllables(slang, (char_u *)word) > slang->sl_compsylmax) {
|
||||||
return (int)STRLEN(flags) < slang->sl_compmax;
|
return (int)strlen((char *)flags) < slang->sl_compmax;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1067,7 +1067,7 @@ static void find_prefix(matchinf_T *mip, int mode)
|
|||||||
}
|
}
|
||||||
// We use the case-folded word here, since prefixes are always
|
// We use the case-folded word here, since prefixes are always
|
||||||
// case-folded.
|
// case-folded.
|
||||||
char_u *ptr = mip->mi_fword;
|
char_u *ptr = (char_u *)mip->mi_fword;
|
||||||
int flen = mip->mi_fwordlen; // available case-folded bytes
|
int flen = mip->mi_fwordlen; // available case-folded bytes
|
||||||
if (mode == FIND_COMPOUND) {
|
if (mode == FIND_COMPOUND) {
|
||||||
// Skip over the previously found word(s).
|
// Skip over the previously found word(s).
|
||||||
@ -1110,7 +1110,7 @@ static void find_prefix(matchinf_T *mip, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Case-folded length may differ from original length.
|
// Case-folded length may differ from original length.
|
||||||
mip->mi_cprefixlen = nofold_len(mip->mi_fword, mip->mi_prefixlen,
|
mip->mi_cprefixlen = nofold_len((char_u *)mip->mi_fword, mip->mi_prefixlen,
|
||||||
mip->mi_word);
|
mip->mi_word);
|
||||||
find_word(mip, FIND_PREFIX);
|
find_word(mip, FIND_PREFIX);
|
||||||
|
|
||||||
@ -1168,9 +1168,9 @@ static int fold_more(matchinf_T *mip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
(void)spell_casefold(mip->mi_win, p, (int)(mip->mi_fend - p),
|
(void)spell_casefold(mip->mi_win, p, (int)(mip->mi_fend - p),
|
||||||
mip->mi_fword + mip->mi_fwordlen,
|
(char_u *)mip->mi_fword + mip->mi_fwordlen,
|
||||||
MAXWLEN - mip->mi_fwordlen);
|
MAXWLEN - mip->mi_fwordlen);
|
||||||
int flen = (int)STRLEN(mip->mi_fword + mip->mi_fwordlen);
|
int flen = (int)strlen(mip->mi_fword + mip->mi_fwordlen);
|
||||||
mip->mi_fwordlen += flen;
|
mip->mi_fwordlen += flen;
|
||||||
return flen;
|
return flen;
|
||||||
}
|
}
|
||||||
@ -2600,7 +2600,7 @@ void ex_spellrepall(exarg_T *eap)
|
|||||||
char *line = get_cursor_line_ptr();
|
char *line = get_cursor_line_ptr();
|
||||||
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
|
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
|
||||||
repl_to, strlen(repl_to)) != 0) {
|
repl_to, strlen(repl_to)) != 0) {
|
||||||
char_u *p = xmalloc(STRLEN(line) + (size_t)addlen + 1);
|
char_u *p = xmalloc(strlen(line) + (size_t)addlen + 1);
|
||||||
memmove(p, line, (size_t)curwin->w_cursor.col);
|
memmove(p, line, (size_t)curwin->w_cursor.col);
|
||||||
STRCPY(p + curwin->w_cursor.col, repl_to);
|
STRCPY(p + curwin->w_cursor.col, repl_to);
|
||||||
STRCAT(p, line + curwin->w_cursor.col + strlen(repl_from));
|
STRCAT(p, line + curwin->w_cursor.col + strlen(repl_from));
|
||||||
@ -2721,7 +2721,7 @@ char *eval_soundfold(const char *const word)
|
|||||||
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
|
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
|
||||||
// soundfold the word
|
// soundfold the word
|
||||||
char_u sound[MAXWLEN];
|
char_u sound[MAXWLEN];
|
||||||
spell_soundfold(lp->lp_slang, (char_u *)word, false, sound);
|
spell_soundfold(lp->lp_slang, (char *)word, false, (char *)sound);
|
||||||
return xstrdup((const char *)sound);
|
return xstrdup((const char *)sound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2746,23 +2746,23 @@ char *eval_soundfold(const char *const word)
|
|||||||
/// @param[in] inword word to soundfold
|
/// @param[in] inword word to soundfold
|
||||||
/// @param[in] folded whether inword is already case-folded
|
/// @param[in] folded whether inword is already case-folded
|
||||||
/// @param[in,out] res destination for soundfolded word
|
/// @param[in,out] res destination for soundfolded word
|
||||||
void spell_soundfold(slang_T *slang, char_u *inword, bool folded, char_u *res)
|
void spell_soundfold(slang_T *slang, char *inword, bool folded, char *res)
|
||||||
{
|
{
|
||||||
if (slang->sl_sofo) {
|
if (slang->sl_sofo) {
|
||||||
// SOFOFROM and SOFOTO used
|
// SOFOFROM and SOFOTO used
|
||||||
spell_soundfold_sofo(slang, inword, res);
|
spell_soundfold_sofo(slang, (char_u *)inword, (char_u *)res);
|
||||||
} else {
|
} else {
|
||||||
char_u fword[MAXWLEN];
|
char fword[MAXWLEN];
|
||||||
char_u *word;
|
char *word;
|
||||||
// SAL items used. Requires the word to be case-folded.
|
// SAL items used. Requires the word to be case-folded.
|
||||||
if (folded) {
|
if (folded) {
|
||||||
word = inword;
|
word = inword;
|
||||||
} else {
|
} else {
|
||||||
(void)spell_casefold(curwin, inword, (int)STRLEN(inword), fword, MAXWLEN);
|
(void)spell_casefold(curwin, (char_u *)inword, (int)strlen(inword), (char_u *)fword, MAXWLEN);
|
||||||
word = fword;
|
word = fword;
|
||||||
}
|
}
|
||||||
|
|
||||||
spell_soundfold_wsal(slang, word, res);
|
spell_soundfold_wsal(slang, (char_u *)word, (char_u *)res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3208,7 +3208,7 @@ void spell_dump_compl(char *pat, int ic, Direction *dir, int dumpflags_arg)
|
|||||||
if (n == WF_ONECAP) {
|
if (n == WF_ONECAP) {
|
||||||
dumpflags |= DUMPFLAG_ONECAP;
|
dumpflags |= DUMPFLAG_ONECAP;
|
||||||
} else if (n == WF_ALLCAP
|
} else if (n == WF_ALLCAP
|
||||||
&& (int)STRLEN(pat) > utfc_ptr2len(pat)) {
|
&& (int)strlen(pat) > utfc_ptr2len(pat)) {
|
||||||
dumpflags |= DUMPFLAG_ALLCAP;
|
dumpflags |= DUMPFLAG_ALLCAP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3311,8 +3311,7 @@ void spell_dump_compl(char *pat, int ic, Direction *dir, int dumpflags_arg)
|
|||||||
// when it's the first one.
|
// when it's the first one.
|
||||||
c = (int)((unsigned)flags >> 24);
|
c = (int)((unsigned)flags >> 24);
|
||||||
if (c == 0 || curi[depth] == 2) {
|
if (c == 0 || curi[depth] == 2) {
|
||||||
dump_word(slang, (char_u *)word, (char_u *)pat, dir,
|
dump_word(slang, word, pat, dir, dumpflags, flags, lnum);
|
||||||
dumpflags, flags, lnum);
|
|
||||||
if (pat == NULL) {
|
if (pat == NULL) {
|
||||||
lnum++;
|
lnum++;
|
||||||
}
|
}
|
||||||
@ -3348,15 +3347,15 @@ void spell_dump_compl(char *pat, int ic, Direction *dir, int dumpflags_arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dumps one word: apply case modifications and append a line to the buffer.
|
/// Dumps one word: apply case modifications and append a line to the buffer.
|
||||||
// When "lnum" is zero add insert mode completion.
|
/// When "lnum" is zero add insert mode completion.
|
||||||
static void dump_word(slang_T *slang, char_u *word, char_u *pat, Direction *dir, int dumpflags,
|
static void dump_word(slang_T *slang, char *word, char *pat, Direction *dir, int dumpflags,
|
||||||
int wordflags, linenr_T lnum)
|
int wordflags, linenr_T lnum)
|
||||||
{
|
{
|
||||||
bool keepcap = false;
|
bool keepcap = false;
|
||||||
char_u *p;
|
char *p;
|
||||||
char_u cword[MAXWLEN];
|
char cword[MAXWLEN];
|
||||||
char_u badword[MAXWLEN + 10];
|
char badword[MAXWLEN + 10];
|
||||||
int flags = wordflags;
|
int flags = wordflags;
|
||||||
|
|
||||||
if (dumpflags & DUMPFLAG_ONECAP) {
|
if (dumpflags & DUMPFLAG_ONECAP) {
|
||||||
@ -3368,17 +3367,17 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, Direction *dir,
|
|||||||
|
|
||||||
if ((dumpflags & DUMPFLAG_KEEPCASE) == 0 && (flags & WF_CAPMASK) != 0) {
|
if ((dumpflags & DUMPFLAG_KEEPCASE) == 0 && (flags & WF_CAPMASK) != 0) {
|
||||||
// Need to fix case according to "flags".
|
// Need to fix case according to "flags".
|
||||||
make_case_word(word, cword, flags);
|
make_case_word((char_u *)word, (char_u *)cword, flags);
|
||||||
p = cword;
|
p = cword;
|
||||||
} else {
|
} else {
|
||||||
p = word;
|
p = word;
|
||||||
if ((dumpflags & DUMPFLAG_KEEPCASE)
|
if ((dumpflags & DUMPFLAG_KEEPCASE)
|
||||||
&& ((captype(word, NULL) & WF_KEEPCAP) == 0
|
&& ((captype((char_u *)word, NULL) & WF_KEEPCAP) == 0
|
||||||
|| (flags & WF_FIXCAP) != 0)) {
|
|| (flags & WF_FIXCAP) != 0)) {
|
||||||
keepcap = true;
|
keepcap = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char_u *tw = p;
|
char *tw = p;
|
||||||
|
|
||||||
if (pat == NULL) {
|
if (pat == NULL) {
|
||||||
// Add flags and regions after a slash.
|
// Add flags and regions after a slash.
|
||||||
@ -3396,8 +3395,8 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, Direction *dir,
|
|||||||
if (flags & WF_REGION) {
|
if (flags & WF_REGION) {
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
if (flags & (0x10000 << i)) {
|
if (flags & (0x10000 << i)) {
|
||||||
const size_t badword_len = STRLEN(badword);
|
const size_t badword_len = strlen(badword);
|
||||||
snprintf((char *)badword + badword_len,
|
snprintf(badword + badword_len,
|
||||||
sizeof(badword) - badword_len,
|
sizeof(badword) - badword_len,
|
||||||
"%d", i + 1);
|
"%d", i + 1);
|
||||||
}
|
}
|
||||||
@ -3410,19 +3409,19 @@ static void dump_word(slang_T *slang, char_u *word, char_u *pat, Direction *dir,
|
|||||||
hashitem_T *hi;
|
hashitem_T *hi;
|
||||||
|
|
||||||
// Include the word count for ":spelldump!".
|
// Include the word count for ":spelldump!".
|
||||||
hi = hash_find(&slang->sl_wordcount, (char *)tw);
|
hi = hash_find(&slang->sl_wordcount, tw);
|
||||||
if (!HASHITEM_EMPTY(hi)) {
|
if (!HASHITEM_EMPTY(hi)) {
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, "%s\t%d",
|
vim_snprintf((char *)IObuff, IOSIZE, "%s\t%d",
|
||||||
tw, HI2WC(hi)->wc_count);
|
tw, HI2WC(hi)->wc_count);
|
||||||
p = (char_u *)IObuff;
|
p = IObuff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ml_append(lnum, (char *)p, (colnr_T)0, false);
|
ml_append(lnum, p, (colnr_T)0, false);
|
||||||
} else if (((dumpflags & DUMPFLAG_ICASE)
|
} else if (((dumpflags & DUMPFLAG_ICASE)
|
||||||
? mb_strnicmp((char *)p, (char *)pat, STRLEN(pat)) == 0
|
? mb_strnicmp(p, pat, strlen(pat)) == 0
|
||||||
: STRNCMP(p, pat, STRLEN(pat)) == 0)
|
: STRNCMP(p, pat, strlen(pat)) == 0)
|
||||||
&& ins_compl_add_infercase(p, (int)STRLEN(p),
|
&& ins_compl_add_infercase((char_u *)p, (int)strlen(p),
|
||||||
p_ic, NULL, *dir, false) == OK) {
|
p_ic, NULL, *dir, false) == OK) {
|
||||||
// if dir was BACKWARD then honor it just once
|
// if dir was BACKWARD then honor it just once
|
||||||
*dir = FORWARD;
|
*dir = FORWARD;
|
||||||
@ -3488,7 +3487,7 @@ static linenr_T dump_prefixes(slang_T *slang, char_u *word, char_u *pat, Directi
|
|||||||
c = valid_word_prefix(i, n, flags, word, slang, false);
|
c = valid_word_prefix(i, n, flags, word, slang, false);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
STRLCPY(prefix + depth, word, MAXWLEN - depth);
|
STRLCPY(prefix + depth, word, MAXWLEN - depth);
|
||||||
dump_word(slang, prefix, pat, dir, dumpflags,
|
dump_word(slang, (char *)prefix, (char *)pat, dir, dumpflags,
|
||||||
(c & WF_RAREPFX) ? (flags | WF_RARE) : flags, lnum);
|
(c & WF_RAREPFX) ? (flags | WF_RARE) : flags, lnum);
|
||||||
if (lnum != 0) {
|
if (lnum != 0) {
|
||||||
lnum++;
|
lnum++;
|
||||||
@ -3503,7 +3502,7 @@ static linenr_T dump_prefixes(slang_T *slang, char_u *word, char_u *pat, Directi
|
|||||||
true);
|
true);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
STRLCPY(prefix + depth, word_up, MAXWLEN - depth);
|
STRLCPY(prefix + depth, word_up, MAXWLEN - depth);
|
||||||
dump_word(slang, prefix, pat, dir, dumpflags,
|
dump_word(slang, (char *)prefix, (char *)pat, dir, dumpflags,
|
||||||
(c & WF_RAREPFX) ? (flags | WF_RARE) : flags, lnum);
|
(c & WF_RAREPFX) ? (flags | WF_RARE) : flags, lnum);
|
||||||
if (lnum != 0) {
|
if (lnum != 0) {
|
||||||
lnum++;
|
lnum++;
|
||||||
|
@ -72,8 +72,8 @@ typedef int idx_T;
|
|||||||
// si_repsal, sl_rep, and si_sal. Not for sl_sal!
|
// si_repsal, sl_rep, and si_sal. Not for sl_sal!
|
||||||
// One replacement: from "ft_from" to "ft_to".
|
// One replacement: from "ft_from" to "ft_to".
|
||||||
typedef struct fromto_S {
|
typedef struct fromto_S {
|
||||||
char_u *ft_from;
|
uint8_t *ft_from;
|
||||||
char_u *ft_to;
|
uint8_t *ft_to;
|
||||||
} fromto_T;
|
} fromto_T;
|
||||||
|
|
||||||
// Info from "SAL" entries in ".aff" file used in sl_sal.
|
// Info from "SAL" entries in ".aff" file used in sl_sal.
|
||||||
|
@ -365,8 +365,8 @@ typedef struct affentry_S affentry_T;
|
|||||||
// Affix entry from ".aff" file. Used for prefixes and suffixes.
|
// Affix entry from ".aff" file. Used for prefixes and suffixes.
|
||||||
struct affentry_S {
|
struct affentry_S {
|
||||||
affentry_T *ae_next; // next affix with same name/number
|
affentry_T *ae_next; // next affix with same name/number
|
||||||
char_u *ae_chop; // text to chop off basic word (can be NULL)
|
char *ae_chop; // text to chop off basic word (can be NULL)
|
||||||
char_u *ae_add; // text to add to basic word (can be NULL)
|
char *ae_add; // text to add to basic word (can be NULL)
|
||||||
char_u *ae_flags; // flags on the affix (can be NULL)
|
char_u *ae_flags; // flags on the affix (can be NULL)
|
||||||
char_u *ae_cond; // condition (NULL for ".")
|
char_u *ae_cond; // condition (NULL for ".")
|
||||||
regprog_T *ae_prog; // regexp program for ae_cond or NULL
|
regprog_T *ae_prog; // regexp program for ae_cond or NULL
|
||||||
@ -483,7 +483,7 @@ typedef struct spellinfo_S {
|
|||||||
int si_memtot; // runtime memory used
|
int si_memtot; // runtime memory used
|
||||||
int si_verbose; // verbose messages
|
int si_verbose; // verbose messages
|
||||||
int si_msg_count; // number of words added since last message
|
int si_msg_count; // number of words added since last message
|
||||||
char_u *si_info; // info text chars or NULL
|
char *si_info; // info text chars or NULL
|
||||||
int si_region_count; // number of regions supported (1 when there
|
int si_region_count; // number of regions supported (1 when there
|
||||||
// are no regions)
|
// are no regions)
|
||||||
char_u si_region_name[MAXREGIONS * 2 + 1];
|
char_u si_region_name[MAXREGIONS * 2 + 1];
|
||||||
@ -493,8 +493,8 @@ typedef struct spellinfo_S {
|
|||||||
garray_T si_rep; // list of fromto_T entries from REP lines
|
garray_T si_rep; // list of fromto_T entries from REP lines
|
||||||
garray_T si_repsal; // list of fromto_T entries from REPSAL lines
|
garray_T si_repsal; // list of fromto_T entries from REPSAL lines
|
||||||
garray_T si_sal; // list of fromto_T entries from SAL lines
|
garray_T si_sal; // list of fromto_T entries from SAL lines
|
||||||
char_u *si_sofofr; // SOFOFROM text
|
char *si_sofofr; // SOFOFROM text
|
||||||
char_u *si_sofoto; // SOFOTO text
|
char *si_sofoto; // SOFOTO text
|
||||||
int si_nosugfile; // NOSUGFILE item found
|
int si_nosugfile; // NOSUGFILE item found
|
||||||
int si_nosplitsugs; // NOSPLITSUGS item found
|
int si_nosplitsugs; // NOSPLITSUGS item found
|
||||||
int si_nocompoundsugs; // NOCOMPOUNDSUGS item found
|
int si_nocompoundsugs; // NOCOMPOUNDSUGS item found
|
||||||
@ -504,16 +504,16 @@ typedef struct spellinfo_S {
|
|||||||
time_t si_sugtime; // timestamp for .sug file
|
time_t si_sugtime; // timestamp for .sug file
|
||||||
int si_rem_accents; // soundsalike: remove accents
|
int si_rem_accents; // soundsalike: remove accents
|
||||||
garray_T si_map; // MAP info concatenated
|
garray_T si_map; // MAP info concatenated
|
||||||
char_u *si_midword; // MIDWORD chars or NULL
|
char *si_midword; // MIDWORD chars or NULL
|
||||||
int si_compmax; // max nr of words for compounding
|
int si_compmax; // max nr of words for compounding
|
||||||
int si_compminlen; // minimal length for compounding
|
int si_compminlen; // minimal length for compounding
|
||||||
int si_compsylmax; // max nr of syllables for compounding
|
int si_compsylmax; // max nr of syllables for compounding
|
||||||
int si_compoptions; // COMP_ flags
|
int si_compoptions; // COMP_ flags
|
||||||
garray_T si_comppat; // CHECKCOMPOUNDPATTERN items, each stored as
|
garray_T si_comppat; // CHECKCOMPOUNDPATTERN items, each stored as
|
||||||
// a string
|
// a string
|
||||||
char_u *si_compflags; // flags used for compounding
|
char *si_compflags; // flags used for compounding
|
||||||
char_u si_nobreak; // NOBREAK
|
char_u si_nobreak; // NOBREAK
|
||||||
char_u *si_syllable; // syllable string
|
char *si_syllable; // syllable string
|
||||||
garray_T si_prefcond; // table with conditions for postponed
|
garray_T si_prefcond; // table with conditions for postponed
|
||||||
// prefixes, each stored as a string
|
// prefixes, each stored as a string
|
||||||
int si_newprefID; // current value for ah_newID
|
int si_newprefID; // current value for ah_newID
|
||||||
@ -2046,11 +2046,11 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
bool found_map = false;
|
bool found_map = false;
|
||||||
hashitem_T *hi;
|
hashitem_T *hi;
|
||||||
int l;
|
int l;
|
||||||
int compminlen = 0; // COMPOUNDMIN value
|
int compminlen = 0; // COMPOUNDMIN value
|
||||||
int compsylmax = 0; // COMPOUNDSYLMAX value
|
int compsylmax = 0; // COMPOUNDSYLMAX value
|
||||||
int compoptions = 0; // COMP_ flags
|
int compoptions = 0; // COMP_ flags
|
||||||
int compmax = 0; // COMPOUNDWORDMAX value
|
int compmax = 0; // COMPOUNDWORDMAX value
|
||||||
char_u *compflags = NULL; // COMPOUNDFLAG and COMPOUNDRULE
|
char *compflags = NULL; // COMPOUNDFLAG and COMPOUNDRULE
|
||||||
// concatenated
|
// concatenated
|
||||||
char_u *midword = NULL; // MIDWORD value
|
char_u *midword = NULL; // MIDWORD value
|
||||||
char_u *syllable = NULL; // SYLLABLE value
|
char_u *syllable = NULL; // SYLLABLE value
|
||||||
@ -2179,7 +2179,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
}
|
}
|
||||||
} else if (spell_info_item(items[0]) && itemcnt > 1) {
|
} else if (spell_info_item(items[0]) && itemcnt > 1) {
|
||||||
p = getroom(spin,
|
p = getroom(spin,
|
||||||
(spin->si_info == NULL ? 0 : STRLEN(spin->si_info))
|
(spin->si_info == NULL ? 0 : strlen(spin->si_info))
|
||||||
+ strlen(items[0])
|
+ strlen(items[0])
|
||||||
+ strlen(items[1]) + 3, false);
|
+ strlen(items[1]) + 3, false);
|
||||||
if (spin->si_info != NULL) {
|
if (spin->si_info != NULL) {
|
||||||
@ -2189,9 +2189,9 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
STRCAT(p, items[0]);
|
STRCAT(p, items[0]);
|
||||||
STRCAT(p, " ");
|
STRCAT(p, " ");
|
||||||
STRCAT(p, items[1]);
|
STRCAT(p, items[1]);
|
||||||
spin->si_info = (char_u *)p;
|
spin->si_info = p;
|
||||||
} else if (is_aff_rule(items, itemcnt, "MIDWORD", 2) && midword == NULL) {
|
} else if (is_aff_rule(items, itemcnt, "MIDWORD", 2) && midword == NULL) {
|
||||||
midword = (char_u *)getroom_save(spin, (char_u *)items[1]);
|
midword = (char_u *)getroom_save(spin, items[1]);
|
||||||
} else if (is_aff_rule(items, itemcnt, "TRY", 2)) {
|
} else if (is_aff_rule(items, itemcnt, "TRY", 2)) {
|
||||||
// ignored, we look in the tree for what chars may appear
|
// ignored, we look in the tree for what chars may appear
|
||||||
} else if ((is_aff_rule(items, itemcnt, "RAR", 2) // TODO(vim): remove "RAR" later
|
} else if ((is_aff_rule(items, itemcnt, "RAR", 2) // TODO(vim): remove "RAR" later
|
||||||
@ -2253,7 +2253,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
p = getroom(spin, strlen(items[1]) + 2, false);
|
p = getroom(spin, strlen(items[1]) + 2, false);
|
||||||
STRCPY(p, items[1]);
|
STRCPY(p, items[1]);
|
||||||
STRCAT(p, "+");
|
STRCAT(p, "+");
|
||||||
compflags = (char_u *)p;
|
compflags = p;
|
||||||
} else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2)) {
|
} else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2)) {
|
||||||
// We don't use the count, but do check that it's a number and
|
// We don't use the count, but do check that it's a number and
|
||||||
// not COMPOUNDRULE mistyped.
|
// not COMPOUNDRULE mistyped.
|
||||||
@ -2268,7 +2268,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
// using a slash to separate them.
|
// using a slash to separate them.
|
||||||
l = (int)strlen(items[1]) + 1;
|
l = (int)strlen(items[1]) + 1;
|
||||||
if (compflags != NULL) {
|
if (compflags != NULL) {
|
||||||
l += (int)STRLEN(compflags) + 1;
|
l += (int)strlen(compflags) + 1;
|
||||||
}
|
}
|
||||||
p = getroom(spin, (size_t)l, false);
|
p = getroom(spin, (size_t)l, false);
|
||||||
if (compflags != NULL) {
|
if (compflags != NULL) {
|
||||||
@ -2276,7 +2276,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
STRCAT(p, "/");
|
STRCAT(p, "/");
|
||||||
}
|
}
|
||||||
STRCAT(p, items[1]);
|
STRCAT(p, items[1]);
|
||||||
compflags = (char_u *)p;
|
compflags = p;
|
||||||
}
|
}
|
||||||
} else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
|
} else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
|
||||||
&& compmax == 0) {
|
&& compmax == 0) {
|
||||||
@ -2325,12 +2325,12 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
}
|
}
|
||||||
if (i >= gap->ga_len) {
|
if (i >= gap->ga_len) {
|
||||||
ga_grow(gap, 2);
|
ga_grow(gap, 2);
|
||||||
((char **)(gap->ga_data))[gap->ga_len++] = getroom_save(spin, (char_u *)items[1]);
|
((char **)(gap->ga_data))[gap->ga_len++] = getroom_save(spin, items[1]);
|
||||||
((char **)(gap->ga_data))[gap->ga_len++] = getroom_save(spin, (char_u *)items[2]);
|
((char **)(gap->ga_data))[gap->ga_len++] = getroom_save(spin, items[2]);
|
||||||
}
|
}
|
||||||
} else if (is_aff_rule(items, itemcnt, "SYLLABLE", 2)
|
} else if (is_aff_rule(items, itemcnt, "SYLLABLE", 2)
|
||||||
&& syllable == NULL) {
|
&& syllable == NULL) {
|
||||||
syllable = (char_u *)getroom_save(spin, (char_u *)items[1]);
|
syllable = (char_u *)getroom_save(spin, items[1]);
|
||||||
} else if (is_aff_rule(items, itemcnt, "NOBREAK", 1)) {
|
} else if (is_aff_rule(items, itemcnt, "NOBREAK", 1)) {
|
||||||
spin->si_nobreak = true;
|
spin->si_nobreak = true;
|
||||||
} else if (is_aff_rule(items, itemcnt, "NOSPLITSUGS", 1)) {
|
} else if (is_aff_rule(items, itemcnt, "NOSPLITSUGS", 1)) {
|
||||||
@ -2394,7 +2394,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
fname, lnum, items[1]);
|
fname, lnum, items[1]);
|
||||||
}
|
}
|
||||||
STRCPY(cur_aff->ah_key, items[1]);
|
STRCPY(cur_aff->ah_key, items[1]);
|
||||||
hash_add(tp, (char_u *)cur_aff->ah_key);
|
hash_add(tp, cur_aff->ah_key);
|
||||||
|
|
||||||
cur_aff->ah_combine = (*items[2] == 'Y');
|
cur_aff->ah_combine = (*items[2] == 'Y');
|
||||||
}
|
}
|
||||||
@ -2463,13 +2463,13 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
aff_entry = getroom(spin, sizeof(*aff_entry), true);
|
aff_entry = getroom(spin, sizeof(*aff_entry), true);
|
||||||
|
|
||||||
if (strcmp(items[2], "0") != 0) {
|
if (strcmp(items[2], "0") != 0) {
|
||||||
aff_entry->ae_chop = (char_u *)getroom_save(spin, (char_u *)items[2]);
|
aff_entry->ae_chop = getroom_save(spin, items[2]);
|
||||||
}
|
}
|
||||||
if (strcmp(items[3], "0") != 0) {
|
if (strcmp(items[3], "0") != 0) {
|
||||||
aff_entry->ae_add = (char_u *)getroom_save(spin, (char_u *)items[3]);
|
aff_entry->ae_add = getroom_save(spin, items[3]);
|
||||||
|
|
||||||
// Recognize flags on the affix: abcd/XYZ
|
// Recognize flags on the affix: abcd/XYZ
|
||||||
aff_entry->ae_flags = (char_u *)vim_strchr((char *)aff_entry->ae_add, '/');
|
aff_entry->ae_flags = (char_u *)vim_strchr(aff_entry->ae_add, '/');
|
||||||
if (aff_entry->ae_flags != NULL) {
|
if (aff_entry->ae_flags != NULL) {
|
||||||
*aff_entry->ae_flags++ = NUL;
|
*aff_entry->ae_flags++ = NUL;
|
||||||
aff_process_flags(aff, aff_entry);
|
aff_process_flags(aff, aff_entry);
|
||||||
@ -2478,15 +2478,15 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
|
|
||||||
// Don't use an affix entry with non-ASCII characters when
|
// Don't use an affix entry with non-ASCII characters when
|
||||||
// "spin->si_ascii" is true.
|
// "spin->si_ascii" is true.
|
||||||
if (!spin->si_ascii || !(has_non_ascii(aff_entry->ae_chop)
|
if (!spin->si_ascii || !(has_non_ascii((char_u *)aff_entry->ae_chop)
|
||||||
|| has_non_ascii(aff_entry->ae_add))) {
|
|| has_non_ascii((char_u *)aff_entry->ae_add))) {
|
||||||
aff_entry->ae_next = cur_aff->ah_first;
|
aff_entry->ae_next = cur_aff->ah_first;
|
||||||
cur_aff->ah_first = aff_entry;
|
cur_aff->ah_first = aff_entry;
|
||||||
|
|
||||||
if (strcmp(items[4], ".") != 0) {
|
if (strcmp(items[4], ".") != 0) {
|
||||||
char_u buf[MAXLINELEN];
|
char_u buf[MAXLINELEN];
|
||||||
|
|
||||||
aff_entry->ae_cond = (char_u *)getroom_save(spin, (char_u *)items[4]);
|
aff_entry->ae_cond = (char_u *)getroom_save(spin, items[4]);
|
||||||
if (*items[0] == 'P') {
|
if (*items[0] == 'P') {
|
||||||
sprintf((char *)buf, "^%s", items[4]); // NOLINT(runtime/printf)
|
sprintf((char *)buf, "^%s", items[4]); // NOLINT(runtime/printf)
|
||||||
} else {
|
} else {
|
||||||
@ -2512,17 +2512,16 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
// be empty or start with the same letter.
|
// be empty or start with the same letter.
|
||||||
if (aff_entry->ae_chop != NULL
|
if (aff_entry->ae_chop != NULL
|
||||||
&& aff_entry->ae_add != NULL
|
&& aff_entry->ae_add != NULL
|
||||||
&& aff_entry->ae_chop[utfc_ptr2len((char *)aff_entry->ae_chop)] ==
|
&& aff_entry->ae_chop[utfc_ptr2len(aff_entry->ae_chop)] ==
|
||||||
NUL) {
|
NUL) {
|
||||||
int c, c_up;
|
int c, c_up;
|
||||||
|
|
||||||
c = utf_ptr2char((char *)aff_entry->ae_chop);
|
c = utf_ptr2char(aff_entry->ae_chop);
|
||||||
c_up = SPELL_TOUPPER(c);
|
c_up = SPELL_TOUPPER(c);
|
||||||
if (c_up != c
|
if (c_up != c
|
||||||
&& (aff_entry->ae_cond == NULL
|
&& (aff_entry->ae_cond == NULL
|
||||||
|| utf_ptr2char((char *)aff_entry->ae_cond) == c)) {
|
|| utf_ptr2char((char *)aff_entry->ae_cond) == c)) {
|
||||||
p = (char *)aff_entry->ae_add
|
p = aff_entry->ae_add + strlen(aff_entry->ae_add);
|
||||||
+ STRLEN(aff_entry->ae_add);
|
|
||||||
MB_PTR_BACK(aff_entry->ae_add, p);
|
MB_PTR_BACK(aff_entry->ae_add, p);
|
||||||
if (utf_ptr2char(p) == c_up) {
|
if (utf_ptr2char(p) == c_up) {
|
||||||
upper = true;
|
upper = true;
|
||||||
@ -2535,7 +2534,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
if (aff_entry->ae_cond != NULL) {
|
if (aff_entry->ae_cond != NULL) {
|
||||||
char_u buf[MAXLINELEN];
|
char_u buf[MAXLINELEN];
|
||||||
onecap_copy((char_u *)items[4], buf, true);
|
onecap_copy((char_u *)items[4], buf, true);
|
||||||
aff_entry->ae_cond = (char_u *)getroom_save(spin, buf);
|
aff_entry->ae_cond = (char_u *)getroom_save(spin, (char *)buf);
|
||||||
if (aff_entry->ae_cond != NULL) {
|
if (aff_entry->ae_cond != NULL) {
|
||||||
sprintf((char *)buf, "^%s", aff_entry->ae_cond); // NOLINT(runtime/printf)
|
sprintf((char *)buf, "^%s", aff_entry->ae_cond); // NOLINT(runtime/printf)
|
||||||
vim_regfree(aff_entry->ae_prog);
|
vim_regfree(aff_entry->ae_prog);
|
||||||
@ -2563,14 +2562,14 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
idx = spin->si_prefcond.ga_len;
|
idx = spin->si_prefcond.ga_len;
|
||||||
pp = GA_APPEND_VIA_PTR(char_u *, &spin->si_prefcond);
|
pp = GA_APPEND_VIA_PTR(char_u *, &spin->si_prefcond);
|
||||||
*pp = (aff_entry->ae_cond == NULL) ?
|
*pp = (aff_entry->ae_cond == NULL) ?
|
||||||
NULL : (char_u *)getroom_save(spin, aff_entry->ae_cond);
|
NULL : (char_u *)getroom_save(spin, (char *)aff_entry->ae_cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the prefix to the prefix tree.
|
// Add the prefix to the prefix tree.
|
||||||
if (aff_entry->ae_add == NULL) {
|
if (aff_entry->ae_add == NULL) {
|
||||||
p = "";
|
p = "";
|
||||||
} else {
|
} else {
|
||||||
p = (char *)aff_entry->ae_add;
|
p = aff_entry->ae_add;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PFX_FLAGS is a negative number, so that
|
// PFX_FLAGS is a negative number, so that
|
||||||
@ -2637,7 +2636,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
}
|
}
|
||||||
add_fromto(spin, items[0][3] == 'S'
|
add_fromto(spin, items[0][3] == 'S'
|
||||||
? &spin->si_repsal
|
? &spin->si_repsal
|
||||||
: &spin->si_rep, (char_u *)items[1], (char_u *)items[2]);
|
: &spin->si_rep, items[1], items[2]);
|
||||||
}
|
}
|
||||||
} else if (is_aff_rule(items, itemcnt, "MAP", 2)) {
|
} else if (is_aff_rule(items, itemcnt, "MAP", 2)) {
|
||||||
// MAP item or count
|
// MAP item or count
|
||||||
@ -2682,24 +2681,24 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
spin->si_rem_accents = sal_to_bool(items[2]);
|
spin->si_rem_accents = sal_to_bool(items[2]);
|
||||||
} else {
|
} else {
|
||||||
// when "to" is "_" it means empty
|
// when "to" is "_" it means empty
|
||||||
add_fromto(spin, &spin->si_sal, (char_u *)items[1],
|
add_fromto(spin, &spin->si_sal, items[1],
|
||||||
strcmp(items[2], "_") == 0 ? (char_u *)""
|
strcmp(items[2], "_") == 0 ? ""
|
||||||
: (char_u *)items[2]);
|
: items[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (is_aff_rule(items, itemcnt, "SOFOFROM", 2)
|
} else if (is_aff_rule(items, itemcnt, "SOFOFROM", 2)
|
||||||
&& sofofrom == NULL) {
|
&& sofofrom == NULL) {
|
||||||
sofofrom = (char_u *)getroom_save(spin, (char_u *)items[1]);
|
sofofrom = (char_u *)getroom_save(spin, items[1]);
|
||||||
} else if (is_aff_rule(items, itemcnt, "SOFOTO", 2)
|
} else if (is_aff_rule(items, itemcnt, "SOFOTO", 2)
|
||||||
&& sofoto == NULL) {
|
&& sofoto == NULL) {
|
||||||
sofoto = (char_u *)getroom_save(spin, (char_u *)items[1]);
|
sofoto = (char_u *)getroom_save(spin, items[1]);
|
||||||
} else if (strcmp(items[0], "COMMON") == 0) {
|
} else if (strcmp(items[0], "COMMON") == 0) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < itemcnt; i++) {
|
for (i = 1; i < itemcnt; i++) {
|
||||||
if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, (char *)items[i]))) {
|
if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, (char *)items[i]))) {
|
||||||
p = xstrdup(items[i]);
|
p = xstrdup(items[i]);
|
||||||
hash_add(&spin->si_commonwords, (char_u *)p);
|
hash_add(&spin->si_commonwords, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2762,8 +2761,8 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (syllable != NULL) {
|
if (syllable != NULL) {
|
||||||
aff_check_string((char *)spin->si_syllable, (char *)syllable, "SYLLABLE");
|
aff_check_string(spin->si_syllable, (char *)syllable, "SYLLABLE");
|
||||||
spin->si_syllable = syllable;
|
spin->si_syllable = (char *)syllable;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sofofrom != NULL || sofoto != NULL) {
|
if (sofofrom != NULL || sofoto != NULL) {
|
||||||
@ -2773,16 +2772,16 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
} else if (!GA_EMPTY(&spin->si_sal)) {
|
} else if (!GA_EMPTY(&spin->si_sal)) {
|
||||||
smsg(_("Both SAL and SOFO lines in %s"), fname);
|
smsg(_("Both SAL and SOFO lines in %s"), fname);
|
||||||
} else {
|
} else {
|
||||||
aff_check_string((char *)spin->si_sofofr, (char *)sofofrom, "SOFOFROM");
|
aff_check_string(spin->si_sofofr, (char *)sofofrom, "SOFOFROM");
|
||||||
aff_check_string((char *)spin->si_sofoto, (char *)sofoto, "SOFOTO");
|
aff_check_string(spin->si_sofoto, (char *)sofoto, "SOFOTO");
|
||||||
spin->si_sofofr = sofofrom;
|
spin->si_sofofr = (char *)sofofrom;
|
||||||
spin->si_sofoto = sofoto;
|
spin->si_sofoto = (char *)sofoto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (midword != NULL) {
|
if (midword != NULL) {
|
||||||
aff_check_string((char *)spin->si_midword, (char *)midword, "MIDWORD");
|
aff_check_string(spin->si_midword, (char *)midword, "MIDWORD");
|
||||||
spin->si_midword = midword;
|
spin->si_midword = (char *)midword;
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(pc);
|
xfree(pc);
|
||||||
@ -2813,7 +2812,7 @@ static void aff_process_flags(afffile_T *affile, affentry_T *entry)
|
|||||||
prevp = p;
|
prevp = p;
|
||||||
flag = get_affitem(affile->af_flagtype, &p);
|
flag = get_affitem(affile->af_flagtype, &p);
|
||||||
if (flag == affile->af_comppermit || flag == affile->af_compforbid) {
|
if (flag == affile->af_comppermit || flag == affile->af_compforbid) {
|
||||||
STRMOVE(prevp, p);
|
STRMOVE(prevp, (char *)p);
|
||||||
p = prevp;
|
p = prevp;
|
||||||
if (flag == affile->af_comppermit) {
|
if (flag == affile->af_comppermit) {
|
||||||
entry->ae_comppermit = true;
|
entry->ae_comppermit = true;
|
||||||
@ -2896,13 +2895,13 @@ static unsigned get_affitem(int flagtype, char_u **pp)
|
|||||||
return (unsigned)res;
|
return (unsigned)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the "compflags" string used in an affix file and append it to
|
/// Process the "compflags" string used in an affix file and append it to
|
||||||
// spin->si_compflags.
|
/// spin->si_compflags.
|
||||||
// The processing involves changing the affix names to ID numbers, so that
|
/// The processing involves changing the affix names to ID numbers, so that
|
||||||
// they fit in one byte.
|
/// they fit in one byte.
|
||||||
static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compflags)
|
static void process_compflags(spellinfo_T *spin, afffile_T *aff, char *compflags)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char *p;
|
||||||
char_u *prevp;
|
char_u *prevp;
|
||||||
unsigned flag;
|
unsigned flag;
|
||||||
compitem_T *ci;
|
compitem_T *ci;
|
||||||
@ -2915,9 +2914,9 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla
|
|||||||
// Make room for the old and the new compflags, concatenated with a / in
|
// Make room for the old and the new compflags, concatenated with a / in
|
||||||
// between. Processing it makes it shorter, but we don't know by how
|
// between. Processing it makes it shorter, but we don't know by how
|
||||||
// much, thus allocate the maximum.
|
// much, thus allocate the maximum.
|
||||||
len = (int)STRLEN(compflags) + 1;
|
len = (int)strlen(compflags) + 1;
|
||||||
if (spin->si_compflags != NULL) {
|
if (spin->si_compflags != NULL) {
|
||||||
len += (int)STRLEN(spin->si_compflags) + 1;
|
len += (int)strlen(spin->si_compflags) + 1;
|
||||||
}
|
}
|
||||||
p = getroom(spin, (size_t)len, false);
|
p = getroom(spin, (size_t)len, false);
|
||||||
if (spin->si_compflags != NULL) {
|
if (spin->si_compflags != NULL) {
|
||||||
@ -2925,20 +2924,20 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla
|
|||||||
STRCAT(p, "/");
|
STRCAT(p, "/");
|
||||||
}
|
}
|
||||||
spin->si_compflags = p;
|
spin->si_compflags = p;
|
||||||
tp = p + STRLEN(p);
|
tp = (char_u *)p + strlen(p);
|
||||||
|
|
||||||
for (p = compflags; *p != NUL;) {
|
for (p = compflags; *p != NUL;) {
|
||||||
if (vim_strchr("/?*+[]", *p) != NULL) {
|
if (vim_strchr("/?*+[]", *p) != NULL) {
|
||||||
// Copy non-flag characters directly.
|
// Copy non-flag characters directly.
|
||||||
*tp++ = *p++;
|
*tp++ = (char_u)(*p++);
|
||||||
} else {
|
} else {
|
||||||
// First get the flag number, also checks validity.
|
// First get the flag number, also checks validity.
|
||||||
prevp = p;
|
prevp = (char_u *)p;
|
||||||
flag = get_affitem(aff->af_flagtype, &p);
|
flag = get_affitem(aff->af_flagtype, (char_u **)&p);
|
||||||
if (flag != 0) {
|
if (flag != 0) {
|
||||||
// Find the flag in the hashtable. If it was used before, use
|
// Find the flag in the hashtable. If it was used before, use
|
||||||
// the existing ID. Otherwise add a new entry.
|
// the existing ID. Otherwise add a new entry.
|
||||||
STRLCPY(key, prevp, p - prevp + 1);
|
STRLCPY(key, prevp, (char_u *)p - prevp + 1);
|
||||||
hi = hash_find(&aff->af_comp, (char *)key);
|
hi = hash_find(&aff->af_comp, (char *)key);
|
||||||
if (!HASHITEM_EMPTY(hi)) {
|
if (!HASHITEM_EMPTY(hi)) {
|
||||||
id = HI2CI(hi)->ci_newID;
|
id = HI2CI(hi)->ci_newID;
|
||||||
@ -2953,7 +2952,7 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla
|
|||||||
id = spin->si_newcompID--;
|
id = spin->si_newcompID--;
|
||||||
} while (vim_strchr("/?*+[]\\-^", id) != NULL);
|
} while (vim_strchr("/?*+[]\\-^", id) != NULL);
|
||||||
ci->ci_newID = id;
|
ci->ci_newID = id;
|
||||||
hash_add(&aff->af_comp, ci->ci_key);
|
hash_add(&aff->af_comp, (char *)ci->ci_key);
|
||||||
}
|
}
|
||||||
*tp++ = (char_u)id;
|
*tp++ = (char_u)id;
|
||||||
}
|
}
|
||||||
@ -3050,17 +3049,17 @@ static bool str_equal(char *s1, char *s2)
|
|||||||
return strcmp(s1, s2) == 0;
|
return strcmp(s1, s2) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a from-to item to "gap". Used for REP and SAL items.
|
/// Add a from-to item to "gap". Used for REP and SAL items.
|
||||||
// They are stored case-folded.
|
/// They are stored case-folded.
|
||||||
static void add_fromto(spellinfo_T *spin, garray_T *gap, char_u *from, char_u *to)
|
static void add_fromto(spellinfo_T *spin, garray_T *gap, char *from, char *to)
|
||||||
{
|
{
|
||||||
char_u word[MAXWLEN];
|
char_u word[MAXWLEN];
|
||||||
|
|
||||||
fromto_T *ftp = GA_APPEND_VIA_PTR(fromto_T, gap);
|
fromto_T *ftp = GA_APPEND_VIA_PTR(fromto_T, gap);
|
||||||
(void)spell_casefold(curwin, from, (int)STRLEN(from), word, MAXWLEN);
|
(void)spell_casefold(curwin, (char_u *)from, (int)strlen(from), word, MAXWLEN);
|
||||||
ftp->ft_from = (char_u *)getroom_save(spin, word);
|
ftp->ft_from = (char_u *)getroom_save(spin, (char *)word);
|
||||||
(void)spell_casefold(curwin, to, (int)STRLEN(to), word, MAXWLEN);
|
(void)spell_casefold(curwin, (char_u *)to, (int)strlen(to), word, MAXWLEN);
|
||||||
ftp->ft_to = (char_u *)getroom_save(spin, word);
|
ftp->ft_to = (char_u *)getroom_save(spin, (char *)word);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a boolean argument in a SAL line to true or false;
|
/// Converts a boolean argument in a SAL line to true or false;
|
||||||
@ -3107,13 +3106,13 @@ static void spell_free_aff(afffile_T *aff)
|
|||||||
static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
||||||
{
|
{
|
||||||
hashtab_T ht;
|
hashtab_T ht;
|
||||||
char_u line[MAXLINELEN];
|
char line[MAXLINELEN];
|
||||||
char_u *p;
|
char_u *p;
|
||||||
char_u *afflist;
|
char_u *afflist;
|
||||||
char_u store_afflist[MAXWLEN];
|
char_u store_afflist[MAXWLEN];
|
||||||
int pfxlen;
|
int pfxlen;
|
||||||
bool need_affix;
|
bool need_affix;
|
||||||
char_u *dw;
|
char *dw;
|
||||||
char_u *pc;
|
char_u *pc;
|
||||||
char_u *w;
|
char_u *w;
|
||||||
int l;
|
int l;
|
||||||
@ -3161,7 +3160,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
|||||||
}
|
}
|
||||||
// Remove CR, LF and white space from the end. White space halfway through
|
// Remove CR, LF and white space from the end. White space halfway through
|
||||||
// the word is kept to allow multi-word terms like "et al.".
|
// the word is kept to allow multi-word terms like "et al.".
|
||||||
l = (int)STRLEN(line);
|
l = (int)strlen(line);
|
||||||
while (l > 0 && line[l - 1] <= ' ') {
|
while (l > 0 && line[l - 1] <= ' ') {
|
||||||
l--;
|
l--;
|
||||||
}
|
}
|
||||||
@ -3181,7 +3180,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
|||||||
w = pc;
|
w = pc;
|
||||||
} else {
|
} else {
|
||||||
pc = NULL;
|
pc = NULL;
|
||||||
w = line;
|
w = (char_u *)line;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate the word at the "/", set "afflist" to what follows.
|
// Truncate the word at the "/", set "afflist" to what follows.
|
||||||
@ -3189,7 +3188,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
|||||||
afflist = NULL;
|
afflist = NULL;
|
||||||
for (p = w; *p != NUL; MB_PTR_ADV(p)) {
|
for (p = w; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\\' && (p[1] == '\\' || p[1] == '/')) {
|
if (*p == '\\' && (p[1] == '\\' || p[1] == '/')) {
|
||||||
STRMOVE(p, p + 1);
|
STRMOVE(p, (char *)p + 1);
|
||||||
} else if (*p == '/') {
|
} else if (*p == '/') {
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
afflist = p + 1;
|
afflist = p + 1;
|
||||||
@ -3223,15 +3222,15 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store the word in the hashtable to be able to find duplicates.
|
// Store the word in the hashtable to be able to find duplicates.
|
||||||
dw = (char_u *)getroom_save(spin, w);
|
dw = getroom_save(spin, (char *)w);
|
||||||
if (dw == NULL) {
|
if (dw == NULL) {
|
||||||
retval = FAIL;
|
retval = FAIL;
|
||||||
xfree(pc);
|
xfree(pc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = hash_hash(dw);
|
hash = hash_hash((char_u *)dw);
|
||||||
hi = hash_lookup(&ht, (const char *)dw, STRLEN(dw), hash);
|
hi = hash_lookup(&ht, (const char *)dw, strlen(dw), hash);
|
||||||
if (!HASHITEM_EMPTY(hi)) {
|
if (!HASHITEM_EMPTY(hi)) {
|
||||||
if (p_verbose > 0) {
|
if (p_verbose > 0) {
|
||||||
smsg(_("Duplicate word in %s line %d: %s"),
|
smsg(_("Duplicate word in %s line %d: %s"),
|
||||||
@ -3242,7 +3241,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
|||||||
}
|
}
|
||||||
duplicate++;
|
duplicate++;
|
||||||
} else {
|
} else {
|
||||||
hash_add_item(&ht, hi, dw, hash);
|
hash_add_item(&ht, hi, (char_u *)dw, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
@ -3427,7 +3426,7 @@ static void get_compflags(afffile_T *affile, char_u *afflist, char_u *store_affl
|
|||||||
/// @param pfxlen nr of flags in "pfxlist" for prefixes, rest is compound flags
|
/// @param pfxlen nr of flags in "pfxlist" for prefixes, rest is compound flags
|
||||||
///
|
///
|
||||||
/// @return FAIL when out of memory.
|
/// @return FAIL when out of memory.
|
||||||
static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afffile_T *affile,
|
static int store_aff_word(spellinfo_T *spin, char *word, char_u *afflist, afffile_T *affile,
|
||||||
hashtab_T *ht, hashtab_T *xht, int condit, int flags, char_u *pfxlist,
|
hashtab_T *ht, hashtab_T *xht, int condit, int flags, char_u *pfxlist,
|
||||||
int pfxlen)
|
int pfxlen)
|
||||||
{
|
{
|
||||||
@ -3435,7 +3434,7 @@ static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afff
|
|||||||
hashitem_T *hi;
|
hashitem_T *hi;
|
||||||
affheader_T *ah;
|
affheader_T *ah;
|
||||||
affentry_T *ae;
|
affentry_T *ae;
|
||||||
char_u newword[MAXWLEN];
|
char newword[MAXWLEN];
|
||||||
int retval = OK;
|
int retval = OK;
|
||||||
int i, j;
|
int i, j;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
@ -3445,7 +3444,7 @@ static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afff
|
|||||||
bool need_affix;
|
bool need_affix;
|
||||||
char_u store_afflist[MAXWLEN];
|
char_u store_afflist[MAXWLEN];
|
||||||
char_u pfx_pfxlist[MAXWLEN];
|
char_u pfx_pfxlist[MAXWLEN];
|
||||||
size_t wordlen = STRLEN(word);
|
size_t wordlen = strlen(word);
|
||||||
int use_condit;
|
int use_condit;
|
||||||
|
|
||||||
todo = (int)ht->ht_used;
|
todo = (int)ht->ht_used;
|
||||||
@ -3475,9 +3474,9 @@ static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afff
|
|||||||
|| ae->ae_chop != NULL
|
|| ae->ae_chop != NULL
|
||||||
|| ae->ae_flags != NULL)
|
|| ae->ae_flags != NULL)
|
||||||
&& (ae->ae_chop == NULL
|
&& (ae->ae_chop == NULL
|
||||||
|| STRLEN(ae->ae_chop) < wordlen)
|
|| strlen(ae->ae_chop) < wordlen)
|
||||||
&& (ae->ae_prog == NULL
|
&& (ae->ae_prog == NULL
|
||||||
|| vim_regexec_prog(&ae->ae_prog, false, word, (colnr_T)0))
|
|| vim_regexec_prog(&ae->ae_prog, false, (char_u *)word, (colnr_T)0))
|
||||||
&& (((condit & CONDIT_CFIX) == 0)
|
&& (((condit & CONDIT_CFIX) == 0)
|
||||||
== ((condit & CONDIT_AFF) == 0
|
== ((condit & CONDIT_AFF) == 0
|
||||||
|| ae->ae_flags == NULL
|
|| ae->ae_flags == NULL
|
||||||
@ -3491,10 +3490,10 @@ static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afff
|
|||||||
} else {
|
} else {
|
||||||
STRLCPY(newword, ae->ae_add, MAXWLEN);
|
STRLCPY(newword, ae->ae_add, MAXWLEN);
|
||||||
}
|
}
|
||||||
p = word;
|
p = (char_u *)word;
|
||||||
if (ae->ae_chop != NULL) {
|
if (ae->ae_chop != NULL) {
|
||||||
// Skip chop string.
|
// Skip chop string.
|
||||||
i = mb_charlen(ae->ae_chop);
|
i = mb_charlen((char_u *)ae->ae_chop);
|
||||||
for (; i > 0; i--) {
|
for (; i > 0; i--) {
|
||||||
MB_PTR_ADV(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
@ -3505,8 +3504,8 @@ static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afff
|
|||||||
STRLCPY(newword, word, MAXWLEN);
|
STRLCPY(newword, word, MAXWLEN);
|
||||||
if (ae->ae_chop != NULL) {
|
if (ae->ae_chop != NULL) {
|
||||||
// Remove chop string.
|
// Remove chop string.
|
||||||
p = newword + STRLEN(newword);
|
p = (char_u *)newword + strlen(newword);
|
||||||
i = mb_charlen(ae->ae_chop);
|
i = mb_charlen((char_u *)ae->ae_chop);
|
||||||
for (; i > 0; i--) {
|
for (; i > 0; i--) {
|
||||||
MB_PTR_BACK(newword, p);
|
MB_PTR_BACK(newword, p);
|
||||||
}
|
}
|
||||||
@ -3674,8 +3673,8 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
|||||||
{
|
{
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
long lnum = 0;
|
long lnum = 0;
|
||||||
char_u rline[MAXLINELEN];
|
char rline[MAXLINELEN];
|
||||||
char_u *line;
|
char *line;
|
||||||
char_u *pc = NULL;
|
char_u *pc = NULL;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int l;
|
int l;
|
||||||
@ -3706,8 +3705,8 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove CR, LF and white space from the end.
|
// Remove CR, LF and white space from the end.
|
||||||
l = (int)STRLEN(rline);
|
l = (int)strlen(rline);
|
||||||
while (l > 0 && rline[l - 1] <= ' ') {
|
while (l > 0 && (uint8_t)rline[l - 1] <= ' ') {
|
||||||
l--;
|
l--;
|
||||||
}
|
}
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
@ -3718,13 +3717,13 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
|||||||
// Convert from "/encoding={encoding}" to 'encoding' when needed.
|
// Convert from "/encoding={encoding}" to 'encoding' when needed.
|
||||||
xfree(pc);
|
xfree(pc);
|
||||||
if (spin->si_conv.vc_type != CONV_NONE) {
|
if (spin->si_conv.vc_type != CONV_NONE) {
|
||||||
pc = (char_u *)string_convert(&spin->si_conv, (char *)rline, NULL);
|
pc = (char_u *)string_convert(&spin->si_conv, rline, NULL);
|
||||||
if (pc == NULL) {
|
if (pc == NULL) {
|
||||||
smsg(_("Conversion failure for word in %s line %ld: %s"),
|
smsg(_("Conversion failure for word in %s line %ld: %s"),
|
||||||
fname, lnum, rline);
|
fname, lnum, rline);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
line = pc;
|
line = (char *)pc;
|
||||||
} else {
|
} else {
|
||||||
pc = NULL;
|
pc = NULL;
|
||||||
line = rline;
|
line = rline;
|
||||||
@ -3744,7 +3743,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
|||||||
|
|
||||||
// Setup for conversion to 'encoding'.
|
// Setup for conversion to 'encoding'.
|
||||||
line += 9;
|
line += 9;
|
||||||
enc = enc_canonize((char *)line);
|
enc = enc_canonize(line);
|
||||||
if (!spin->si_ascii
|
if (!spin->si_ascii
|
||||||
&& convert_setup(&spin->si_conv, enc, p_enc) == FAIL) {
|
&& convert_setup(&spin->si_conv, enc, p_enc) == FAIL) {
|
||||||
smsg(_("Conversion in %s not supported: from %s to %s"),
|
smsg(_("Conversion in %s not supported: from %s to %s"),
|
||||||
@ -3762,11 +3761,11 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
|||||||
fname, lnum, line);
|
fname, lnum, line);
|
||||||
} else {
|
} else {
|
||||||
line += 8;
|
line += 8;
|
||||||
if (STRLEN(line) > MAXREGIONS * 2) {
|
if (strlen(line) > MAXREGIONS * 2) {
|
||||||
smsg(_("Too many regions in %s line %ld: %s"),
|
smsg(_("Too many regions in %s line %ld: %s"),
|
||||||
fname, lnum, line);
|
fname, lnum, line);
|
||||||
} else {
|
} else {
|
||||||
spin->si_region_count = (int)STRLEN(line) / 2;
|
spin->si_region_count = (int)strlen(line) / 2;
|
||||||
STRCPY(spin->si_region_name, line);
|
STRCPY(spin->si_region_name, line);
|
||||||
|
|
||||||
// Adjust the mask for a word valid in all regions.
|
// Adjust the mask for a word valid in all regions.
|
||||||
@ -3785,7 +3784,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
|||||||
regionmask = spin->si_region;
|
regionmask = spin->si_region;
|
||||||
|
|
||||||
// Check for flags and region after a slash.
|
// Check for flags and region after a slash.
|
||||||
p = (char_u *)vim_strchr((char *)line, '/');
|
p = (char_u *)vim_strchr(line, '/');
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
*p++ = NUL;
|
*p++ = NUL;
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
@ -3818,7 +3817,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip non-ASCII words when "spin->si_ascii" is true.
|
// Skip non-ASCII words when "spin->si_ascii" is true.
|
||||||
if (spin->si_ascii && has_non_ascii(line)) {
|
if (spin->si_ascii && has_non_ascii((char_u *)line)) {
|
||||||
non_ascii++;
|
non_ascii++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3883,9 +3882,9 @@ static void *getroom(spellinfo_T *spin, size_t len, bool align)
|
|||||||
/// Make a copy of a string into memory allocated with getroom().
|
/// Make a copy of a string into memory allocated with getroom().
|
||||||
///
|
///
|
||||||
/// @return NULL when out of memory.
|
/// @return NULL when out of memory.
|
||||||
static char *getroom_save(spellinfo_T *spin, char_u *s)
|
static char *getroom_save(spellinfo_T *spin, char *s)
|
||||||
{
|
{
|
||||||
const size_t s_size = STRLEN(s) + 1;
|
const size_t s_size = strlen(s) + 1;
|
||||||
return memcpy(getroom(spin, s_size, false), s, s_size);
|
return memcpy(getroom(spin, s_size, false), s, s_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3936,20 +3935,20 @@ static bool valid_spell_word(const char *word, const char *end)
|
|||||||
/// @param region supported region(s)
|
/// @param region supported region(s)
|
||||||
/// @param pfxlist list of prefix ids or null
|
/// @param pfxlist list of prefix ids or null
|
||||||
/// @param need_affix only store word with affix id
|
/// @param need_affix only store word with affix id
|
||||||
static int store_word(spellinfo_T *spin, char_u *word, int flags, int region, const char_u *pfxlist,
|
static int store_word(spellinfo_T *spin, char *word, int flags, int region, const char_u *pfxlist,
|
||||||
bool need_affix)
|
bool need_affix)
|
||||||
{
|
{
|
||||||
int len = (int)STRLEN(word);
|
int len = (int)strlen(word);
|
||||||
int ct = captype(word, word + len);
|
int ct = captype((char_u *)word, (char_u *)word + len);
|
||||||
char_u foldword[MAXWLEN];
|
char_u foldword[MAXWLEN];
|
||||||
int res = OK;
|
int res = OK;
|
||||||
|
|
||||||
// Avoid adding illegal bytes to the word tree.
|
// Avoid adding illegal bytes to the word tree.
|
||||||
if (!valid_spell_word((char *)word, (char *)word + len)) {
|
if (!valid_spell_word(word, word + len)) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
|
(void)spell_casefold(curwin, (char_u *)word, len, foldword, MAXWLEN);
|
||||||
for (const char_u *p = pfxlist; res == OK; p++) {
|
for (const char_u *p = pfxlist; res == OK; p++) {
|
||||||
if (!need_affix || (p != NULL && *p != NUL)) {
|
if (!need_affix || (p != NULL && *p != NUL)) {
|
||||||
res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
|
res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
|
||||||
@ -3964,7 +3963,7 @@ static int store_word(spellinfo_T *spin, char_u *word, int flags, int region, co
|
|||||||
if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP))) {
|
if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP))) {
|
||||||
for (const char_u *p = pfxlist; res == OK; p++) {
|
for (const char_u *p = pfxlist; res == OK; p++) {
|
||||||
if (!need_affix || (p != NULL && *p != NUL)) {
|
if (!need_affix || (p != NULL && *p != NUL)) {
|
||||||
res = tree_add_word(spin, word, spin->si_keeproot, flags,
|
res = tree_add_word(spin, (char_u *)word, spin->si_keeproot, flags,
|
||||||
region, p == NULL ? 0 : *p);
|
region, p == NULL ? 0 : *p);
|
||||||
}
|
}
|
||||||
if (p == NULL || *p == NUL) {
|
if (p == NULL || *p == NUL) {
|
||||||
@ -4268,7 +4267,7 @@ static long node_compress(spellinfo_T *spin, wordnode_T *node, hashtab_T *ht, lo
|
|||||||
// Try to find an identical child.
|
// Try to find an identical child.
|
||||||
hash = hash_hash(child->wn_u1.hashkey);
|
hash = hash_hash(child->wn_u1.hashkey);
|
||||||
hi = hash_lookup(ht, (const char *)child->wn_u1.hashkey,
|
hi = hash_lookup(ht, (const char *)child->wn_u1.hashkey,
|
||||||
STRLEN(child->wn_u1.hashkey), hash);
|
strlen((char *)child->wn_u1.hashkey), hash);
|
||||||
if (!HASHITEM_EMPTY(hi)) {
|
if (!HASHITEM_EMPTY(hi)) {
|
||||||
// There are children we encountered before with a hash value
|
// There are children we encountered before with a hash value
|
||||||
// identical to the current child. Now check if there is one
|
// identical to the current child. Now check if there is one
|
||||||
@ -4394,7 +4393,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
if (spin->si_info != NULL) {
|
if (spin->si_info != NULL) {
|
||||||
putc(SN_INFO, fd); // <sectionID>
|
putc(SN_INFO, fd); // <sectionID>
|
||||||
putc(0, fd); // <sectionflags>
|
putc(0, fd); // <sectionflags>
|
||||||
size_t i = STRLEN(spin->si_info);
|
size_t i = strlen(spin->si_info);
|
||||||
put_bytes(fd, i, 4); // <sectionlen>
|
put_bytes(fd, i, 4); // <sectionlen>
|
||||||
fwv &= fwrite(spin->si_info, i, 1, fd); // <infotext>
|
fwv &= fwrite(spin->si_info, i, 1, fd); // <infotext>
|
||||||
}
|
}
|
||||||
@ -4457,7 +4456,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
putc(SN_MIDWORD, fd); // <sectionID>
|
putc(SN_MIDWORD, fd); // <sectionID>
|
||||||
putc(SNF_REQUIRED, fd); // <sectionflags>
|
putc(SNF_REQUIRED, fd); // <sectionflags>
|
||||||
|
|
||||||
size_t i = STRLEN(spin->si_midword);
|
size_t i = strlen(spin->si_midword);
|
||||||
put_bytes(fd, i, 4); // <sectionlen>
|
put_bytes(fd, i, 4); // <sectionlen>
|
||||||
fwv &= fwrite(spin->si_midword, i, 1, fd);
|
fwv &= fwrite(spin->si_midword, i, 1, fd);
|
||||||
// <midword>
|
// <midword>
|
||||||
@ -4517,8 +4516,8 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
assert(gap->ga_len >= 0);
|
assert(gap->ga_len >= 0);
|
||||||
for (size_t i = 0; i < (size_t)gap->ga_len; i++) {
|
for (size_t i = 0; i < (size_t)gap->ga_len; i++) {
|
||||||
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
|
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
|
||||||
l += 1 + STRLEN(ftp->ft_from); // count <*fromlen> and <*from>
|
l += 1 + strlen((char *)ftp->ft_from); // count <*fromlen> and <*from>
|
||||||
l += 1 + STRLEN(ftp->ft_to); // count <*tolen> and <*to>
|
l += 1 + strlen((char *)ftp->ft_to); // count <*tolen> and <*to>
|
||||||
}
|
}
|
||||||
if (round == 2) {
|
if (round == 2) {
|
||||||
l++; // count <salflags>
|
l++; // count <salflags>
|
||||||
@ -4545,8 +4544,8 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
// <sal> : <salfromlen> <salfrom> <saltolen> <salto>
|
// <sal> : <salfromlen> <salfrom> <saltolen> <salto>
|
||||||
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
|
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
|
||||||
for (unsigned int rr = 1; rr <= 2; rr++) {
|
for (unsigned int rr = 1; rr <= 2; rr++) {
|
||||||
char_u *p = rr == 1 ? ftp->ft_from : ftp->ft_to;
|
char *p = rr == 1 ? (char *)ftp->ft_from : (char *)ftp->ft_to;
|
||||||
l = STRLEN(p);
|
l = strlen(p);
|
||||||
assert(l < INT_MAX);
|
assert(l < INT_MAX);
|
||||||
putc((int)l, fd);
|
putc((int)l, fd);
|
||||||
if (l > 0) {
|
if (l > 0) {
|
||||||
@ -4562,13 +4561,13 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
putc(SN_SOFO, fd); // <sectionID>
|
putc(SN_SOFO, fd); // <sectionID>
|
||||||
putc(0, fd); // <sectionflags>
|
putc(0, fd); // <sectionflags>
|
||||||
|
|
||||||
size_t l = STRLEN(spin->si_sofofr);
|
size_t l = strlen(spin->si_sofofr);
|
||||||
put_bytes(fd, l + STRLEN(spin->si_sofoto) + 4, 4); // <sectionlen>
|
put_bytes(fd, l + strlen(spin->si_sofoto) + 4, 4); // <sectionlen>
|
||||||
|
|
||||||
put_bytes(fd, l, 2); // <sofofromlen>
|
put_bytes(fd, l, 2); // <sofofromlen>
|
||||||
fwv &= fwrite(spin->si_sofofr, l, 1, fd); // <sofofrom>
|
fwv &= fwrite(spin->si_sofofr, l, 1, fd); // <sofofrom>
|
||||||
|
|
||||||
l = STRLEN(spin->si_sofoto);
|
l = strlen(spin->si_sofoto);
|
||||||
put_bytes(fd, l, 2); // <sofotolen>
|
put_bytes(fd, l, 2); // <sofotolen>
|
||||||
fwv &= fwrite(spin->si_sofoto, l, 1, fd); // <sofoto>
|
fwv &= fwrite(spin->si_sofoto, l, 1, fd); // <sofoto>
|
||||||
}
|
}
|
||||||
@ -4589,7 +4588,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
todo = spin->si_commonwords.ht_used;
|
todo = spin->si_commonwords.ht_used;
|
||||||
for (hi = spin->si_commonwords.ht_array; todo > 0; hi++) {
|
for (hi = spin->si_commonwords.ht_array; todo > 0; hi++) {
|
||||||
if (!HASHITEM_EMPTY(hi)) {
|
if (!HASHITEM_EMPTY(hi)) {
|
||||||
size_t l = STRLEN(hi->hi_key) + 1;
|
size_t l = strlen(hi->hi_key) + 1;
|
||||||
len += l;
|
len += l;
|
||||||
if (round == 2) { // <word>
|
if (round == 2) { // <word>
|
||||||
fwv &= fwrite(hi->hi_key, l, 1, fd);
|
fwv &= fwrite(hi->hi_key, l, 1, fd);
|
||||||
@ -4655,7 +4654,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
putc(SN_COMPOUND, fd); // <sectionID>
|
putc(SN_COMPOUND, fd); // <sectionID>
|
||||||
putc(0, fd); // <sectionflags>
|
putc(0, fd); // <sectionflags>
|
||||||
|
|
||||||
size_t l = STRLEN(spin->si_compflags);
|
size_t l = strlen(spin->si_compflags);
|
||||||
assert(spin->si_comppat.ga_len >= 0);
|
assert(spin->si_comppat.ga_len >= 0);
|
||||||
for (size_t i = 0; i < (size_t)spin->si_comppat.ga_len; i++) {
|
for (size_t i = 0; i < (size_t)spin->si_comppat.ga_len; i++) {
|
||||||
l += strlen(((char **)(spin->si_comppat.ga_data))[i]) + 1;
|
l += strlen(((char **)(spin->si_comppat.ga_data))[i]) + 1;
|
||||||
@ -4675,7 +4674,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
fwv &= fwrite(p, strlen(p), 1, fd); // <comppattext>
|
fwv &= fwrite(p, strlen(p), 1, fd); // <comppattext>
|
||||||
}
|
}
|
||||||
// <compflags>
|
// <compflags>
|
||||||
fwv &= fwrite(spin->si_compflags, STRLEN(spin->si_compflags), 1, fd);
|
fwv &= fwrite(spin->si_compflags, strlen(spin->si_compflags), 1, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SN_NOBREAK: NOBREAK flag
|
// SN_NOBREAK: NOBREAK flag
|
||||||
@ -4694,7 +4693,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
|
|||||||
putc(SN_SYLLABLE, fd); // <sectionID>
|
putc(SN_SYLLABLE, fd); // <sectionID>
|
||||||
putc(0, fd); // <sectionflags>
|
putc(0, fd); // <sectionflags>
|
||||||
|
|
||||||
size_t l = STRLEN(spin->si_syllable);
|
size_t l = strlen(spin->si_syllable);
|
||||||
put_bytes(fd, l, 4); // <sectionlen>
|
put_bytes(fd, l, 4); // <sectionlen>
|
||||||
fwv &= fwrite(spin->si_syllable, l, 1, fd); // <syllable>
|
fwv &= fwrite(spin->si_syllable, l, 1, fd); // <syllable>
|
||||||
}
|
}
|
||||||
@ -4913,7 +4912,7 @@ void ex_mkspell(exarg_T *eap)
|
|||||||
// Writes the file with the name "wfname", with ".spl" changed to ".sug".
|
// Writes the file with the name "wfname", with ".spl" changed to ".sug".
|
||||||
static void spell_make_sugfile(spellinfo_T *spin, char *wfname)
|
static void spell_make_sugfile(spellinfo_T *spin, char *wfname)
|
||||||
{
|
{
|
||||||
char_u *fname = NULL;
|
char *fname = NULL;
|
||||||
int len;
|
int len;
|
||||||
slang_T *slang;
|
slang_T *slang;
|
||||||
bool free_slang = false;
|
bool free_slang = false;
|
||||||
@ -4972,10 +4971,10 @@ static void spell_make_sugfile(spellinfo_T *spin, char *wfname)
|
|||||||
// Make the file name by changing ".spl" to ".sug".
|
// Make the file name by changing ".spl" to ".sug".
|
||||||
fname = xmalloc(MAXPATHL);
|
fname = xmalloc(MAXPATHL);
|
||||||
STRLCPY(fname, wfname, MAXPATHL);
|
STRLCPY(fname, wfname, MAXPATHL);
|
||||||
len = (int)STRLEN(fname);
|
len = (int)strlen(fname);
|
||||||
fname[len - 2] = 'u';
|
fname[len - 2] = 'u';
|
||||||
fname[len - 1] = 'g';
|
fname[len - 1] = 'g';
|
||||||
sug_write(spin, fname);
|
sug_write(spin, (char_u *)fname);
|
||||||
|
|
||||||
theend:
|
theend:
|
||||||
xfree(fname);
|
xfree(fname);
|
||||||
@ -5036,7 +5035,7 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang)
|
|||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
// Sound-fold the word.
|
// Sound-fold the word.
|
||||||
tword[depth] = NUL;
|
tword[depth] = NUL;
|
||||||
spell_soundfold(slang, tword, true, tsalword);
|
spell_soundfold(slang, (char *)tword, true, (char *)tsalword);
|
||||||
|
|
||||||
// We use the "flags" field for the MSB of the wordnr,
|
// We use the "flags" field for the MSB of the wordnr,
|
||||||
// "region" for the LSB of the wordnr.
|
// "region" for the LSB of the wordnr.
|
||||||
@ -5250,8 +5249,8 @@ static void sug_write(spellinfo_T *spin, char_u *fname)
|
|||||||
|
|
||||||
for (linenr_T lnum = 1; lnum <= wcount; lnum++) {
|
for (linenr_T lnum = 1; lnum <= wcount; lnum++) {
|
||||||
// <sugline>: <sugnr> ... NUL
|
// <sugline>: <sugnr> ... NUL
|
||||||
char_u *line = (char_u *)ml_get_buf(spin->si_spellbuf, lnum, false);
|
char *line = ml_get_buf(spin->si_spellbuf, lnum, false);
|
||||||
size_t len = STRLEN(line) + 1;
|
size_t len = strlen(line) + 1;
|
||||||
if (fwrite(line, len, 1, fd) == 0) {
|
if (fwrite(line, len, 1, fd) == 0) {
|
||||||
emsg(_(e_write));
|
emsg(_(e_write));
|
||||||
goto theend;
|
goto theend;
|
||||||
@ -5316,7 +5315,7 @@ static void mkspell(int fcount, char **fnames, bool ascii, bool over_write, bool
|
|||||||
char *wfname = xmalloc(MAXPATHL);
|
char *wfname = xmalloc(MAXPATHL);
|
||||||
|
|
||||||
if (fcount >= 1) {
|
if (fcount >= 1) {
|
||||||
len = (int)STRLEN(fnames[0]);
|
len = (int)strlen(fnames[0]);
|
||||||
if (fcount == 1 && len > 4 && strcmp(fnames[0] + len - 4, ".add") == 0) {
|
if (fcount == 1 && len > 4 && strcmp(fnames[0] + len - 4, ".add") == 0) {
|
||||||
// For ":mkspell path/en.latin1.add" output file is
|
// For ":mkspell path/en.latin1.add" output file is
|
||||||
// "path/en.latin1.add.spl".
|
// "path/en.latin1.add.spl".
|
||||||
@ -5689,7 +5688,7 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo
|
|||||||
// Initialize 'spellfile' for the current buffer.
|
// Initialize 'spellfile' for the current buffer.
|
||||||
static void init_spellfile(void)
|
static void init_spellfile(void)
|
||||||
{
|
{
|
||||||
char_u *buf;
|
char *buf;
|
||||||
int l;
|
int l;
|
||||||
char_u *fname;
|
char_u *fname;
|
||||||
char_u *rtp;
|
char_u *rtp;
|
||||||
@ -5720,29 +5719,29 @@ static void init_spellfile(void)
|
|||||||
STRLCPY(buf, curbuf->b_s.b_p_spl, lstart - (char_u *)curbuf->b_s.b_p_spl);
|
STRLCPY(buf, curbuf->b_s.b_p_spl, lstart - (char_u *)curbuf->b_s.b_p_spl);
|
||||||
} else {
|
} else {
|
||||||
// Copy the path from 'runtimepath' to buf[].
|
// Copy the path from 'runtimepath' to buf[].
|
||||||
copy_option_part((char **)&rtp, (char *)buf, MAXPATHL, ",");
|
copy_option_part((char **)&rtp, buf, MAXPATHL, ",");
|
||||||
}
|
}
|
||||||
if (os_file_is_writable((char *)buf) == 2) {
|
if (os_file_is_writable(buf) == 2) {
|
||||||
// Use the first language name from 'spelllang' and the
|
// Use the first language name from 'spelllang' and the
|
||||||
// encoding used in the first loaded .spl file.
|
// encoding used in the first loaded .spl file.
|
||||||
if (aspath) {
|
if (aspath) {
|
||||||
STRLCPY(buf, curbuf->b_s.b_p_spl, lend - (char_u *)curbuf->b_s.b_p_spl + 1);
|
STRLCPY(buf, curbuf->b_s.b_p_spl, lend - (char_u *)curbuf->b_s.b_p_spl + 1);
|
||||||
} else {
|
} else {
|
||||||
// Create the "spell" directory if it doesn't exist yet.
|
// Create the "spell" directory if it doesn't exist yet.
|
||||||
l = (int)STRLEN(buf);
|
l = (int)strlen(buf);
|
||||||
vim_snprintf((char *)buf + l, MAXPATHL - (size_t)l, "/spell");
|
vim_snprintf(buf + l, MAXPATHL - (size_t)l, "/spell");
|
||||||
if (os_file_is_writable((char *)buf) != 2) {
|
if (os_file_is_writable(buf) != 2) {
|
||||||
os_mkdir((char *)buf, 0755);
|
os_mkdir(buf, 0755);
|
||||||
}
|
}
|
||||||
|
|
||||||
l = (int)STRLEN(buf);
|
l = (int)strlen(buf);
|
||||||
vim_snprintf((char *)buf + l, MAXPATHL - (size_t)l,
|
vim_snprintf(buf + l, MAXPATHL - (size_t)l,
|
||||||
"/%.*s", (int)(lend - lstart), lstart);
|
"/%.*s", (int)(lend - lstart), lstart);
|
||||||
}
|
}
|
||||||
l = (int)STRLEN(buf);
|
l = (int)strlen(buf);
|
||||||
fname = (char_u *)LANGP_ENTRY(curwin->w_s->b_langp, 0)
|
fname = (char_u *)LANGP_ENTRY(curwin->w_s->b_langp, 0)
|
||||||
->lp_slang->sl_fname;
|
->lp_slang->sl_fname;
|
||||||
vim_snprintf((char *)buf + l, MAXPATHL - (size_t)l, ".%s.add",
|
vim_snprintf(buf + l, MAXPATHL - (size_t)l, ".%s.add",
|
||||||
((fname != NULL
|
((fname != NULL
|
||||||
&& strstr(path_tail((char *)fname), ".ascii.") != NULL)
|
&& strstr(path_tail((char *)fname), ".ascii.") != NULL)
|
||||||
? "ascii"
|
? "ascii"
|
||||||
|
@ -71,7 +71,7 @@ typedef struct suginfo_S {
|
|||||||
int su_maxscore; ///< maximum score for adding to su_ga
|
int su_maxscore; ///< maximum score for adding to su_ga
|
||||||
int su_sfmaxscore; ///< idem, for when doing soundfold words
|
int su_sfmaxscore; ///< idem, for when doing soundfold words
|
||||||
garray_T su_sga; ///< like su_ga, sound-folded scoring
|
garray_T su_sga; ///< like su_ga, sound-folded scoring
|
||||||
char_u *su_badptr; ///< start of bad word in line
|
char *su_badptr; ///< start of bad word in line
|
||||||
int su_badlen; ///< length of detected bad word in line
|
int su_badlen; ///< length of detected bad word in line
|
||||||
int su_badflags; ///< caps flags for bad word
|
int su_badflags; ///< caps flags for bad word
|
||||||
char_u su_badword[MAXWLEN]; ///< bad word truncated at su_badlen
|
char_u su_badword[MAXWLEN]; ///< bad word truncated at su_badlen
|
||||||
@ -629,20 +629,20 @@ void spell_suggest(int count)
|
|||||||
if (sug.su_badlen > stp->st_orglen) {
|
if (sug.su_badlen > stp->st_orglen) {
|
||||||
// Replacing less than "su_badlen", append the remainder to
|
// Replacing less than "su_badlen", append the remainder to
|
||||||
// repl_to.
|
// repl_to.
|
||||||
repl_from = xstrnsave((char *)sug.su_badptr, (size_t)sug.su_badlen);
|
repl_from = xstrnsave(sug.su_badptr, (size_t)sug.su_badlen);
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, "%s%.*s", stp->st_word,
|
vim_snprintf((char *)IObuff, IOSIZE, "%s%.*s", stp->st_word,
|
||||||
sug.su_badlen - stp->st_orglen,
|
sug.su_badlen - stp->st_orglen,
|
||||||
sug.su_badptr + stp->st_orglen);
|
sug.su_badptr + stp->st_orglen);
|
||||||
repl_to = xstrdup((char *)IObuff);
|
repl_to = xstrdup((char *)IObuff);
|
||||||
} else {
|
} else {
|
||||||
// Replacing su_badlen or more, use the whole word.
|
// Replacing su_badlen or more, use the whole word.
|
||||||
repl_from = xstrnsave((char *)sug.su_badptr, (size_t)stp->st_orglen);
|
repl_from = xstrnsave(sug.su_badptr, (size_t)stp->st_orglen);
|
||||||
repl_to = xstrdup(stp->st_word);
|
repl_to = xstrdup(stp->st_word);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the word.
|
// Replace the word.
|
||||||
p = xmalloc(strlen(line) - (size_t)stp->st_orglen + (size_t)stp->st_wordlen + 1);
|
p = xmalloc(strlen(line) - (size_t)stp->st_orglen + (size_t)stp->st_wordlen + 1);
|
||||||
c = (int)(sug.su_badptr - (char_u *)line);
|
c = (int)(sug.su_badptr - line);
|
||||||
memmove(p, line, (size_t)c);
|
memmove(p, line, (size_t)c);
|
||||||
STRCPY(p + c, stp->st_word);
|
STRCPY(p + c, stp->st_word);
|
||||||
STRCAT(p, sug.su_badptr + stp->st_orglen);
|
STRCAT(p, sug.su_badptr + stp->st_orglen);
|
||||||
@ -689,7 +689,7 @@ void spell_suggest_list(garray_T *gap, char_u *word, int maxcount, bool need_cap
|
|||||||
|
|
||||||
// The suggested word may replace only part of "word", add the not
|
// The suggested word may replace only part of "word", add the not
|
||||||
// replaced part.
|
// replaced part.
|
||||||
wcopy = xmalloc((size_t)stp->st_wordlen + STRLEN(sug.su_badptr + stp->st_orglen) + 1);
|
wcopy = xmalloc((size_t)stp->st_wordlen + strlen(sug.su_badptr + stp->st_orglen) + 1);
|
||||||
STRCPY(wcopy, stp->st_word);
|
STRCPY(wcopy, stp->st_word);
|
||||||
STRCPY(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen);
|
STRCPY(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen);
|
||||||
((char_u **)gap->ga_data)[gap->ga_len++] = wcopy;
|
((char_u **)gap->ga_data)[gap->ga_len++] = wcopy;
|
||||||
@ -729,11 +729,11 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
|||||||
}
|
}
|
||||||
hash_init(&su->su_banned);
|
hash_init(&su->su_banned);
|
||||||
|
|
||||||
su->su_badptr = badptr;
|
su->su_badptr = (char *)badptr;
|
||||||
if (badlen != 0) {
|
if (badlen != 0) {
|
||||||
su->su_badlen = badlen;
|
su->su_badlen = badlen;
|
||||||
} else {
|
} else {
|
||||||
size_t tmplen = spell_check(curwin, su->su_badptr, &attr, NULL, false);
|
size_t tmplen = spell_check(curwin, (char_u *)su->su_badptr, &attr, NULL, false);
|
||||||
assert(tmplen <= INT_MAX);
|
assert(tmplen <= INT_MAX);
|
||||||
su->su_badlen = (int)tmplen;
|
su->su_badlen = (int)tmplen;
|
||||||
}
|
}
|
||||||
@ -744,7 +744,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
|||||||
su->su_badlen = MAXWLEN - 1; // just in case
|
su->su_badlen = MAXWLEN - 1; // just in case
|
||||||
}
|
}
|
||||||
STRLCPY(su->su_badword, su->su_badptr, su->su_badlen + 1);
|
STRLCPY(su->su_badword, su->su_badptr, su->su_badlen + 1);
|
||||||
(void)spell_casefold(curwin, su->su_badptr, su->su_badlen, su->su_fbadword,
|
(void)spell_casefold(curwin, (char_u *)su->su_badptr, su->su_badlen, su->su_fbadword,
|
||||||
MAXWLEN);
|
MAXWLEN);
|
||||||
|
|
||||||
// TODO(vim): make this work if the case-folded text is longer than the
|
// TODO(vim): make this work if the case-folded text is longer than the
|
||||||
@ -753,8 +753,8 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
|||||||
su->su_fbadword[su->su_badlen] = NUL;
|
su->su_fbadword[su->su_badlen] = NUL;
|
||||||
|
|
||||||
// get caps flags for bad word
|
// get caps flags for bad word
|
||||||
su->su_badflags = badword_captype(su->su_badptr,
|
su->su_badflags = badword_captype((char_u *)su->su_badptr,
|
||||||
su->su_badptr + su->su_badlen);
|
(char_u *)su->su_badptr + su->su_badlen);
|
||||||
if (need_cap) {
|
if (need_cap) {
|
||||||
su->su_badflags |= WF_ONECAP;
|
su->su_badflags |= WF_ONECAP;
|
||||||
}
|
}
|
||||||
@ -774,14 +774,14 @@ 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
|
// Soundfold the bad word with the default sound folding, so that we don't
|
||||||
// have to do this many times.
|
// have to do this many times.
|
||||||
if (su->su_sallang != NULL) {
|
if (su->su_sallang != NULL) {
|
||||||
spell_soundfold(su->su_sallang, su->su_fbadword, true,
|
spell_soundfold(su->su_sallang, (char *)su->su_fbadword, true,
|
||||||
su->su_sal_badword);
|
(char *)su->su_sal_badword);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the word is not capitalised and spell_check() doesn't consider the
|
// If the word is not capitalised and spell_check() doesn't consider the
|
||||||
// word to be bad then it might need to be capitalised. Add a suggestion
|
// word to be bad then it might need to be capitalised. Add a suggestion
|
||||||
// for that.
|
// for that.
|
||||||
c = utf_ptr2char((char *)su->su_badptr);
|
c = utf_ptr2char(su->su_badptr);
|
||||||
if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) {
|
if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) {
|
||||||
make_case_word(su->su_badword, buf, WF_ONECAP);
|
make_case_word(su->su_badword, buf, WF_ONECAP);
|
||||||
add_suggestion(su, &su->su_ga, (char *)buf, su->su_badlen, SCORE_ICASE,
|
add_suggestion(su, &su->su_ga, (char *)buf, su->su_badlen, SCORE_ICASE,
|
||||||
@ -790,7 +790,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
|||||||
|
|
||||||
// Ban the bad word itself. It may appear in another region.
|
// Ban the bad word itself. It may appear in another region.
|
||||||
if (banbadword) {
|
if (banbadword) {
|
||||||
add_banned(su, su->su_badword);
|
add_banned(su, (char *)su->su_badword);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a copy of 'spellsuggest', because the expression may change it.
|
// Make a copy of 'spellsuggest', because the expression may change it.
|
||||||
@ -1008,10 +1008,10 @@ static void suggest_try_special(suginfo_T *su)
|
|||||||
char_u word[MAXWLEN];
|
char_u word[MAXWLEN];
|
||||||
|
|
||||||
// Recognize a word that is repeated: "the the".
|
// Recognize a word that is repeated: "the the".
|
||||||
char_u *p = (char_u *)skiptowhite((char *)su->su_fbadword);
|
char *p = skiptowhite((char *)su->su_fbadword);
|
||||||
size_t len = (size_t)(p - su->su_fbadword);
|
size_t len = (size_t)(p - (char *)su->su_fbadword);
|
||||||
p = (char_u *)skipwhite((char *)p);
|
p = skipwhite(p);
|
||||||
if (STRLEN(p) == len && STRNCMP(su->su_fbadword, p, len) == 0) {
|
if (strlen(p) == len && STRNCMP(su->su_fbadword, p, len) == 0) {
|
||||||
// Include badflags: if the badword is onecap or allcap
|
// Include badflags: if the badword is onecap or allcap
|
||||||
// use that for the goodword too: "The the" -> "The".
|
// use that for the goodword too: "The the" -> "The".
|
||||||
c = su->su_fbadword[len];
|
c = su->su_fbadword[len];
|
||||||
@ -1074,21 +1074,21 @@ static void prof_report(char *name)
|
|||||||
/// Try finding suggestions by adding/removing/swapping letters.
|
/// Try finding suggestions by adding/removing/swapping letters.
|
||||||
static void suggest_try_change(suginfo_T *su)
|
static void suggest_try_change(suginfo_T *su)
|
||||||
{
|
{
|
||||||
char_u fword[MAXWLEN]; // copy of the bad word, case-folded
|
char fword[MAXWLEN]; // copy of the bad word, case-folded
|
||||||
int n;
|
int n;
|
||||||
char_u *p;
|
char *p;
|
||||||
langp_T *lp;
|
langp_T *lp;
|
||||||
|
|
||||||
// We make a copy of the case-folded bad word, so that we can modify it
|
// We make a copy of the case-folded bad word, so that we can modify it
|
||||||
// to find matches (esp. REP items). Append some more text, changing
|
// to find matches (esp. REP items). Append some more text, changing
|
||||||
// chars after the bad word may help.
|
// chars after the bad word may help.
|
||||||
STRCPY(fword, su->su_fbadword);
|
STRCPY(fword, su->su_fbadword);
|
||||||
n = (int)STRLEN(fword);
|
n = (int)strlen(fword);
|
||||||
p = su->su_badptr + su->su_badlen;
|
p = su->su_badptr + su->su_badlen;
|
||||||
(void)spell_casefold(curwin, p, (int)STRLEN(p), fword + n, MAXWLEN - n);
|
(void)spell_casefold(curwin, (char_u *)p, (int)strlen(p), (char_u *)fword + n, MAXWLEN - n);
|
||||||
|
|
||||||
// Make sure the resulting text is not longer than the original text.
|
// Make sure the resulting text is not longer than the original text.
|
||||||
n = (int)STRLEN(su->su_badptr);
|
n = (int)strlen(su->su_badptr);
|
||||||
if (n < MAXWLEN) {
|
if (n < MAXWLEN) {
|
||||||
fword[n] = NUL;
|
fword[n] = NUL;
|
||||||
}
|
}
|
||||||
@ -1106,7 +1106,7 @@ static void suggest_try_change(suginfo_T *su)
|
|||||||
#ifdef SUGGEST_PROFILE
|
#ifdef SUGGEST_PROFILE
|
||||||
prof_init();
|
prof_init();
|
||||||
#endif
|
#endif
|
||||||
suggest_trie_walk(su, lp, fword, false);
|
suggest_trie_walk(su, lp, (char_u *)fword, false);
|
||||||
#ifdef SUGGEST_PROFILE
|
#ifdef SUGGEST_PROFILE
|
||||||
prof_report("try_change");
|
prof_report("try_change");
|
||||||
#endif
|
#endif
|
||||||
@ -1258,10 +1258,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
if (depth < MAXWLEN - 1 && (byts[arridx] == 0 || n == STATE_NOPREFIX)) {
|
if (depth < MAXWLEN - 1 && (byts[arridx] == 0 || n == STATE_NOPREFIX)) {
|
||||||
// Set su->su_badflags to the caps type at this position.
|
// Set su->su_badflags to the caps type at this position.
|
||||||
// Use the caps type until here for the prefix itself.
|
// Use the caps type until here for the prefix itself.
|
||||||
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
|
n = nofold_len(fword, sp->ts_fidx, (char_u *)su->su_badptr);
|
||||||
flags = badword_captype(su->su_badptr, su->su_badptr + n);
|
flags = badword_captype((char_u *)su->su_badptr, (char_u *)su->su_badptr + n);
|
||||||
su->su_badflags = badword_captype(su->su_badptr + n,
|
su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
|
||||||
su->su_badptr + su->su_badlen);
|
(char_u *)su->su_badptr + su->su_badlen);
|
||||||
#ifdef DEBUG_TRIEWALK
|
#ifdef DEBUG_TRIEWALK
|
||||||
sprintf(changename[depth], "prefix"); // NOLINT(runtime/printf)
|
sprintf(changename[depth], "prefix"); // NOLINT(runtime/printf)
|
||||||
#endif
|
#endif
|
||||||
@ -1278,7 +1278,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
tword[sp->ts_twordlen] = NUL;
|
tword[sp->ts_twordlen] = NUL;
|
||||||
make_case_word(tword + sp->ts_splitoff,
|
make_case_word(tword + sp->ts_splitoff,
|
||||||
(char_u *)preword + sp->ts_prewordlen, flags);
|
(char_u *)preword + sp->ts_prewordlen, flags);
|
||||||
sp->ts_prewordlen = (char_u)STRLEN(preword);
|
sp->ts_prewordlen = (char_u)strlen(preword);
|
||||||
sp->ts_splitoff = sp->ts_twordlen;
|
sp->ts_splitoff = sp->ts_twordlen;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1408,8 +1408,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
while (*skiptowhite((char *)p) != NUL) {
|
while (*skiptowhite((char *)p) != NUL) {
|
||||||
p = (char_u *)skipwhite(skiptowhite((char *)p));
|
p = (char_u *)skipwhite(skiptowhite((char *)p));
|
||||||
}
|
}
|
||||||
if (fword_ends && !can_compound(slang, p,
|
if (fword_ends && !can_compound(slang, (char *)p, compflags + sp->ts_compsplit)) {
|
||||||
compflags + sp->ts_compsplit)) {
|
|
||||||
// Compound is not allowed. But it may still be
|
// Compound is not allowed. But it may still be
|
||||||
// possible if we add another (short) word.
|
// possible if we add another (short) word.
|
||||||
compound_ok = false;
|
compound_ok = false;
|
||||||
@ -1436,9 +1435,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
// use that for the goodword too. But if the badword is
|
// use that for the goodword too. But if the badword is
|
||||||
// allcap and it's only one char long use onecap.
|
// allcap and it's only one char long use onecap.
|
||||||
c = su->su_badflags;
|
c = su->su_badflags;
|
||||||
if ((c & WF_ALLCAP)
|
if ((c & WF_ALLCAP) && su->su_badlen == utfc_ptr2len(su->su_badptr)) {
|
||||||
&& su->su_badlen ==
|
|
||||||
utfc_ptr2len((char *)su->su_badptr)) {
|
|
||||||
c = WF_ONECAP;
|
c = WF_ONECAP;
|
||||||
}
|
}
|
||||||
c |= flags;
|
c |= flags;
|
||||||
@ -1456,7 +1453,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
// Don't use a banned word. It may appear again as a good
|
// Don't use a banned word. It may appear again as a good
|
||||||
// word, thus remember it.
|
// word, thus remember it.
|
||||||
if (flags & WF_BANNED) {
|
if (flags & WF_BANNED) {
|
||||||
add_banned(su, (char_u *)preword + sp->ts_prewordlen);
|
add_banned(su, preword + sp->ts_prewordlen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((sp->ts_complen == sp->ts_compsplit
|
if ((sp->ts_complen == sp->ts_compsplit
|
||||||
@ -1506,14 +1503,14 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
if (soundfold) {
|
if (soundfold) {
|
||||||
// For soundfolded words we need to find the original
|
// For soundfolded words we need to find the original
|
||||||
// words, the edit distance and then add them.
|
// words, the edit distance and then add them.
|
||||||
add_sound_suggest(su, (char_u *)preword, sp->ts_score, lp);
|
add_sound_suggest(su, preword, sp->ts_score, lp);
|
||||||
} else if (sp->ts_fidx > 0) {
|
} else if (sp->ts_fidx > 0) {
|
||||||
// Give a penalty when changing non-word char to word
|
// Give a penalty when changing non-word char to word
|
||||||
// char, e.g., "thes," -> "these".
|
// char, e.g., "thes," -> "these".
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
MB_PTR_BACK(fword, p);
|
MB_PTR_BACK(fword, p);
|
||||||
if (!spell_iswordp(p, curwin) && *preword != NUL) {
|
if (!spell_iswordp(p, curwin) && *preword != NUL) {
|
||||||
p = (char_u *)preword + STRLEN(preword);
|
p = (char_u *)preword + strlen(preword);
|
||||||
MB_PTR_BACK(preword, p);
|
MB_PTR_BACK(preword, p);
|
||||||
if (spell_iswordp(p, curwin)) {
|
if (spell_iswordp(p, curwin)) {
|
||||||
newscore += SCORE_NONWORD;
|
newscore += SCORE_NONWORD;
|
||||||
@ -1630,8 +1627,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
p = (char_u *)skipwhite(skiptowhite((char *)p));
|
p = (char_u *)skipwhite(skiptowhite((char *)p));
|
||||||
}
|
}
|
||||||
if (sp->ts_complen > sp->ts_compsplit
|
if (sp->ts_complen > sp->ts_compsplit
|
||||||
&& !can_compound(slang, p,
|
&& !can_compound(slang, (char *)p, compflags + sp->ts_compsplit)) {
|
||||||
compflags + sp->ts_compsplit)) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1710,9 +1706,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
|
|
||||||
// set su->su_badflags to the caps type at this
|
// set su->su_badflags to the caps type at this
|
||||||
// position
|
// position
|
||||||
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
|
n = nofold_len(fword, sp->ts_fidx, (char_u *)su->su_badptr);
|
||||||
su->su_badflags = badword_captype(su->su_badptr + n,
|
su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
|
||||||
su->su_badptr + su->su_badlen);
|
(char_u *)su->su_badptr + su->su_badlen);
|
||||||
|
|
||||||
// Restart at top of the tree.
|
// Restart at top of the tree.
|
||||||
sp->ts_arridx = 0;
|
sp->ts_arridx = 0;
|
||||||
@ -2289,7 +2285,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
sp->ts_curi = (int16_t)gap->ga_len;
|
sp->ts_curi = (int16_t)gap->ga_len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (STRNCMP(ftp->ft_from, p, STRLEN(ftp->ft_from)) == 0
|
if (STRNCMP(ftp->ft_from, p, strlen((char *)ftp->ft_from)) == 0
|
||||||
&& TRY_DEEPER(su, stack, depth, SCORE_REP)) {
|
&& TRY_DEEPER(su, stack, depth, SCORE_REP)) {
|
||||||
go_deeper(stack, depth, SCORE_REP);
|
go_deeper(stack, depth, SCORE_REP);
|
||||||
#ifdef DEBUG_TRIEWALK
|
#ifdef DEBUG_TRIEWALK
|
||||||
@ -2303,10 +2299,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
|
|
||||||
// Change the "from" to the "to" string.
|
// Change the "from" to the "to" string.
|
||||||
depth++;
|
depth++;
|
||||||
fl = (int)STRLEN(ftp->ft_from);
|
fl = (int)strlen((char *)ftp->ft_from);
|
||||||
tl = (int)STRLEN(ftp->ft_to);
|
tl = (int)strlen((char *)ftp->ft_to);
|
||||||
if (fl != tl) {
|
if (fl != tl) {
|
||||||
STRMOVE(p + tl, p + fl);
|
STRMOVE(p + tl, (char *)p + fl);
|
||||||
repextra += tl - fl;
|
repextra += tl - fl;
|
||||||
}
|
}
|
||||||
memmove(p, ftp->ft_to, (size_t)tl);
|
memmove(p, ftp->ft_to, (size_t)tl);
|
||||||
@ -2332,11 +2328,11 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
gap = &lp->lp_replang->sl_rep;
|
gap = &lp->lp_replang->sl_rep;
|
||||||
}
|
}
|
||||||
ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;
|
ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;
|
||||||
fl = (int)STRLEN(ftp->ft_from);
|
fl = (int)strlen((char *)ftp->ft_from);
|
||||||
tl = (int)STRLEN(ftp->ft_to);
|
tl = (int)strlen((char *)ftp->ft_to);
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
if (fl != tl) {
|
if (fl != tl) {
|
||||||
STRMOVE(p + fl, p + tl);
|
STRMOVE(p + fl, (char *)p + tl);
|
||||||
repextra -= tl - fl;
|
repextra -= tl - fl;
|
||||||
}
|
}
|
||||||
memmove(p, ftp->ft_from, (size_t)fl);
|
memmove(p, ftp->ft_from, (size_t)fl);
|
||||||
@ -2519,7 +2515,7 @@ static void score_comp_sal(suginfo_T *su)
|
|||||||
lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);
|
lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi);
|
||||||
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
|
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
|
||||||
// soundfold the bad word
|
// soundfold the bad word
|
||||||
spell_soundfold(lp->lp_slang, su->su_fbadword, true, badsound);
|
spell_soundfold(lp->lp_slang, (char *)su->su_fbadword, true, (char *)badsound);
|
||||||
|
|
||||||
for (i = 0; i < su->su_ga.ga_len; i++) {
|
for (i = 0; i < su->su_ga.ga_len; i++) {
|
||||||
stp = &SUG(su->su_ga, i);
|
stp = &SUG(su->su_ga, i);
|
||||||
@ -2562,7 +2558,7 @@ static void score_combine(suginfo_T *su)
|
|||||||
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
|
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
|
||||||
// soundfold the bad word
|
// soundfold the bad word
|
||||||
slang = lp->lp_slang;
|
slang = lp->lp_slang;
|
||||||
spell_soundfold(slang, su->su_fbadword, true, (char_u *)badsound);
|
spell_soundfold(slang, (char *)su->su_fbadword, true, badsound);
|
||||||
|
|
||||||
for (int i = 0; i < su->su_ga.ga_len; i++) {
|
for (int i = 0; i < su->su_ga.ga_len; i++) {
|
||||||
stp = &SUG(su->su_ga, i);
|
stp = &SUG(su->su_ga, i);
|
||||||
@ -2664,7 +2660,7 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
|
|||||||
pbad = badsound;
|
pbad = badsound;
|
||||||
} else {
|
} else {
|
||||||
// soundfold the bad word with more characters following
|
// soundfold the bad word with more characters following
|
||||||
(void)spell_casefold(curwin, su->su_badptr, stp->st_orglen, fword, MAXWLEN);
|
(void)spell_casefold(curwin, (char_u *)su->su_badptr, stp->st_orglen, fword, MAXWLEN);
|
||||||
|
|
||||||
// When joining two words the sound often changes a lot. E.g., "t he"
|
// 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
|
// sounds like "t h" while "the" sounds like "@". Avoid that by
|
||||||
@ -2673,11 +2669,11 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
|
|||||||
if (ascii_iswhite(su->su_badptr[su->su_badlen])
|
if (ascii_iswhite(su->su_badptr[su->su_badlen])
|
||||||
&& *skiptowhite(stp->st_word) == NUL) {
|
&& *skiptowhite(stp->st_word) == NUL) {
|
||||||
for (p = fword; *(p = (char_u *)skiptowhite((char *)p)) != NUL;) {
|
for (p = fword; *(p = (char_u *)skiptowhite((char *)p)) != NUL;) {
|
||||||
STRMOVE(p, p + 1);
|
STRMOVE(p, (char *)p + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spell_soundfold(slang, fword, true, badsound2);
|
spell_soundfold(slang, (char *)fword, true, (char *)badsound2);
|
||||||
pbad = badsound2;
|
pbad = badsound2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2693,7 +2689,7 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sound-fold the word and compute the score for the difference.
|
// Sound-fold the word and compute the score for the difference.
|
||||||
spell_soundfold(slang, pgood, false, goodsound);
|
spell_soundfold(slang, (char *)pgood, false, (char *)goodsound);
|
||||||
|
|
||||||
return soundalike_score((char *)goodsound, (char *)pbad);
|
return soundalike_score((char *)goodsound, (char *)pbad);
|
||||||
}
|
}
|
||||||
@ -2742,7 +2738,7 @@ static void suggest_try_soundalike(suginfo_T *su)
|
|||||||
slang = lp->lp_slang;
|
slang = lp->lp_slang;
|
||||||
if (!GA_EMPTY(&slang->sl_sal) && slang->sl_sbyts != NULL) {
|
if (!GA_EMPTY(&slang->sl_sal) && slang->sl_sbyts != NULL) {
|
||||||
// soundfold the bad word
|
// soundfold the bad word
|
||||||
spell_soundfold(slang, su->su_fbadword, true, salword);
|
spell_soundfold(slang, (char *)su->su_fbadword, true, (char *)salword);
|
||||||
|
|
||||||
// try all kinds of inserts/deletes/swaps/etc.
|
// try all kinds of inserts/deletes/swaps/etc.
|
||||||
// TODO(vim): also soundfold the next words, so that we can try joining
|
// TODO(vim): also soundfold the next words, so that we can try joining
|
||||||
@ -2792,7 +2788,7 @@ static void suggest_try_soundalike_finish(void)
|
|||||||
/// produce this soundfolded word.
|
/// produce this soundfolded word.
|
||||||
///
|
///
|
||||||
/// @param score soundfold score
|
/// @param score soundfold score
|
||||||
static void add_sound_suggest(suginfo_T *su, char_u *goodword, int score, langp_T *lp)
|
static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T *lp)
|
||||||
{
|
{
|
||||||
slang_T *slang = lp->lp_slang; // language for sound folding
|
slang_T *slang = lp->lp_slang; // language for sound folding
|
||||||
int sfwordnr;
|
int sfwordnr;
|
||||||
@ -2817,8 +2813,8 @@ static void add_sound_suggest(suginfo_T *su, char_u *goodword, int score, langp_
|
|||||||
// times with different scores. Since the following is quite slow only do
|
// times with different scores. Since the following is quite slow only do
|
||||||
// the words that have a better score than before. Use a hashtable to
|
// the words that have a better score than before. Use a hashtable to
|
||||||
// remember the words that have been done.
|
// remember the words that have been done.
|
||||||
hash = hash_hash(goodword);
|
hash = hash_hash((char_u *)goodword);
|
||||||
const size_t goodword_len = STRLEN(goodword);
|
const size_t goodword_len = strlen(goodword);
|
||||||
hi = hash_lookup(&slang->sl_sounddone, (const char *)goodword, goodword_len,
|
hi = hash_lookup(&slang->sl_sounddone, (const char *)goodword, goodword_len,
|
||||||
hash);
|
hash);
|
||||||
if (HASHITEM_EMPTY(hi)) {
|
if (HASHITEM_EMPTY(hi)) {
|
||||||
@ -2835,7 +2831,7 @@ static void add_sound_suggest(suginfo_T *su, char_u *goodword, int score, langp_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the word nr in the soundfold tree.
|
// Find the word nr in the soundfold tree.
|
||||||
sfwordnr = soundfold_find(slang, goodword);
|
sfwordnr = soundfold_find(slang, (char_u *)goodword);
|
||||||
if (sfwordnr < 0) {
|
if (sfwordnr < 0) {
|
||||||
internal_error("add_sound_suggest()");
|
internal_error("add_sound_suggest()");
|
||||||
return;
|
return;
|
||||||
@ -3064,7 +3060,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
|
|||||||
if (HASHITEM_EMPTY(hi)) {
|
if (HASHITEM_EMPTY(hi)) {
|
||||||
m1 = 0;
|
m1 = 0;
|
||||||
} else {
|
} else {
|
||||||
m1 = utf_ptr2char((char *)hi->hi_key + STRLEN(hi->hi_key) + 1);
|
m1 = utf_ptr2char(hi->hi_key + strlen(hi->hi_key) + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m1 = slang->sl_map_array[c1];
|
m1 = slang->sl_map_array[c1];
|
||||||
@ -3079,7 +3075,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
|
|||||||
if (HASHITEM_EMPTY(hi)) {
|
if (HASHITEM_EMPTY(hi)) {
|
||||||
m2 = 0;
|
m2 = 0;
|
||||||
} else {
|
} else {
|
||||||
m2 = utf_ptr2char((char *)hi->hi_key + STRLEN(hi->hi_key) + 1);
|
m2 = utf_ptr2char(hi->hi_key + strlen(hi->hi_key) + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m2 = slang->sl_map_array[c2];
|
m2 = slang->sl_map_array[c2];
|
||||||
@ -3107,7 +3103,7 @@ static void add_suggestion(suginfo_T *su, garray_T *gap, const char *goodword, i
|
|||||||
// Minimize "badlen" for consistency. Avoids that changing "the the" to
|
// Minimize "badlen" for consistency. Avoids that changing "the the" to
|
||||||
// "thee the" is added next to changing the first "the" the "thee".
|
// "thee the" is added next to changing the first "the" the "thee".
|
||||||
const char *pgood = goodword + strlen(goodword);
|
const char *pgood = goodword + strlen(goodword);
|
||||||
char_u *pbad = su->su_badptr + badlenarg;
|
char *pbad = su->su_badptr + badlenarg;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
goodlen = (int)(pgood - goodword);
|
goodlen = (int)(pgood - goodword);
|
||||||
badlen = (int)(pbad - su->su_badptr);
|
badlen = (int)(pbad - su->su_badptr);
|
||||||
@ -3116,7 +3112,7 @@ static void add_suggestion(suginfo_T *su, garray_T *gap, const char *goodword, i
|
|||||||
}
|
}
|
||||||
MB_PTR_BACK(goodword, pgood);
|
MB_PTR_BACK(goodword, pgood);
|
||||||
MB_PTR_BACK(su->su_badptr, pbad);
|
MB_PTR_BACK(su->su_badptr, pbad);
|
||||||
if (utf_ptr2char((char *)pgood) != utf_ptr2char((char *)pbad)) {
|
if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3236,15 +3232,15 @@ static void check_suggestions(suginfo_T *su, garray_T *gap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add a word to be banned.
|
/// Add a word to be banned.
|
||||||
static void add_banned(suginfo_T *su, char_u *word)
|
static void add_banned(suginfo_T *su, char *word)
|
||||||
{
|
{
|
||||||
char_u *s;
|
char_u *s;
|
||||||
hash_T hash;
|
hash_T hash;
|
||||||
hashitem_T *hi;
|
hashitem_T *hi;
|
||||||
|
|
||||||
hash = hash_hash(word);
|
hash = hash_hash((char_u *)word);
|
||||||
const size_t word_len = STRLEN(word);
|
const size_t word_len = strlen(word);
|
||||||
hi = hash_lookup(&su->su_banned, (const char *)word, word_len, hash);
|
hi = hash_lookup(&su->su_banned, word, word_len, hash);
|
||||||
if (HASHITEM_EMPTY(hi)) {
|
if (HASHITEM_EMPTY(hi)) {
|
||||||
s = xmemdupz(word, word_len);
|
s = xmemdupz(word, word_len);
|
||||||
hash_add_item(&su->su_banned, hi, s, hash);
|
hash_add_item(&su->su_banned, hi, s, hash);
|
||||||
@ -3275,7 +3271,7 @@ static void rescore_one(suginfo_T *su, suggest_T *stp)
|
|||||||
if (slang == su->su_sallang) {
|
if (slang == su->su_sallang) {
|
||||||
p = su->su_sal_badword;
|
p = su->su_sal_badword;
|
||||||
} else {
|
} else {
|
||||||
spell_soundfold(slang, su->su_fbadword, true, sal_badword);
|
spell_soundfold(slang, (char *)su->su_fbadword, true, (char *)sal_badword);
|
||||||
p = sal_badword;
|
p = sal_badword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ void draw_tabline(void)
|
|||||||
len = Columns - col - 1;
|
len = Columns - col - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
grid_puts_len(&default_grid, (char *)p, (int)STRLEN(p), 0, col, attr);
|
grid_puts_len(&default_grid, (char *)p, (int)strlen((char *)p), 0, col, attr);
|
||||||
col += len;
|
col += len;
|
||||||
}
|
}
|
||||||
grid_putchar(&default_grid, ' ', 0, col++, attr);
|
grid_putchar(&default_grid, ' ', 0, col++, attr);
|
||||||
|
@ -137,15 +137,16 @@ char *vim_strnsave_unquoted(const char *const string, const size_t length)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escape "string" for use as a shell argument with system().
|
/// Escape "string" for use as a shell argument with system().
|
||||||
// This uses single quotes, except when we know we need to use double quotes
|
/// This uses single quotes, except when we know we need to use double quotes
|
||||||
// (MS-Windows without 'shellslash' set).
|
/// (MS-Windows without 'shellslash' set).
|
||||||
// Escape a newline, depending on the 'shell' option.
|
/// Escape a newline, depending on the 'shell' option.
|
||||||
// When "do_special" is true also replace "!", "%", "#" and things starting
|
/// When "do_special" is true also replace "!", "%", "#" and things starting
|
||||||
// with "<" like "<cfile>".
|
/// with "<" like "<cfile>".
|
||||||
// When "do_newline" is false do not escape newline unless it is csh shell.
|
/// When "do_newline" is false do not escape newline unless it is csh shell.
|
||||||
// Returns the result in allocated memory.
|
///
|
||||||
char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_newline)
|
/// @return the result in allocated memory.
|
||||||
|
char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newline)
|
||||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
@ -165,8 +166,8 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
|
|||||||
fish_like = fish_like_shell();
|
fish_like = fish_like_shell();
|
||||||
|
|
||||||
// First count the number of extra bytes required.
|
// First count the number of extra bytes required.
|
||||||
size_t length = STRLEN(string) + 3; // two quotes and a trailing NUL
|
size_t length = strlen(string) + 3; // two quotes and a trailing NUL
|
||||||
for (const char_u *p = string; *p != NUL; MB_PTR_ADV(p)) {
|
for (const char_u *p = (char_u *)string; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
#ifdef MSWIN
|
#ifdef MSWIN
|
||||||
if (!p_ssl) {
|
if (!p_ssl) {
|
||||||
if (*p == '"') {
|
if (*p == '"') {
|
||||||
@ -258,7 +259,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
|
|||||||
*d++ = '\'';
|
*d++ = '\'';
|
||||||
*d = NUL;
|
*d = NUL;
|
||||||
|
|
||||||
return escaped_string;
|
return (char *)escaped_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like vim_strsave(), but make all characters uppercase.
|
// Like vim_strsave(), but make all characters uppercase.
|
||||||
@ -338,12 +339,12 @@ char *strcase_save(const char *const orig, bool upper)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete spaces at the end of a string
|
// delete spaces at the end of a string
|
||||||
void del_trailing_spaces(char_u *ptr)
|
void del_trailing_spaces(char *ptr)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char_u *q;
|
char *q;
|
||||||
|
|
||||||
q = ptr + STRLEN(ptr);
|
q = ptr + strlen(ptr);
|
||||||
while (--q > ptr && ascii_iswhite(q[0]) && q[-1] != '\\' && q[-1] != Ctrl_V) {
|
while (--q > ptr && ascii_iswhite(q[0]) && q[-1] != '\\' && q[-1] != Ctrl_V) {
|
||||||
*q = NUL;
|
*q = NUL;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ typedef struct {
|
|||||||
proftime_T slowest;
|
proftime_T slowest;
|
||||||
proftime_T average;
|
proftime_T average;
|
||||||
int id;
|
int id;
|
||||||
char_u *pattern;
|
char *pattern;
|
||||||
} time_entry_T;
|
} time_entry_T;
|
||||||
|
|
||||||
struct name_list {
|
struct name_list {
|
||||||
@ -228,7 +228,7 @@ static int running_syn_inc_tag = 0;
|
|||||||
// HI2KE() converts a hashitem pointer to a var pointer.
|
// HI2KE() converts a hashitem pointer to a var pointer.
|
||||||
static keyentry_T dumkey;
|
static keyentry_T dumkey;
|
||||||
#define KE2HIKEY(kp) ((kp)->keyword)
|
#define KE2HIKEY(kp) ((kp)->keyword)
|
||||||
#define HIKEY2KE(p) ((keyentry_T *)((p) - (dumkey.keyword - (char_u *)&dumkey)))
|
#define HIKEY2KE(p) ((keyentry_T *)((p) - (dumkey.keyword - (char *)&dumkey)))
|
||||||
#define HI2KE(hi) HIKEY2KE((hi)->hi_key)
|
#define HI2KE(hi) HIKEY2KE((hi)->hi_key)
|
||||||
|
|
||||||
// -V:HI2KE:782
|
// -V:HI2KE:782
|
||||||
@ -2754,7 +2754,7 @@ static int check_keyword_id(char *const line, const int startcol, int *const end
|
|||||||
|
|
||||||
// ignoring case
|
// ignoring case
|
||||||
if (kp == NULL && syn_block->b_keywtab_ic.ht_used != 0) {
|
if (kp == NULL && syn_block->b_keywtab_ic.ht_used != 0) {
|
||||||
str_foldcase((char_u *)kwp, kwlen, keyword, MAXKEYWLEN + 1);
|
str_foldcase((char_u *)kwp, kwlen, (char *)keyword, MAXKEYWLEN + 1);
|
||||||
kp = match_keyword((char *)keyword, &syn_block->b_keywtab_ic, cur_si);
|
kp = match_keyword((char *)keyword, &syn_block->b_keywtab_ic, cur_si);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3599,7 +3599,7 @@ static bool syn_list_keywords(const int id, const hashtab_T *const ht, bool did_
|
|||||||
|| prev_next_list != kp->next_list) {
|
|| prev_next_list != kp->next_list) {
|
||||||
force_newline = true;
|
force_newline = true;
|
||||||
} else {
|
} else {
|
||||||
outlen = (int)STRLEN(kp->keyword);
|
outlen = (int)strlen(kp->keyword);
|
||||||
}
|
}
|
||||||
// output "contained" and "nextgroup" on each line
|
// output "contained" and "nextgroup" on each line
|
||||||
if (syn_list_header(did_header, outlen, id, force_newline)) {
|
if (syn_list_header(did_header, outlen, id, force_newline)) {
|
||||||
@ -3672,7 +3672,7 @@ static void syn_clear_keyword(int id, hashtab_T *ht)
|
|||||||
if (kp_next == NULL) {
|
if (kp_next == NULL) {
|
||||||
hash_remove(ht, hi);
|
hash_remove(ht, hi);
|
||||||
} else {
|
} else {
|
||||||
hi->hi_key = KE2HIKEY(kp_next);
|
hi->hi_key = (char *)KE2HIKEY(kp_next);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
kp_prev->ke_next = kp_next;
|
kp_prev->ke_next = kp_next;
|
||||||
@ -3727,7 +3727,7 @@ static void add_keyword(char *const name, const int id, const int flags,
|
|||||||
{
|
{
|
||||||
char name_folded[MAXKEYWLEN + 1];
|
char name_folded[MAXKEYWLEN + 1];
|
||||||
const char *const name_ic = (curwin->w_s->b_syn_ic)
|
const char *const name_ic = (curwin->w_s->b_syn_ic)
|
||||||
? (char *)str_foldcase((char_u *)name, (int)strlen(name), (char_u *)name_folded,
|
? (char *)str_foldcase((char_u *)name, (int)strlen(name), name_folded,
|
||||||
sizeof(name_folded))
|
sizeof(name_folded))
|
||||||
: name;
|
: name;
|
||||||
|
|
||||||
@ -3743,12 +3743,12 @@ static void add_keyword(char *const name, const int id, const int flags,
|
|||||||
}
|
}
|
||||||
kp->next_list = copy_id_list(next_list);
|
kp->next_list = copy_id_list(next_list);
|
||||||
|
|
||||||
const hash_T hash = hash_hash(kp->keyword);
|
const hash_T hash = hash_hash((char_u *)kp->keyword);
|
||||||
hashtab_T *const ht = (curwin->w_s->b_syn_ic)
|
hashtab_T *const ht = (curwin->w_s->b_syn_ic)
|
||||||
? &curwin->w_s->b_keywtab_ic
|
? &curwin->w_s->b_keywtab_ic
|
||||||
: &curwin->w_s->b_keywtab;
|
: &curwin->w_s->b_keywtab;
|
||||||
hashitem_T *const hi = hash_lookup(ht, (const char *)kp->keyword,
|
hashitem_T *const hi = hash_lookup(ht, (const char *)kp->keyword,
|
||||||
STRLEN(kp->keyword), hash);
|
strlen(kp->keyword), hash);
|
||||||
|
|
||||||
// even though it looks like only the kp->keyword member is
|
// even though it looks like only the kp->keyword member is
|
||||||
// being used here, vim uses some pointer trickery to get the original
|
// being used here, vim uses some pointer trickery to get the original
|
||||||
@ -3757,11 +3757,11 @@ static void add_keyword(char *const name, const int id, const int flags,
|
|||||||
if (HASHITEM_EMPTY(hi)) {
|
if (HASHITEM_EMPTY(hi)) {
|
||||||
// new keyword, add to hashtable
|
// new keyword, add to hashtable
|
||||||
kp->ke_next = NULL;
|
kp->ke_next = NULL;
|
||||||
hash_add_item(ht, hi, kp->keyword, hash);
|
hash_add_item(ht, hi, (char_u *)kp->keyword, hash);
|
||||||
} else {
|
} else {
|
||||||
// keyword already exists, prepend to list
|
// keyword already exists, prepend to list
|
||||||
kp->ke_next = HI2KE(hi);
|
kp->ke_next = HI2KE(hi);
|
||||||
hi->hi_key = KE2HIKEY(kp);
|
hi->hi_key = (char *)KE2HIKEY(kp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5646,7 +5646,7 @@ static void syntime_report(void)
|
|||||||
proftime_T tm = profile_divide(spp->sp_time.total, (int)spp->sp_time.count);
|
proftime_T tm = profile_divide(spp->sp_time.total, (int)spp->sp_time.count);
|
||||||
p->average = tm;
|
p->average = tm;
|
||||||
p->id = spp->sp_syn.id;
|
p->id = spp->sp_syn.id;
|
||||||
p->pattern = (char_u *)spp->sp_pattern;
|
p->pattern = spp->sp_pattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5687,10 +5687,10 @@ static void syntime_report(void)
|
|||||||
} else {
|
} else {
|
||||||
len = Columns - 70;
|
len = Columns - 70;
|
||||||
}
|
}
|
||||||
if (len > (int)STRLEN(p->pattern)) {
|
if (len > (int)strlen(p->pattern)) {
|
||||||
len = (int)STRLEN(p->pattern);
|
len = (int)strlen(p->pattern);
|
||||||
}
|
}
|
||||||
msg_outtrans_len((char *)p->pattern, len);
|
msg_outtrans_len(p->pattern, len);
|
||||||
msg_puts("\n");
|
msg_puts("\n");
|
||||||
}
|
}
|
||||||
ga_clear(&ga);
|
ga_clear(&ga);
|
||||||
|
@ -30,7 +30,7 @@ struct keyentry {
|
|||||||
int16_t *next_list; // ID list for next match (if non-zero)
|
int16_t *next_list; // ID list for next match (if non-zero)
|
||||||
int flags;
|
int flags;
|
||||||
int k_char; // conceal substitute character
|
int k_char; // conceal substitute character
|
||||||
char_u keyword[1]; // actually longer
|
char keyword[1]; // actually longer
|
||||||
};
|
};
|
||||||
|
|
||||||
// Struct used to store one state of the state stack.
|
// Struct used to store one state of the state stack.
|
||||||
|
@ -1481,7 +1481,7 @@ static bool findtags_in_help_init(findtags_state_T *st)
|
|||||||
} else {
|
} else {
|
||||||
// Prefer help tags according to 'helplang'. Put the two-letter
|
// Prefer help tags according to 'helplang'. Put the two-letter
|
||||||
// language name in help_lang[].
|
// language name in help_lang[].
|
||||||
i = (int)STRLEN(st->tag_fname);
|
i = (int)strlen(st->tag_fname);
|
||||||
if (i > 3 && st->tag_fname[i - 3] == '-') {
|
if (i > 3 && st->tag_fname[i - 3] == '-') {
|
||||||
STRLCPY(st->help_lang, st->tag_fname + i - 2, 3);
|
STRLCPY(st->help_lang, st->tag_fname + i - 2, 3);
|
||||||
} else {
|
} else {
|
||||||
@ -2599,7 +2599,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
|
|||||||
// move the filename one char forward and truncate the
|
// move the filename one char forward and truncate the
|
||||||
// filepath with a NUL
|
// filepath with a NUL
|
||||||
filename = (char_u *)path_tail(buf);
|
filename = (char_u *)path_tail(buf);
|
||||||
STRMOVE(filename + 1, filename);
|
STRMOVE(filename + 1, (char *)filename);
|
||||||
*filename++ = NUL;
|
*filename++ = NUL;
|
||||||
|
|
||||||
tnp->tn_search_ctx = vim_findfile_init(buf, (char *)filename,
|
tnp->tn_search_ctx = vim_findfile_init(buf, (char *)filename,
|
||||||
|
@ -188,7 +188,7 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_s
|
|||||||
if (item2 == NULL
|
if (item2 == NULL
|
||||||
|| !tv_equal(&TV_DICT_HI2DI(hi)->di_tv, &item2->di_tv, false, false)) {
|
|| !tv_equal(&TV_DICT_HI2DI(hi)->di_tv, &item2->di_tv, false, false)) {
|
||||||
// item of exp_d not present in got_d or values differ.
|
// item of exp_d not present in got_d or values differ.
|
||||||
const size_t key_len = STRLEN(hi->hi_key);
|
const size_t key_len = strlen(hi->hi_key);
|
||||||
tv_dict_add_tv(exp_tv->vval.v_dict, (const char *)hi->hi_key, key_len,
|
tv_dict_add_tv(exp_tv->vval.v_dict, (const char *)hi->hi_key, key_len,
|
||||||
&TV_DICT_HI2DI(hi)->di_tv);
|
&TV_DICT_HI2DI(hi)->di_tv);
|
||||||
if (item2 != NULL) {
|
if (item2 != NULL) {
|
||||||
@ -209,7 +209,7 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_s
|
|||||||
dictitem_T *item2 = tv_dict_find(exp_d, (const char *)hi->hi_key, -1);
|
dictitem_T *item2 = tv_dict_find(exp_d, (const char *)hi->hi_key, -1);
|
||||||
if (item2 == NULL) {
|
if (item2 == NULL) {
|
||||||
// item of got_d not present in exp_d
|
// item of got_d not present in exp_d
|
||||||
const size_t key_len = STRLEN(hi->hi_key);
|
const size_t key_len = strlen(hi->hi_key);
|
||||||
tv_dict_add_tv(got_tv->vval.v_dict, (const char *)hi->hi_key, key_len,
|
tv_dict_add_tv(got_tv->vval.v_dict, (const char *)hi->hi_key, key_len,
|
||||||
&TV_DICT_HI2DI(hi)->di_tv);
|
&TV_DICT_HI2DI(hi)->di_tv);
|
||||||
}
|
}
|
||||||
|
@ -3009,7 +3009,7 @@ void u_undoline(void)
|
|||||||
char *oldp = (char *)u_save_line(curbuf->b_u_line_lnum);
|
char *oldp = (char *)u_save_line(curbuf->b_u_line_lnum);
|
||||||
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true);
|
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true);
|
||||||
changed_bytes(curbuf->b_u_line_lnum, 0);
|
changed_bytes(curbuf->b_u_line_lnum, 0);
|
||||||
extmark_splice_cols(curbuf, (int)curbuf->b_u_line_lnum - 1, 0, (colnr_T)STRLEN(oldp),
|
extmark_splice_cols(curbuf, (int)curbuf->b_u_line_lnum - 1, 0, (colnr_T)strlen(oldp),
|
||||||
(colnr_T)strlen(curbuf->b_u_line_ptr), kExtmarkUndo);
|
(colnr_T)strlen(curbuf->b_u_line_ptr), kExtmarkUndo);
|
||||||
xfree(curbuf->b_u_line_ptr);
|
xfree(curbuf->b_u_line_ptr);
|
||||||
curbuf->b_u_line_ptr = oldp;
|
curbuf->b_u_line_ptr = oldp;
|
||||||
|
@ -195,7 +195,6 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
|
|||||||
// defines to avoid typecasts from (char_u *) to (char *) and back
|
// defines to avoid typecasts from (char_u *) to (char *) and back
|
||||||
// (vim_strchr() is now in strings.c)
|
// (vim_strchr() is now in strings.c)
|
||||||
|
|
||||||
#define STRLEN(s) strlen((char *)(s))
|
|
||||||
#ifdef HAVE_STRNLEN
|
#ifdef HAVE_STRNLEN
|
||||||
# define STRNLEN(s, n) strnlen((char *)(s), (size_t)(n))
|
# define STRNLEN(s, n) strnlen((char *)(s), (size_t)(n))
|
||||||
#else
|
#else
|
||||||
@ -216,7 +215,7 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Like strcpy() but allows overlapped source and destination.
|
// Like strcpy() but allows overlapped source and destination.
|
||||||
#define STRMOVE(d, s) memmove((d), (s), STRLEN(s) + 1)
|
#define STRMOVE(d, s) memmove((d), (s), strlen(s) + 1)
|
||||||
|
|
||||||
#ifdef HAVE_STRNCASECMP
|
#ifdef HAVE_STRNCASECMP
|
||||||
# define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n))
|
# define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n))
|
||||||
|
Loading…
Reference in New Issue
Block a user