aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-11-26 18:58:45 +0100
committerGitHub <noreply@github.com>2022-11-26 18:58:45 +0100
commit019c8805e514428c0b999583f5aec8c9f4eb96d0 (patch)
tree1a105862628c997b46725b4f3f485bd074332cce
parent319fbffc94896dd9cf0a77891d69b7fcada1fad4 (diff)
parentbd22585061b66d7f71d4832b4a81e950b3c9d19d (diff)
downloadrneovim-019c8805e514428c0b999583f5aec8c9f4eb96d0.tar.gz
rneovim-019c8805e514428c0b999583f5aec8c9f4eb96d0.tar.bz2
rneovim-019c8805e514428c0b999583f5aec8c9f4eb96d0.zip
Merge pull request #20196 from dundargoc/refactor/char_u/14
refactor: replace char_u with char 14: remove `STRLEN` part final
-rw-r--r--src/klib/kvec.h2
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/charset.c14
-rw-r--r--src/nvim/cmdexpand.c4
-rw-r--r--src/nvim/context.c6
-rw-r--r--src/nvim/debugger.c14
-rw-r--r--src/nvim/diff.c3
-rw-r--r--src/nvim/drawline.c132
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c22
-rw-r--r--src/nvim/eval/encode.c6
-rw-r--r--src/nvim/eval/encode.h2
-rw-r--r--src/nvim/eval/funcs.c3
-rw-r--r--src/nvim/eval/typval.c6
-rw-r--r--src/nvim/eval/typval_defs.h2
-rw-r--r--src/nvim/eval/userfunc.c32
-rw-r--r--src/nvim/eval/vars.c4
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--src/nvim/ex_docmd.c6
-rw-r--r--src/nvim/file_search.c2
-rw-r--r--src/nvim/hashtab.c12
-rw-r--r--src/nvim/hashtab.h6
-rw-r--r--src/nvim/highlight_group.c13
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/indent_c.c34
-rw-r--r--src/nvim/keycodes.c35
-rw-r--r--src/nvim/linematch.c2
-rw-r--r--src/nvim/match.c19
-rw-r--r--src/nvim/mbyte.c6
-rw-r--r--src/nvim/memline.c74
-rw-r--r--src/nvim/memline_defs.h2
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/normal.c4
-rw-r--r--src/nvim/option.c28
-rw-r--r--src/nvim/path.c10
-rw-r--r--src/nvim/profile.c4
-rw-r--r--src/nvim/quickfix.c2
-rw-r--r--src/nvim/regexp.c70
-rw-r--r--src/nvim/regexp_bt.c16
-rw-r--r--src/nvim/regexp_nfa.c8
-rw-r--r--src/nvim/runtime.c3
-rw-r--r--src/nvim/spell.c95
-rw-r--r--src/nvim/spell_defs.h4
-rw-r--r--src/nvim/spellfile.c283
-rw-r--r--src/nvim/spellsuggest.c134
-rw-r--r--src/nvim/statusline.c2
-rw-r--r--src/nvim/strings.c31
-rw-r--r--src/nvim/syntax.c28
-rw-r--r--src/nvim/syntax_defs.h2
-rw-r--r--src/nvim/tag.c4
-rw-r--r--src/nvim/testing.c4
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/vim.h3
53 files changed, 603 insertions, 611 deletions
diff --git a/src/klib/kvec.h b/src/klib/kvec.h
index b5b3adf7d2..f6674a0adf 100644
--- a/src/klib/kvec.h
+++ b/src/klib/kvec.h
@@ -111,7 +111,7 @@
(v).size = (v).size + len; \
} 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_pushp(v) \
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 461034ba36..d4c94a5b13 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -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
char *newp;
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
} else { // need to allocate a new line
newp = xmalloc((size_t)(oldlen + 1 - count));
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 1f9b8f9a65..a8abee42be 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -423,7 +423,7 @@ char *transstr(const char *const s, bool untab)
///
/// When "buf" is NULL, return an allocated string.
/// 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
{
garray_T ga;
@@ -431,7 +431,7 @@ char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
int len = orglen;
#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_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.
i = 0;
while (STR_CHAR(i) != NUL) {
- int c = utf_ptr2char((char *)STR_PTR(i));
- int olen = utf_ptr2len((char *)STR_PTR(i));
+ int c = utf_ptr2char(STR_PTR(i));
+ int olen = utf_ptr2len(STR_PTR(i));
int lc = mb_tolower(c);
// 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
- i += utfc_ptr2len((char *)STR_PTR(i));
+ i += utfc_ptr2len(STR_PTR(i));
}
if (buf == NULL) {
return (char_u *)ga.ga_data;
}
- return buf;
+ return (char_u *)buf;
}
// Catch 22: g_chartab[] can't be initialized before the options are
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 79ffd7552d..037d5b4060 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -449,7 +449,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|| xp->xp_context == EXPAND_MENUNAMES);
if (emenu && menu_is_separator((char *)s)) {
STRCPY(buf + len, transchar('|'));
- l = (int)STRLEN(buf + len);
+ l = (int)strlen((char *)buf + len);
len += l;
clen += l;
} else {
@@ -462,7 +462,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
len += l;
} else {
STRCPY(buf + len, transchar_byte(*s));
- len += (int)STRLEN(buf + len);
+ len += (int)strlen((char *)buf + len);
}
}
}
diff --git a/src/nvim/context.c b/src/nvim/context.c
index 5ea843e023..47e60373bf 100644
--- a/src/nvim/context.c
+++ b/src/nvim/context.c
@@ -263,12 +263,12 @@ static inline void ctx_save_funcs(Context *ctx, bool scriptonly)
Error err = ERROR_INIT;
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 isscript = (name[0] == K_SPECIAL);
+ bool isscript = ((uint8_t)name[0] == K_SPECIAL);
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);
snprintf(cmd, cmd_len, "func! %s", name);
String func_body = nvim_exec(VIML_INTERNAL_CALL, cstr_as_string(cmd),
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index 6f7d6a27ef..aa9e2a9a82 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -742,7 +742,7 @@ void ex_breaklist(exarg_T *eap)
/// @param after after this line number
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
@@ -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.
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;
}
@@ -763,11 +763,11 @@ bool has_profiling(bool file, char *fname, bool *fp)
/// @param after after this line number
/// @param gap either &dbg_breakp or &prof_ga
/// @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;
linenr_T lnum = 0;
- char_u *name = fname;
+ char *name = fname;
int prev_got_int;
// 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>".
- if (!file && fname[0] == K_SPECIAL) {
- name = xmalloc(STRLEN(fname) + 3);
+ if (!file && (uint8_t)fname[0] == K_SPECIAL) {
+ name = xmalloc(strlen(fname) + 3);
STRCPY(name, "<SNR>");
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.
prev_got_int = got_int;
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;
if (fp != NULL) {
*fp = bp->dbg_forceit;
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 121b98d047..c28eecc76a 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1215,8 +1215,7 @@ void ex_diffpatch(exarg_T *eap)
#ifdef UNIX
// Get the absolute path of the patchfile, changing directory below.
fullname = FullName_save(eap->arg, false);
- esc_name =
- (char *)vim_strsave_shellescape((char_u *)(fullname != NULL ? fullname : eap->arg), true, true);
+ esc_name = vim_strsave_shellescape(fullname != NULL ? fullname : eap->arg, true, true);
#else
esc_name = (char *)vim_strsave_shellescape(eap->arg, true, true);
#endif
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index f0637549f7..b5704897ad 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -313,8 +313,8 @@ static bool use_cursor_line_sign(win_T *wp, linenr_T lnum)
// @param sign_idxp Index of the displayed sign
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 *c_extrap, int *c_finalp, char_u *extra, size_t extra_size,
- char_u **pp_extra, int *n_extrap, int *char_attrp, int sign_idx,
+ int *c_extrap, int *c_finalp, char *extra, size_t extra_size,
+ char **pp_extra, int *n_extrap, int *char_attrp, int sign_idx,
int cul_attr)
{
// 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) {
SignTextAttrs *sattr = sign_get_attr(sign_idx, sattrs, wp->w_scwidth);
if (sattr != NULL) {
- *pp_extra = (char_u *)sattr->text;
+ *pp_extra = sattr->text;
if (*pp_extra != NULL) {
*c_extrap = 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 = extra;
- *n_extrap = (int)STRLEN(*pp_extra);
+ *n_extrap = (int)strlen(*pp_extra);
} else {
- size_t symbol_blen = STRLEN(*pp_extra);
+ size_t symbol_blen = strlen(*pp_extra);
// TODO(oni-link): Is sign text already extended to
// full cell width?
assert((size_t)win_signcol_width(wp) >= mb_string2cells((char *)(*pp_extra)));
// symbol(s) bytes + (filling spaces) (one byte each)
*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);
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_sbr = -1; // virtual column after showbreak
long vcol_prev = -1; // "vcol" of previous character
- char_u *line; // current line
- char_u *ptr; // current position in "line"
+ char *line; // current line
+ char *ptr; // current position in "line"
int row; // row in the window, excl w_winrow
ScreenGrid *grid = &wp->w_grid; // grid specific to the window
char_u extra[57]; // sign, line number and 'fdc' must
// fit in here
int n_extra = 0; // number of extra chars
- char_u *p_extra = NULL; // string of extra chars, plus NUL
- char_u *p_extra_free = NULL; // p_extra needs to be freed
+ char *p_extra = NULL; // string of extra chars, plus NUL
+ char *p_extra_free = NULL; // p_extra needs to be freed
int c_extra = NUL; // extra chars, all the same
int c_final = NUL; // final char, mandatory if set
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
bool has_spell = false; // this buffer has spell checking
#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 nextline_idx = 0; // index in nextline[] where next line
// 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
nextline[SPWORDLEN] = NUL;
if (lnum < wp->w_buffer->b_ml.ml_line_count) {
- line = (char_u *)ml_get_buf(wp->w_buffer, lnum + 1, false);
- spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN);
+ line = ml_get_buf(wp->w_buffer, lnum + 1, false);
+ spell_cat_line((char_u *)nextline + SPWORDLEN, (char_u *)line, SPWORDLEN);
}
// 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 = 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;
if (has_spell && !number_only) {
// For checking first word with a capital skip white space.
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
@@ -904,7 +904,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
nextlinecol = MAXCOL;
nextline_idx = 0;
} else {
- v = (long)STRLEN(line);
+ v = (long)strlen(line);
if (v < SPWORDLEN) {
// Short line, use it completely and append the start of the
// 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
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])) {
trailcol--;
}
@@ -962,19 +962,19 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
v = wp->w_leftcol;
}
if (v > 0 && !number_only) {
- char_u *prev_ptr = ptr;
+ char *prev_ptr = ptr;
chartabsize_T cts;
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) {
charsize = win_lbr_chartabsize(&cts, NULL);
cts.cts_vcol += charsize;
- prev_ptr = (char_u *)cts.cts_ptr;
+ prev_ptr = cts.cts_ptr;
MB_PTR_ADV(cts.cts_ptr);
}
vcol = cts.cts_vcol;
- ptr = (char_u *)cts.cts_ptr;
+ ptr = cts.cts_ptr;
clear_chartabsize_arg(&cts);
// When:
@@ -997,7 +997,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
ptr = prev_ptr;
// If the character fits on the screen, don't need to skip it.
// Except for a TAB.
- if (utf_ptr2cells((char *)ptr) >= charsize || *ptr == TAB) {
+ if (utf_ptr2cells(ptr) >= charsize || *ptr == TAB) {
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);
// 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;
if (len == 0 || (int)wp->w_cursor.col > ptr - line) {
// no bad word found at line start, don't check until end of a
// word
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 {
// bad word found, use attributes until end of word
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.
xfree(p_extra_free);
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 = p_extra_free;
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) {
get_sign_display_info(false, wp, lnum, sattrs, row,
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,
sign_cul_attr);
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) {
get_sign_display_info(true, wp, lnum, sattrs, row,
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,
sign_cul_attr);
} 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) {
get_line_number_str(wp, lnum, (char_u *)extra, sizeof(extra));
if (wp->w_skipcol > 0) {
- for (p_extra = extra; *p_extra == ' '; p_extra++) {
+ for (p_extra = (char *)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;
}
}
- p_extra = extra;
+ p_extra = (char *)extra;
c_extra = NUL;
} else {
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_u *const sbr = get_showbreak_value(wp);
+ char *const sbr = (char *)get_showbreak_value(wp);
if (*sbr != NUL && need_showbreak) {
// Draw 'showbreak' at the start of each broken line.
p_extra = sbr;
c_extra = NUL;
c_final = NUL;
- n_extra = (int)STRLEN(sbr);
+ n_extra = (int)strlen(sbr);
char_attr = win_hl_attr(wp, HLF_AT);
if (wp->w_skipcol == 0 || !wp->w_p_wrap) {
need_showbreak = false;
}
- vcol_sbr = vcol + mb_charlen(sbr);
+ vcol_sbr = vcol + mb_charlen((char_u *)sbr);
// Correct end of highlighted area for 'showbreak',
// required when 'linebreak' is also set.
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;
c_extra = saved_c_extra;
c_final = saved_c_final;
- p_extra = saved_p_extra;
+ p_extra = (char *)saved_p_extra;
char_attr = saved_char_attr;
} else {
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;
memset(buf_fold, ' ', FOLD_TEXT_LEN);
- p_extra = (char_u *)get_foldtext(wp, lnum, lnume, foldinfo, (char *)buf_fold);
- n_extra = (int)STRLEN(p_extra);
+ p_extra = get_foldtext(wp, lnum, lnume, foldinfo, (char *)buf_fold);
+ n_extra = (int)strlen(p_extra);
- if (p_extra != buf_fold) {
+ if (p_extra != (char *)buf_fold) {
xfree(p_extra_free);
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
if (vcol == fromcol
|| (vcol + 1 == fromcol && n_extra == 0
- && utf_ptr2cells((char *)ptr) > 1)
+ && utf_ptr2cells(ptr) > 1)
|| ((int)vcol_prev == fromcol_prev
&& vcol_prev < vcol // not at margin
&& 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);
} else {
assert(p_extra != NULL);
- c = *p_extra;
+ c = (uint8_t)(*p_extra);
mb_c = c;
// If the UTF-8 character is more than one byte:
// Decode it into "mb_c".
- mb_l = utfc_ptr2len((char *)p_extra);
+ mb_l = utfc_ptr2len(p_extra);
mb_utf8 = false;
if (mb_l > n_extra) {
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;
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);
// Get a character from the line itself.
- c0 = c = *ptr;
+ c0 = c = (uint8_t)(*ptr);
mb_c = c;
// If the UTF-8 character is more than one byte: Decode it
// into "mb_c".
- mb_l = utfc_ptr2len((char *)ptr);
+ mb_l = utfc_ptr2len(ptr);
mb_utf8 = false;
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
// is displayed normally, except a NUL.
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);
}
- p_extra = extra;
- c = *p_extra;
+ p_extra = (char *)extra;
+ c = (uint8_t)(*p_extra);
mb_c = mb_ptr2char_adv((const char_u **)&p_extra);
mb_utf8 = (c >= 0x80);
- n_extra = (int)STRLEN(p_extra);
+ n_extra = (int)strlen(p_extra);
c_extra = NUL;
c_final = NUL;
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) {
pc = prev_c;
pc1 = prev_c1;
- nc = utf_ptr2char((char *)ptr + mb_l);
+ nc = utf_ptr2char(ptr + mb_l);
prev_c1 = u8cc[0];
} else {
- pc = utfc_ptr2char((char *)ptr + mb_l, pcc);
+ pc = utfc_ptr2char(ptr + mb_l, pcc);
nc = prev_c;
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
// 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;
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);
}
if (c != 0 && ((!has_syntax && !no_plain_buffer) || can_spell)) {
- char_u *prev_ptr;
- char_u *p;
+ char *prev_ptr;
+ char *p;
int len;
hlf_T spell_hlf = HLF_COUNT;
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;
}
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);
len = (int)tmplen;
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.
if (wp->w_p_lbr && c0 == c && vim_isbreak(c)
&& !vim_isbreak((int)(*ptr))) {
- int mb_off = utf_head_off((char *)line, (char *)ptr - 1);
- char_u *p = ptr - (mb_off + 1);
+ int mb_off = utf_head_off(line, ptr - 1);
+ char *p = ptr - (mb_off + 1);
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;
// 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);
p[len] = NUL;
xfree(p_extra_free);
- p_extra_free = p;
+ p_extra_free = (char *)p;
for (i = 0; i < tab_len; i++) {
if (*p == NUL) {
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) {
n_extra = 0;
} else {
- p_extra = at_end_str;
+ p_extra = (char *)at_end_str;
n_extra = 1;
c_extra = 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_utf8 = check_mb_utf8(&c, u8cc);
} 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) {
n_extra = byte2cells(c) - 1;
}
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_final = NUL;
if (wp->w_p_lbr) {
char_u *p;
- c = *p_extra;
+ c = (uint8_t)(*p_extra);
p = xmalloc((size_t)n_extra + 1);
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;
xfree(p_extra_free);
- p_extra_free = p_extra = p;
+ p_extra_free = p_extra = (char *)p;
} else {
n_extra = byte2cells(c) - 1;
- c = *p_extra++;
+ c = (uint8_t)(*p_extra++);
}
n_attr = n_extra + 1;
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
|| filler_todo > 0
|| (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
&& (c_extra != NUL || *p_extra != NUL)))) {
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
draw_state = WL_START;
saved_n_extra = n_extra;
- saved_p_extra = p_extra;
+ saved_p_extra = (char_u *)p_extra;
saved_c_extra = c_extra;
saved_c_final = c_final;
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
// After an empty line check first word for capital.
- if (*skipwhite((char *)line) == NUL) {
+ if (*skipwhite(line) == NUL) {
capcol_lnum = lnum + 1;
cap_col = 0;
}
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index cfcc33c65e..6a5f55ad79 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -4593,7 +4593,7 @@ static bool ins_tab(void)
// Delete following spaces.
i = cursor->col - fpos.col;
if (i > 0) {
- STRMOVE(ptr, ptr + i);
+ STRMOVE(ptr, (char *)ptr + i);
// correct replace stack.
if ((State & REPLACE_FLAG)
&& !(State & VREPLACE_FLAG)) {
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index a41a559fd9..005207718b 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -407,11 +407,11 @@ void eval_init(void)
// add to v: scope dict, unless the value is not always available
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) {
// 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;
@@ -1012,7 +1012,7 @@ void prepare_vimvar(int idx, typval_T *save_tv)
{
*save_tv = vimvars[idx].vv_tv;
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++;
}
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
@@ -2159,7 +2159,7 @@ char *get_user_var_name(expand_T *xp, int idx)
while (HASHITEM_EMPTY(hi)) {
hi++;
}
- return cat_prefix_varname('b', (char *)hi->hi_key);
+ return cat_prefix_varname('b', hi->hi_key);
}
// w: variables
@@ -2173,7 +2173,7 @@ char *get_user_var_name(expand_T *xp, int idx)
while (HASHITEM_EMPTY(hi)) {
hi++;
}
- return cat_prefix_varname('w', (char *)hi->hi_key);
+ return cat_prefix_varname('w', hi->hi_key);
}
// t: variables
@@ -2187,7 +2187,7 @@ char *get_user_var_name(expand_T *xp, int idx)
while (HASHITEM_EMPTY(hi)) {
hi++;
}
- return cat_prefix_varname('t', (char *)hi->hi_key);
+ return cat_prefix_varname('t', hi->hi_key);
}
// v: variables
@@ -7947,7 +7947,7 @@ const void *var_shada_iter(const void *const iter, const char **const name, typv
hi = globvarht.ht_array;
while ((size_t)(hi - hifirst) < hinum
&& (HASHITEM_EMPTY(hi)
- || !(var_flavour((char *)hi->hi_key) & flavour))) {
+ || !(var_flavour(hi->hi_key) & flavour))) {
hi++;
}
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;
tv_copy(&TV_DICT_HI2DI(hi)->di_tv, rettv);
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;
}
}
@@ -8352,7 +8352,7 @@ repeat:
if (c != NUL) {
(*fnamep)[*fnamelen] = NUL;
}
- p = (char *)vim_strsave_shellescape((char_u *)(*fnamep), false, false);
+ p = vim_strsave_shellescape(*fnamep, false, false);
if (c != NUL) {
(*fnamep)[*fnamelen] = (char)c;
}
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index 3e002ef52c..b7ef109f06 100644
--- a/src/nvim/eval/encode.c
+++ b/src/nvim/eval/encode.c
@@ -136,9 +136,9 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
typval_T key_tv = {
.v_type = VAR_STRING,
.vval = { .v_string =
- (char *)(v.data.d.hi ==
- NULL ? v.data.d.dict->dv_hashtab.ht_array : (v.data.d.hi -
- 1))->hi_key },
+ (v.data.d.hi ==
+ NULL ? v.data.d.dict->dv_hashtab.ht_array : (v.data.d.hi -
+ 1))->hi_key },
};
char *const key = encode_tv2string(&key_tv, NULL);
vim_snprintf((char *)IObuff, IOSIZE, key_msg, key);
diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h
index 5c217abb5a..e66dab1cff 100644
--- a/src/nvim/eval/encode.h
+++ b/src/nvim/eval/encode.h
@@ -47,7 +47,7 @@ static inline ListReaderState encode_init_lrstate(const list_T *const list)
.offset = 0,
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
? 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)),
};
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 96c483ea75..67da5803d9 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -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]);
rettv->vval.v_string =
- (char *)vim_strsave_shellescape((const char_u *)tv_get_string(&argvars[0]), do_special,
- do_special);
+ vim_strsave_shellescape(tv_get_string(&argvars[0]), do_special, do_special);
rettv->v_type = VAR_STRING;
}
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 25b2a20bac..1de268a9d8 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -2098,7 +2098,7 @@ char **tv_dict_to_env(dict_T *denv)
TV_DICT_ITER(denv, var, {
const char *str = tv_get_string(&var->di_tv);
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);
snprintf(env[i], len, "%s=%s", (char *)var->di_key, str);
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)) {
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
@@ -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) {
new_di = tv_dict_item_alloc((const char *)di->di_key);
} 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);
if (key == NULL) {
new_di = tv_dict_item_alloc_len((const char *)di->di_key, len);
diff --git a/src/nvim/eval/typval_defs.h b/src/nvim/eval/typval_defs.h
index 1c0a438751..f025f21cf7 100644
--- a/src/nvim/eval/typval_defs.h
+++ b/src/nvim/eval/typval_defs.h
@@ -339,7 +339,7 @@ struct ufunc {
funccall_T *uf_scoped; ///< l: local variables for closure
char_u *uf_name_exp; ///< if "uf_name[]" starts with SNR the name with
///< "<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_
///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
};
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 42f78422cb..7f0ac06f60 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -595,7 +595,7 @@ ufunc_T *find_func(const char_u *name)
/// Takes care of script-local function names.
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>");
STRCAT(buf, fp->uf_name + 3);
} 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);
#endif
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_lock = VAR_FIXED;
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");
#endif
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_lock = VAR_UNLOCKED;
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");
#endif
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_lock = VAR_FIXED;
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
// expressions. Add to the l: dict.
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 {
- 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) {
@@ -1318,7 +1318,7 @@ void free_all_functions(void)
// Only free functions that are not refcounted, those are
// supposed to be freed when no longer referenced.
fp = HI2UF(hi);
- if (func_name_refcount(fp->uf_name)) {
+ if (func_name_refcount((char_u *)fp->uf_name)) {
skipped++;
} else {
used = func_hashtab.ht_used;
@@ -1344,7 +1344,7 @@ void free_all_functions(void)
// Only free functions that are not refcounted, those are
// supposed to be freed when no longer referenced.
fp = HI2UF(hi);
- if (func_name_refcount(fp->uf_name)) {
+ if (func_name_refcount((char_u *)fp->uf_name)) {
skipped++;
} else {
func_free(fp);
@@ -1654,7 +1654,7 @@ theend:
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)".
@@ -1970,7 +1970,7 @@ static void list_functions(regmatch_T *regmatch)
if ((fp->uf_flags & FC_DEAD) == 0
&& (regmatch == NULL
? (!message_filtered((char *)fp->uf_name)
- && !func_name_refcount(fp->uf_name))
+ && !func_name_refcount((char_u *)fp->uf_name))
: (!isdigit(*fp->uf_name)
&& vim_regexec(regmatch, (char *)fp->uf_name, 0)))) {
list_func_head(fp, false, false);
@@ -2590,7 +2590,7 @@ void ex_function(exarg_T *eap)
set_ufunc_name(fp, name);
if (overwrite) {
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) {
xfree(fp);
goto erret;
@@ -2718,7 +2718,7 @@ char *get_user_func_name(expand_T *xp, int idx)
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.
}
@@ -2802,7 +2802,7 @@ void ex_delfunction(exarg_T *eap)
// it and the refcount is more than one, it should be kept.
// A numbered function or lambda should be kept if the refcount is
// 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
// do remove it from the hashtable.
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.
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.
@@ -3579,7 +3579,7 @@ bool set_ref_in_functions(int copyID)
if (!HASHITEM_EMPTY(hi)) {
todo--;
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)) {
return true;
}
@@ -3648,5 +3648,5 @@ char_u *register_luafunc(LuaRef ref)
hash_add(&func_hashtab, UF2HIKEY(fp));
// coverity[leaked_storage]
- return fp->uf_name;
+ return (char_u *)fp->uf_name;
}
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index 733bc3ac2d..2d7df6fde9 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -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)
{
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);
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));
STRCPY(v->di_key, varname);
- if (hash_add(ht, v->di_key) == FAIL) {
+ if (hash_add(ht, (char *)v->di_key) == FAIL) {
xfree(v);
return;
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index c405b4f4c1..34144fbdfc 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -825,7 +825,7 @@ void ex_retab(exarg_T *eap)
}
if (ml_replace(lnum, new_line, false) == OK) {
// "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,
(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.
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);
STRCAT(newcmd, prevcmd);
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;
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);
if (os_path_exists(swapname)) {
if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index a2bd6fb43f..85577b8cf3 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -3980,7 +3980,7 @@ void separate_nextcmd(exarg_T *eap)
}
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 {
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);
}
}
@@ -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!
if (src > srcstart && src[-1] == '\\') {
*usedlen = 0;
- STRMOVE(src - 1, src); // remove backslash
+ STRMOVE(src - 1, (char *)src); // remove backslash
return NULL;
}
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 36d58923b0..00fbcabc7e 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -512,7 +512,7 @@ char_u *vim_findfile_stopdir(char_u *buf)
if (r_ptr[0] == '\\' && r_ptr[1] == ';') {
// Overwrite the escape char,
// 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++;
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index 1ebac603c2..e3a5f40492 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -201,15 +201,15 @@ void hash_debug_results(void)
///
/// @return OK if success.
/// 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);
- hashitem_T *hi = hash_lookup(ht, (const char *)key, STRLEN(key), hash);
+ hash_T hash = hash_hash((char_u *)key);
+ hashitem_T *hi = hash_lookup(ht, key, strlen(key), hash);
if (!HASHITEM_EMPTY(hi)) {
internal_error("hash_add()");
return FAIL;
}
- hash_add_item(ht, hi, key, hash);
+ hash_add_item(ht, hi, (char_u *)key, hash);
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) {
ht->ht_filled++;
}
- hi->hi_key = key;
+ hi->hi_key = (char *)key;
hi->hi_hash = hash;
// 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)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
- return HI_KEY_REMOVED;
+ return (char_u *)HI_KEY_REMOVED;
}
diff --git a/src/nvim/hashtab.h b/src/nvim/hashtab.h
index 7740a3e431..28a3b69d44 100644
--- a/src/nvim/hashtab.h
+++ b/src/nvim/hashtab.h
@@ -15,9 +15,9 @@ typedef size_t hash_T;
/// The address of "hash_removed" is used as a magic number
/// 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 \
- || (hi)->hi_key == (char_u *)&hash_removed)
+ || (hi)->hi_key == &hash_removed)
/// Hashtable item.
///
@@ -45,7 +45,7 @@ typedef struct hashitem_S {
/// NULL : Item was never used.
/// HI_KEY_REMOVED : Item was removed.
/// (Any other pointer value) : Item is currently being used.
- char_u *hi_key;
+ char *hi_key;
} hashitem_T;
/// Initial size for a hashtable.
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 0c7ff39197..2e60d6a570 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -590,7 +590,7 @@ void init_highlight(bool both, bool reset)
// Value of g:colors_name could be freed in load_colors() and make
// p invalid, so copy it.
char *copy_p = xstrdup(p);
- bool okay = load_colors((char_u *)copy_p);
+ bool okay = load_colors(copy_p);
xfree(copy_p);
if (okay) {
return;
@@ -638,8 +638,9 @@ void init_highlight(bool both, bool reset)
}
/// 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;
int retval = FAIL;
@@ -653,9 +654,9 @@ int load_colors(char_u *name)
}
recursive = true;
- size_t buflen = STRLEN(name) + 12;
+ size_t buflen = strlen(name) + 12;
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);
retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
if (retval == FAIL) {
@@ -664,7 +665,7 @@ int load_colors(char_u *name)
}
xfree(buf);
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;
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index f6b1b81780..062e073156 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -561,7 +561,7 @@ int set_indent(int size, int flags)
} else {
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
// characters and allocate accordingly. We will fill the rest with spaces
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 0f1159fb94..18f301f96e 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -242,7 +242,7 @@ static const char_u *cin_skipcomment(const char_u *s)
// Perl/shell # comment comment continues until eol. Require a space
// before # to avoid recognizing $#array.
if (curbuf->b_ind_hash_comment != 0 && s != prev_s && *s == '#') {
- s += STRLEN(s);
+ s += strlen((char *)s);
break;
}
if (*s != '/') {
@@ -250,7 +250,7 @@ static const char_u *cin_skipcomment(const char_u *s)
}
s++;
if (*s == '/') { // slash-slash comment continues till eol
- s += STRLEN(s);
+ s += strlen((char *)s);
break;
}
if (*s != '*') {
@@ -697,7 +697,7 @@ static int cin_get_equal_amount(linenr_T lnum)
if (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;
}
}
@@ -750,7 +750,7 @@ static int cin_ispreproc_cont(const char_u **pp, linenr_T *lnump, int *amount)
int retval = false;
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);
}
@@ -764,7 +764,7 @@ static int cin_ispreproc_cont(const char_u **pp, linenr_T *lnump, int *amount)
break;
}
line = (char_u *)ml_get(--lnum);
- if (*line == NUL || line[STRLEN(line) - 1] != '\\') {
+ if (*line == NUL || line[strlen((char *)line) - 1] != '\\') {
break;
}
}
@@ -915,7 +915,7 @@ static int cin_isfuncdecl(const char_u **sp, linenr_T first_lnum, linenr_T min_l
// defined(y)
lnum = first_lnum - 1;
s = (char_u *)ml_get(lnum);
- if (*s == NUL || s[STRLEN(s) - 1] != '\\') {
+ if (*s == NUL || s[strlen((char *)s) - 1] != '\\') {
retval = true;
}
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 *r;
- int len = (int)STRLEN(find);
+ int len = (int)strlen((char *)find);
while (*p != NUL) {
p = cin_skipcomment(p);
if (STRNCMP(p, find, len) == 0) {
r = (char_u *)skipwhite((char *)p + len);
- if (ignore != NULL && STRNCMP(r, ignore, STRLEN(ignore)) == 0) {
- r = (char_u *)skipwhite((char *)r + STRLEN(ignore));
+ if (ignore != NULL && STRNCMP(r, ignore, strlen((char *)ignore)) == 0) {
+ r = (char_u *)skipwhite((char *)r + strlen((char *)ignore));
}
if (cin_nocode(r)) {
return true;
@@ -2897,7 +2897,7 @@ int get_c_indent(void)
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
&& terminated == ',')) {
if (lookfor != LOOKFOR_ENUM_OR_INIT
- && (*skipwhite((char *)l) == '[' || l[STRLEN(l) - 1] == '[')) {
+ && (*skipwhite((char *)l) == '[' || l[strlen((char *)l) - 1] == '[')) {
amount += ind_continuation;
}
// 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 == ',') {
while (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;
}
curwin->w_cursor.lnum--;
@@ -3104,7 +3104,7 @@ int get_c_indent(void)
l = (char_u *)get_cursor_line_ptr();
amount = cur_amount;
- n = (int)STRLEN(l);
+ n = (int)strlen((char *)l);
if (terminated == ','
&& (*skipwhite((char *)l) == ']'
|| (n >= 2 && l[n - 2] == ']'))) {
@@ -3153,7 +3153,7 @@ int get_c_indent(void)
} else {
if (lookfor == LOOKFOR_INITIAL
&& *l != NUL
- && l[STRLEN(l) - 1] == '\\') {
+ && l[strlen((char *)l) - 1] == '\\') {
// XXX
cont_amount = cin_get_equal_amount(curwin->w_cursor.lnum);
}
@@ -3435,7 +3435,7 @@ term_again:
// } foo,
// bar;
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
if (find_last_paren(l, '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
@@ -3449,7 +3449,7 @@ term_again:
// here;
while (n == 0 && 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;
}
curwin->w_cursor.lnum--;
@@ -3535,7 +3535,7 @@ term_again:
if (cin_ends_in(l, (char_u *)";", NULL)) {
l = (char_u *)ml_get(curwin->w_cursor.lnum - 1);
if (cin_ends_in(l, (char_u *)",", NULL)
- || (*l != NUL && l[STRLEN(l) - 1] == '\\')) {
+ || (*l != NUL && l[strlen((char *)l) - 1] == '\\')) {
break;
}
l = (char_u *)get_cursor_line_ptr();
@@ -3567,7 +3567,7 @@ term_again:
// here";
if (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);
if (cur_amount > 0) {
amount = cur_amount;
diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c
index cec8d1e603..90539d5578 100644
--- a/src/nvim/keycodes.c
+++ b/src/nvim/keycodes.c
@@ -889,7 +889,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
size_t dlen = 0;
const char_u *src;
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_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
if ((flags & REPTERM_FROM_PART) && from_len > 1 && src[0] == '#'
&& ascii_isdigit(src[1])) { // function key
- result[dlen++] = K_SPECIAL;
+ result[dlen++] = (char)K_SPECIAL;
result[dlen++] = 'k';
if (src[1] == '0') {
result[dlen++] = ';'; // #0 is F10 is "k;"
} else {
- result[dlen++] = src[1]; // #3 is F3 is "k3"
+ result[dlen++] = (char)src[1]; // #3 is F3 is "k3"
}
src += 2;
}
@@ -931,18 +931,18 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
emsg(_(e_usingsid));
} else {
src += 5;
- result[dlen++] = K_SPECIAL;
- result[dlen++] = KS_EXTRA;
+ result[dlen++] = (char)K_SPECIAL;
+ result[dlen++] = (char)KS_EXTRA;
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);
- dlen += STRLEN(result + dlen);
+ dlen += strlen(result + dlen);
result[dlen++] = '_';
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),
true, did_simplify);
if (slen) {
@@ -952,17 +952,18 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
}
if (do_special) {
- char_u *p, *s, len;
+ char *p, *s;
+ int len;
// Replace <Leader> by the value of "mapleader".
// Replace <LocalLeader> by the value of "maplocalleader".
// If "mapleader" or "maplocalleader" isn't set use a backslash.
if (end - src >= 7 && STRNICMP(src, "<Leader>", 8) == 0) {
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) {
len = 13;
- p = get_var_value("g:maplocalleader");
+ p = (char *)get_var_value("g:maplocalleader");
} else {
len = 0;
p = NULL;
@@ -970,8 +971,8 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
if (len != 0) {
// Allow up to 8 * 6 characters for "mapleader".
- if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) {
- s = (char_u *)"\\";
+ if (p == NULL || *p == NUL || strlen(p) > 8 * 6) {
+ s = "\\";
} else {
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
if (src > end) {
if (flags & REPTERM_FROM_PART) {
- result[dlen++] = key;
+ result[dlen++] = (char)key;
}
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
// KS_SPECIAL KE_FILLER.
if (*src == K_SPECIAL) {
- result[dlen++] = K_SPECIAL;
- result[dlen++] = KS_SPECIAL;
+ result[dlen++] = (char)K_SPECIAL;
+ result[dlen++] = (char)KS_SPECIAL;
result[dlen++] = KE_FILLER;
} else {
- result[dlen++] = *src;
+ result[dlen++] = (char)(*src);
}
src++;
}
diff --git a/src/nvim/linematch.c b/src/nvim/linematch.c
index 2b53fe6bd6..ebedda9b4d 100644
--- a/src/nvim/linematch.c
+++ b/src/nvim/linematch.c
@@ -30,7 +30,7 @@ static size_t line_len(const char *s)
if (end) {
return (size_t)(end - s);
}
- return STRLEN(s);
+ return strlen(s);
}
/// Same as matching_chars but ignore whitespace
diff --git a/src/nvim/match.c b/src/nvim/match.c
index 83d1055fd0..4b6ed0edee 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -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.
-/// Return true if there is such highlighting and set "search_attr" to the
-/// current highlight attribute.
-bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **line,
+///
+/// @return true if there is such highlighting and set "search_attr" to the
+/// 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)
{
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
// 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 == 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.
if (shl->startcol == shl->endcol) {
if ((*line)[shl->endcol] != NUL) {
- shl->endcol += utfc_ptr2len((char *)(*line) + shl->endcol);
+ shl->endcol += utfc_ptr2len(*line + shl->endcol);
} else {
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
/// is endcol.
/// 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,
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
&& col >= shl->startcol
&& 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) {
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
// 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) {
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) {
// highlight empty match, try again after it
- char *p = (char *)(*line) + shl->endcol;
+ char *p = *line + shl->endcol;
if (*p == NUL) {
shl->endcol++;
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 1a30852e72..c7734e45e7 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1987,7 +1987,7 @@ void mb_check_adjust_col(void *win_)
// Column 0 is always valid.
if (oldcol != 0) {
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?
if (len == 0 || oldcol < 0) {
@@ -2127,7 +2127,7 @@ char *enc_canonize(char *enc)
}
// 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 '-'.
p = r;
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;
if (lenp == NULL) {
- len = STRLEN(ptr);
+ len = strlen((char *)ptr);
} else {
len = *lenp;
}
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 6e1316d651..3cdeef4f47 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -187,7 +187,7 @@ struct block0 {
char_u b0_pid[4]; // process id of creator (or 0)
char_u b0_uname[B0_UNAME_SIZE]; // name of user (uid if no name)
char_u b0_hname[B0_HNAME_SIZE]; // host name (if it has a name)
- char_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
int b0_magic_int; // check for byte order of int
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) {
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);
(void)os_get_username((char *)b0p->b0_uname, B0_UNAME_SIZE);
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 "~/"
int retval = os_get_username(uname, B0_UNAME_SIZE);
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) {
STRLCPY(b0p->b0_fname, buf->b_ffname, B0_FNAME_SIZE_CRYPT);
} 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)) {
b0p->b0_flags |= B0_SAME_DIR;
} 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;
int n = (int)strlen(buf->b_p_fenc);
- if ((int)STRLEN(b0p->b0_fname) + n + 1 > size) {
- b0p->b0_flags &= (uint8_t) ~B0_HAS_FENC;
+ if ((int)strlen(b0p->b0_fname) + n + 1 > size) {
+ b0p->b0_flags = (char)(b0p->b0_flags & ~B0_HAS_FENC);
} else {
memmove((char *)b0p->b0_fname + size - n,
buf->b_p_fenc, (size_t)n);
@@ -923,8 +923,8 @@ void ml_recover(bool checkext)
if (b0p->b0_flags & B0_HAS_FENC) {
int fnsize = B0_FNAME_SIZE_NOCRYPT;
- for (p = (char *)b0p->b0_fname + fnsize; (char_u *)p > b0p->b0_fname && p[-1] != NUL; p--) {}
- b0_fenc = xstrnsave(p, (size_t)(b0p->b0_fname + fnsize - (char_u *)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 - p));
}
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);
if (num_names >= 1) { // check if we have the same name twice
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) {
p += i; // file name has been expanded to full path
}
@@ -1822,16 +1822,16 @@ errorret:
DATA_BL *dp = hp->bh_data;
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_flags &= ~ML_LINE_DIRTY;
}
if (will_change) {
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
@@ -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) {
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
@@ -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) {
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)
@@ -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 newfile flag, see above
/// @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,
- int mark)
+static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, bool newfile, int mark)
{
// lnum out of range
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) {
- 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
@@ -2312,7 +2311,7 @@ void ml_add_deleted_len_buf(buf_T *buf, char *ptr, ssize_t len)
if (inhibit_delete_count) {
return;
}
- ssize_t maxlen = (ssize_t)STRLEN(ptr);
+ ssize_t maxlen = (ssize_t)strlen(ptr);
if (len == -1 || 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
ml_flush_line(buf); // flush it
} 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
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);
}
- 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_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++;
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);
if (hp == NULL) {
@@ -2650,7 +2649,7 @@ static void ml_flush_line(buf_T *buf)
} else { // text of previous line follows
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
// 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.
///
/// @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
- char_u fname_buf[MAXPATHL];
+ char fname_buf[MAXPATHL];
// Expand symlink in the file name, so that we put the swap file with the
// actual file instead of with the symlink.
- if (resolve_symlink((char *)fname, (char *)fname_buf) == OK) {
+ if (resolve_symlink(fname, (char *)fname_buf) == OK) {
fname_res = fname_buf;
}
#endif
- int len = (int)STRLEN(dir_name);
+ int len = (int)strlen(dir_name);
- char_u *s = dir_name + len;
- if (after_pathsep((char *)dir_name, (char *)s)
+ char *s = dir_name + len;
+ if (after_pathsep(dir_name, s)
&& len > 1
&& s[-1] == s[-2]) { // Ends with '//', Use Full path
- char_u *r = NULL;
- s = (char_u *)make_percent_swname((char *)dir_name, (char *)fname_res);
+ char *r = NULL;
+ s = make_percent_swname(dir_name, fname_res);
if (s != NULL) {
- r = (char_u *)modname((char *)s, ".swp", false);
+ r = modname(s, ".swp", false);
xfree(s);
}
return r;
}
// 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);
if (r == NULL) { // out of memory
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);
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, ",");
// 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_u *)dir_name);
+ char *fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);
for (;;) {
if (fname == NULL) { // must be out of memory
@@ -3576,7 +3574,7 @@ void ml_setflags(buf_T *buf)
if (hp->bh_bnum == 0) {
b0p = hp->bh_data;
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);
hp->bh_flags |= BH_DIRTY;
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_chunksize[0].mlcs_numlines = 1;
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;
}
diff --git a/src/nvim/memline_defs.h b/src/nvim/memline_defs.h
index 552ec1e3a9..6bb9255909 100644
--- a/src/nvim/memline_defs.h
+++ b/src/nvim/memline_defs.h
@@ -56,7 +56,7 @@ typedef struct memline {
int ml_flags;
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
int ml_line_offset_ff; // fileformat of cached line
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 01f4612026..8116ffa77b 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -923,7 +923,7 @@ char *msg_may_trunc(bool force, char *s)
room = (Rows - cmdline_row - 1) * Columns + sc_col - 1;
if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
- && (int)STRLEN(s) - room > 0) {
+ && (int)strlen(s) - room > 0) {
int size = vim_strsize(s);
// There may be room anyway when there are multibyte chars.
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index f993bf339b..a0f8a3b667 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1911,7 +1911,7 @@ bool add_to_showcmd(int c)
if (*p == ' ') {
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 limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN - 1 : SHOWCMD_COLS;
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);
} else {
// 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);
char *newbuf = xrealloc(buf, strlen(buf) + strlen(p) + 1);
diff --git a/src/nvim/option.c b/src/nvim/option.c
index b78fc7c27a..01ad73005a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -771,7 +771,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
char *s = NULL;
char_u *oldval = NULL; // previous value if *varp
char *newval;
- char_u *origval = NULL;
+ char *origval = NULL;
char_u *origval_l = NULL;
char_u *origval_g = 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
// the global value.
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 {
- origval = oldval;
+ origval = (char *)oldval;
}
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;
}
xfree(oldval);
- if (origval == oldval) {
- origval = *(char_u **)varp;
+ if ((char_u *)origval == oldval) {
+ origval = *(char **)varp;
}
if (origval_l == oldval) {
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
newlen = (unsigned)strlen(arg) + 1;
if (op != OP_NONE) {
- newlen += (unsigned)STRLEN(origval) + 1;
+ newlen += (unsigned)strlen(origval) + 1;
}
newval = xmalloc(newlen);
s = newval;
@@ -947,7 +947,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
xfree(newval);
newlen = (unsigned)strlen(s) + 1;
if (op != OP_NONE) {
- newlen += (unsigned)STRLEN(origval) + 1;
+ newlen += (unsigned)strlen(origval) + 1;
}
newval = xmalloc(newlen);
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
int len = 0;
if (op == OP_REMOVING || (flags & P_NODUP)) {
- len = (int)STRLEN(newval);
- s = find_dup_item((char *)origval, newval, flags);
+ len = (int)strlen(newval);
+ s = find_dup_item(origval, newval, flags);
// do not add if already there
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 (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) {
comma = ((flags & P_COMMA) && *origval != NUL && *newval != NUL);
if (op == OP_ADDING) {
- len = (int)STRLEN(origval);
+ len = (int)strlen(origval);
// Strip a trailing comma, would get 2.
if (comma && len > 1
&& (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) {
// may need to remove a comma
if (flags & P_COMMA) {
- if (s == (char *)origval) {
+ if (s == origval) {
// include comma after string
if (s[len] == ',') {
len++;
@@ -1014,7 +1014,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
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;
// 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_g = (origval_g != NULL) ? xstrdup((char *)origval_g) : NULL;
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 49deb821be..b912020ea5 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1521,7 +1521,7 @@ void simplify_filename(char_u *filename)
// 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.
if (vim_ispathsep(*p)) {
- STRMOVE(p, p + 1); // remove duplicate "/"
+ STRMOVE(p, (char *)p + 1); // remove duplicate "/"
} else if (p[0] == '.'
&& (vim_ispathsep(p[1]) || p[1] == NUL)) {
if (p == start && relative) {
@@ -1539,7 +1539,7 @@ void simplify_filename(char_u *filename)
} else if (p > start) {
p--; // strip preceding path separator
}
- STRMOVE(p, tail);
+ STRMOVE(p, (char *)tail);
}
} else if (p[0] == '.' && p[1] == '.'
&& (vim_ispathsep(p[2]) || p[2] == NUL)) {
@@ -1638,16 +1638,16 @@ void simplify_filename(char_u *filename)
if (p > start && tail[-1] == '.') {
p--;
}
- STRMOVE(p, tail); // strip previous component
+ STRMOVE(p, (char *)tail); // strip previous component
}
components--;
}
} else if (p == start && !relative) { // leading "/.." or "/../"
- STRMOVE(p, tail); // strip ".." or "../"
+ STRMOVE(p, (char *)tail); // strip ".." or "../"
} else {
if (p == start + 2 && p[-2] == '.') { // leading "./../"
- STRMOVE(p - 2, p); // strip leading "./"
+ STRMOVE(p - 2, (char *)p); // strip leading "./"
tail -= 2;
}
p = tail; // skip to char after ".." or "../"
diff --git a/src/nvim/profile.c b/src/nvim/profile.c
index f3a55696aa..b6e2572182 100644
--- a/src/nvim/profile.c
+++ b/src/nvim/profile.c
@@ -444,7 +444,7 @@ static void prof_sort_list(FILE *fd, ufunc_T **sorttab, int st_len, char *title,
fp = sorttab[i];
prof_func_line(fd, fp->uf_tm_count, &fp->uf_tm_total, &fp->uf_tm_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);
} else {
fprintf(fd, " %s()\n", fp->uf_name);
@@ -615,7 +615,7 @@ static void func_dump_profile(FILE *fd)
if (fp->uf_prof_initialized) {
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);
} else {
fprintf(fd, "FUNCTION %s()\n", fp->uf_name);
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index ef168d1d45..b3adccb2f2 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -4242,7 +4242,7 @@ static char *make_get_auname(cmdidx_T cmdidx)
static char *make_get_fullcmd(const char *makecmd, const char *fname)
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) {
len += strlen(p_sp) + strlen(fname) + 3;
}
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 0d3cb927e9..d61a185fcc 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -1228,7 +1228,7 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
linenr_T clnum = start_lnum;
colnr_T ccol = start_col;
int len;
- char_u *p;
+ char *p;
if (bytelen != NULL) {
*bytelen = 0;
@@ -1237,7 +1237,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.
// Slow!
if (rex.line != reg_tofree) {
- len = (int)STRLEN(rex.line);
+ len = (int)strlen((char *)rex.line);
if (reg_tofree == NULL || len >= (int)reg_tofreelen) {
len += 50; // get some extra
xfree(reg_tofree);
@@ -1250,16 +1250,16 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e
}
// Get the line to compare with.
- p = reg_getline(clnum);
+ p = (char *)reg_getline(clnum);
assert(p);
if (clnum == end_lnum) {
len = end_col - ccol;
} 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
}
if (bytelen != NULL) {
@@ -1651,7 +1651,7 @@ int vim_regsub(regmatch_T *rmp, char_u *source, typval_T *expr, char_u *dest, in
rex.reg_maxline = 0;
rex.reg_buf = curbuf;
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;
if (rex_in_use) {
@@ -1679,7 +1679,7 @@ int vim_regsub_multi(regmmatch_T *rmp, linenr_T lnum, char_u *source, char_u *de
rex.reg_firstlnum = lnum;
rex.reg_maxline = curbuf->b_ml.ml_line_count - lnum;
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;
if (rex_in_use) {
@@ -1702,11 +1702,11 @@ void free_resub_eval_result(void)
}
#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_u *dst;
- char_u *s;
+ char *src;
+ char *dst;
+ char *s;
int c;
int cc;
int no = -1;
@@ -1782,14 +1782,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_evaluate = true;
if (expr->v_type == VAR_FUNC) {
- s = (char_u *)expr->vval.v_string;
- call_func((char *)s, -1, &rettv, 1, argv, &funcexe);
+ s = expr->vval.v_string;
+ call_func(s, -1, &rettv, 1, argv, &funcexe);
} else if (expr->v_type == VAR_PARTIAL) {
partial_T *partial = expr->vval.v_partial;
- s = (char_u *)partial_name(partial);
+ s = partial_name(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) {
// fill_submatch_list() was called.
@@ -1807,14 +1807,14 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
}
tv_clear(&rettv);
} else {
- eval_result[nested] = eval_to_string((char *)source + 2, NULL, true);
+ eval_result[nested] = eval_to_string(source + 2, NULL, true);
}
nesting--;
if (eval_result[nested] != NULL) {
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,
// unless called from vim_regexec_nl().
// Skip over a backslashed character.
@@ -1835,9 +1835,9 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
}
if (had_backslash && (flags & REGSUB_BACKSLASH)) {
// 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]);
- eval_result[nested] = (char *)s;
+ eval_result[nested] = s;
}
dst += strlen(eval_result[nested]);
@@ -1849,7 +1849,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
}
}
} else {
- while ((c = *src++) != NUL) {
+ while ((c = (uint8_t)(*src++)) != NUL) {
if (c == '&' && (flags & REGSUB_MAGIC)) {
no = 0;
} else if (c == '\\' && *src != NUL) {
@@ -1887,7 +1887,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
iemsg("vim_regsub_both(): not enough space");
return 0;
}
- *dst++ = (char_u)c;
+ *dst++ = (char)c;
*dst++ = *src++;
*dst++ = *src++;
} else {
@@ -1924,10 +1924,10 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
}
dst++;
}
- c = *src++;
+ c = (uint8_t)(*src++);
}
} else {
- c = utf_ptr2char((char *)src - 1);
+ c = utf_ptr2char(src - 1);
}
// Write to buffer, if copy is set.
if (func_one != NULL) {
@@ -1939,7 +1939,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
cc = c;
}
- int totlen = utfc_ptr2len((char *)src - 1);
+ int totlen = utfc_ptr2len(src - 1);
int charlen = utf_char2len(cc);
if (copy) {
@@ -1947,10 +1947,10 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
iemsg("vim_regsub_both(): not enough space");
return 0;
}
- utf_char2bytes(cc, (char *)dst);
+ utf_char2bytes(cc, dst);
}
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
// are composing characters; copy them as-is.
@@ -1972,20 +1972,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) {
s = NULL;
} 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) {
len = rex.reg_mmatch->endpos[no].col
- rex.reg_mmatch->startpos[no].col;
} else {
- len = (int)STRLEN(s);
+ len = (int)strlen(s);
}
}
} else {
- s = (char_u *)rex.reg_match->startp[no];
+ s = rex.reg_match->startp[no];
if (rex.reg_match->endp[no] == NULL) {
s = NULL;
} else {
- len = (int)(rex.reg_match->endp[no] - (char *)s);
+ len = (int)(rex.reg_match->endp[no] - s);
}
}
if (s != NULL) {
@@ -2003,11 +2003,11 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
*dst = CAR;
}
dst++;
- s = reg_getline(++clnum);
+ s = (char *)reg_getline(++clnum);
if (rex.reg_mmatch->endpos[no].lnum == clnum) {
len = rex.reg_mmatch->endpos[no].col;
} else {
- len = (int)STRLEN(s);
+ len = (int)strlen(s);
}
} else {
break;
@@ -2033,7 +2033,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
}
dst += 2;
} else {
- c = utf_ptr2char((char *)s);
+ c = utf_ptr2char(s);
if (func_one != (fptr_T)NULL) {
// Turbo C complains without the typecast
@@ -2051,7 +2051,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
// Copy composing characters separately, one
// at a time.
- l = utf_ptr2len((char *)s) - 1;
+ l = utf_ptr2len(s) - 1;
s += l;
len -= l;
@@ -2061,7 +2061,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int des
iemsg("vim_regsub_both(): not enough space");
return 0;
}
- utf_char2bytes(cc, (char *)dst);
+ utf_char2bytes(cc, dst);
}
dst += charlen - 1;
}
diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c
index 9411d17f57..19b89bef74 100644
--- a/src/nvim/regexp_bt.c
+++ b/src/nvim/regexp_bt.c
@@ -2928,9 +2928,9 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
longest = NULL;
len = 0;
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);
- len = (int)STRLEN(OPERAND(scan));
+ len = (int)strlen((char *)OPERAND(scan));
}
}
r->regmust = longest;
@@ -3658,7 +3658,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
pos = &fm->mark;
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
&& 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;
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
} else {
// 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) {
status = RA_NOMATCH;
}
@@ -4257,7 +4257,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
no = op - ZREF;
if (re_extmatch_in != 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) {
status = RA_NOMATCH;
} else {
@@ -4683,7 +4683,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
if (limit > 0
&& ((rp->rs_un.regsave.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)
- rp->rs_un.regsave.rs_u.pos.col >= limit)) {
no = FAIL;
@@ -4696,7 +4696,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
} else {
reg_restore(&rp->rs_un.regsave, &backpos);
rp->rs_un.regsave.rs_u.pos.col =
- (colnr_T)STRLEN(rex.line);
+ (colnr_T)strlen((char *)rex.line);
}
} else {
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) {
break;
}
- rex.input = rex.line + STRLEN(rex.line);
+ rex.input = rex.line + strlen((char *)rex.line);
fast_breakcheck();
} else {
MB_PTR_BACK(rex.line, rex.input);
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index e379af16ca..7361b31456 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -361,7 +361,7 @@ static void nfa_regcomp_start(char_u *expr, int re_flags)
nstate = 0;
istate = 0;
// 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.
// 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;
}
- 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) {
*bytelen = len;
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.input = rex.line;
} else {
- rex.input = rex.line + STRLEN(rex.line);
+ rex.input = rex.line + strlen((char *)rex.line);
}
}
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;
const colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
&& 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;
result = pos->lnum == rex.lnum + rex.reg_firstlnum
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 8fafe4b6b9..659e34f27a 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -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)
{
estack_T *entry = estack_push(ETYPE_UFUNC,
- (char *)(ufunc->uf_name_exp != NULL
- ? ufunc->uf_name_exp : ufunc->uf_name),
+ ufunc->uf_name_exp != NULL ? (char *)ufunc->uf_name_exp : ufunc->uf_name,
lnum);
if (entry != NULL) {
entry->es_info.ufunc = ufunc;
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index e6d2eac7c3..f91ac0f347 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -137,7 +137,7 @@ typedef struct matchinf_S {
// mi_capflags
// 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
// 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);
}
- (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);
- mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
+ mi.mi_fwordlen = (int)strlen(mi.mi_fword);
if (camel_case && mi.mi_fwordlen > 0) {
// 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);
if (mi.mi_lp->lp_slang->sl_fidxs != NULL) {
p = mi.mi_word;
- fp = mi.mi_fword;
+ fp = (char_u *)mi.mi_fword;
for (;;) {
MB_PTR_ADV(p);
MB_PTR_ADV(fp);
if (p >= mi.mi_end) {
break;
}
- mi.mi_compoff = (int)(fp - mi.mi_fword);
+ mi.mi_compoff = (int)(fp - (char_u *)mi.mi_fword);
find_word(&mi, FIND_COMPOUND);
if (mi.mi_result != SP_BAD) {
mi.mi_end = p;
@@ -453,7 +453,7 @@ static void find_word(matchinf_T *mip, int mode)
}
} else {
// 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
byts = slang->sl_fbyts;
idxs = slang->sl_fidxs;
@@ -749,7 +749,7 @@ static void find_word(matchinf_T *mip, int mode)
STRLCPY(fword, ptr, endlen[endidxcnt] + 1);
}
}
- if (!can_compound(slang, fword, mip->mi_compflags)) {
+ if (!can_compound(slang, (char *)fword, mip->mi_compflags)) {
continue;
}
} 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
// folding case. This can be slow, take a shortcut when
// 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) {
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
MB_PTR_ADV(p);
}
- mip->mi_compoff = (int)(p - mip->mi_fword);
+ mip->mi_compoff = (int)(p - (char_u *)mip->mi_fword);
}
}
#if 0
@@ -925,9 +925,9 @@ bool match_checkcompoundpattern(char_u *ptr, int wlen, garray_T *gap)
return false;
}
-// Returns true if "flags" is a valid sequence of compound flags and "word"
-// does not have too many syllables.
-bool can_compound(slang_T *slang, const char_u *word, const char_u *flags)
+/// @return true if "flags" is a valid sequence of compound flags and "word"
+/// does not have too many syllables.
+bool can_compound(slang_T *slang, const char *word, const uint8_t *flags)
FUNC_ATTR_NONNULL_ALL
{
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
// COMPOUNDWORDMAX then compounding is not allowed.
if (slang->sl_compsylmax < MAXWLEN
- && count_syllables(slang, word) > slang->sl_compsylmax) {
- return (int)STRLEN(flags) < slang->sl_compmax;
+ && count_syllables(slang, (char_u *)word) > slang->sl_compsylmax) {
+ return (int)strlen((char *)flags) < slang->sl_compmax;
}
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
// 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
if (mode == FIND_COMPOUND) {
// 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.
- 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);
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),
- mip->mi_fword + mip->mi_fwordlen,
+ (char_u *)mip->mi_fword + 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;
return flen;
}
@@ -2600,7 +2600,7 @@ void ex_spellrepall(exarg_T *eap)
char *line = get_cursor_line_ptr();
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
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);
STRCPY(p + curwin->w_cursor.col, repl_to);
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)) {
// soundfold the word
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);
}
}
@@ -2746,23 +2746,23 @@ char *eval_soundfold(const char *const word)
/// @param[in] inword word to soundfold
/// @param[in] folded whether inword is already case-folded
/// @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) {
// SOFOFROM and SOFOTO used
- spell_soundfold_sofo(slang, inword, res);
+ spell_soundfold_sofo(slang, (char_u *)inword, (char_u *)res);
} else {
- char_u fword[MAXWLEN];
- char_u *word;
+ char fword[MAXWLEN];
+ char *word;
// SAL items used. Requires the word to be case-folded.
if (folded) {
word = inword;
} 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;
}
- 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) {
dumpflags |= DUMPFLAG_ONECAP;
} else if (n == WF_ALLCAP
- && (int)STRLEN(pat) > utfc_ptr2len(pat)) {
+ && (int)strlen(pat) > utfc_ptr2len(pat)) {
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.
c = (int)((unsigned)flags >> 24);
if (c == 0 || curi[depth] == 2) {
- dump_word(slang, (char_u *)word, (char_u *)pat, dir,
- dumpflags, flags, lnum);
+ dump_word(slang, word, pat, dir, dumpflags, flags, lnum);
if (pat == NULL) {
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.
-// 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,
+/// Dumps one word: apply case modifications and append a line to the buffer.
+/// When "lnum" is zero add insert mode completion.
+static void dump_word(slang_T *slang, char *word, char *pat, Direction *dir, int dumpflags,
int wordflags, linenr_T lnum)
{
bool keepcap = false;
- char_u *p;
- char_u cword[MAXWLEN];
- char_u badword[MAXWLEN + 10];
+ char *p;
+ char cword[MAXWLEN];
+ char badword[MAXWLEN + 10];
int flags = wordflags;
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) {
// 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;
} else {
p = word;
if ((dumpflags & DUMPFLAG_KEEPCASE)
- && ((captype(word, NULL) & WF_KEEPCAP) == 0
+ && ((captype((char_u *)word, NULL) & WF_KEEPCAP) == 0
|| (flags & WF_FIXCAP) != 0)) {
keepcap = true;
}
}
- char_u *tw = p;
+ char *tw = p;
if (pat == NULL) {
// 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) {
for (int i = 0; i < 7; i++) {
if (flags & (0x10000 << i)) {
- const size_t badword_len = STRLEN(badword);
- snprintf((char *)badword + badword_len,
+ const size_t badword_len = strlen(badword);
+ snprintf(badword + badword_len,
sizeof(badword) - badword_len,
"%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;
// 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)) {
vim_snprintf((char *)IObuff, IOSIZE, "%s\t%d",
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)
- ? mb_strnicmp((char *)p, (char *)pat, STRLEN(pat)) == 0
- : STRNCMP(p, pat, STRLEN(pat)) == 0)
- && ins_compl_add_infercase(p, (int)STRLEN(p),
+ ? mb_strnicmp(p, pat, strlen(pat)) == 0
+ : STRNCMP(p, pat, strlen(pat)) == 0)
+ && ins_compl_add_infercase((char_u *)p, (int)strlen(p),
p_ic, NULL, *dir, false) == OK) {
// if dir was BACKWARD then honor it just once
*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);
if (c != 0) {
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);
if (lnum != 0) {
lnum++;
@@ -3503,7 +3502,7 @@ static linenr_T dump_prefixes(slang_T *slang, char_u *word, char_u *pat, Directi
true);
if (c != 0) {
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);
if (lnum != 0) {
lnum++;
diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h
index 2c4aebe420..1484d8cef2 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -72,8 +72,8 @@ typedef int idx_T;
// si_repsal, sl_rep, and si_sal. Not for sl_sal!
// One replacement: from "ft_from" to "ft_to".
typedef struct fromto_S {
- char_u *ft_from;
- char_u *ft_to;
+ uint8_t *ft_from;
+ uint8_t *ft_to;
} fromto_T;
// Info from "SAL" entries in ".aff" file used in sl_sal.
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 1b338ef4bf..48c3cd11e2 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -365,8 +365,8 @@ typedef struct affentry_S affentry_T;
// Affix entry from ".aff" file. Used for prefixes and suffixes.
struct affentry_S {
affentry_T *ae_next; // next affix with same name/number
- char_u *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_chop; // text to chop off 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_cond; // condition (NULL for ".")
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_verbose; // verbose messages
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
// are no regions)
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_repsal; // list of fromto_T entries from REPSAL lines
garray_T si_sal; // list of fromto_T entries from SAL lines
- char_u *si_sofofr; // SOFOFROM text
- char_u *si_sofoto; // SOFOTO text
+ char *si_sofofr; // SOFOFROM text
+ char *si_sofoto; // SOFOTO text
int si_nosugfile; // NOSUGFILE item found
int si_nosplitsugs; // NOSPLITSUGS item found
int si_nocompoundsugs; // NOCOMPOUNDSUGS item found
@@ -504,16 +504,16 @@ typedef struct spellinfo_S {
time_t si_sugtime; // timestamp for .sug file
int si_rem_accents; // soundsalike: remove accents
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_compminlen; // minimal length for compounding
int si_compsylmax; // max nr of syllables for compounding
int si_compoptions; // COMP_ flags
garray_T si_comppat; // CHECKCOMPOUNDPATTERN items, each stored as
// 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_syllable; // syllable string
+ char *si_syllable; // syllable string
garray_T si_prefcond; // table with conditions for postponed
// prefixes, each stored as a string
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;
hashitem_T *hi;
int l;
- int compminlen = 0; // COMPOUNDMIN value
- int compsylmax = 0; // COMPOUNDSYLMAX value
- int compoptions = 0; // COMP_ flags
- int compmax = 0; // COMPOUNDWORDMAX value
- char_u *compflags = NULL; // COMPOUNDFLAG and COMPOUNDRULE
+ int compminlen = 0; // COMPOUNDMIN value
+ int compsylmax = 0; // COMPOUNDSYLMAX value
+ int compoptions = 0; // COMP_ flags
+ int compmax = 0; // COMPOUNDWORDMAX value
+ char *compflags = NULL; // COMPOUNDFLAG and COMPOUNDRULE
// concatenated
char_u *midword = NULL; // MIDWORD 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) {
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[1]) + 3, false);
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, " ");
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) {
- 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)) {
// 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
@@ -2253,7 +2253,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
p = getroom(spin, strlen(items[1]) + 2, false);
STRCPY(p, items[1]);
STRCAT(p, "+");
- compflags = (char_u *)p;
+ compflags = p;
} else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2)) {
// We don't use the count, but do check that it's a number and
// 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.
l = (int)strlen(items[1]) + 1;
if (compflags != NULL) {
- l += (int)STRLEN(compflags) + 1;
+ l += (int)strlen(compflags) + 1;
}
p = getroom(spin, (size_t)l, false);
if (compflags != NULL) {
@@ -2276,7 +2276,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
STRCAT(p, "/");
}
STRCAT(p, items[1]);
- compflags = (char_u *)p;
+ compflags = p;
}
} else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
&& compmax == 0) {
@@ -2325,12 +2325,12 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
}
if (i >= gap->ga_len) {
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, (char_u *)items[2]);
+ ((char **)(gap->ga_data))[gap->ga_len++] = getroom_save(spin, items[1]);
+ ((char **)(gap->ga_data))[gap->ga_len++] = getroom_save(spin, items[2]);
}
} else if (is_aff_rule(items, itemcnt, "SYLLABLE", 2)
&& 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)) {
spin->si_nobreak = true;
} 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]);
}
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');
}
@@ -2463,13 +2463,13 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
aff_entry = getroom(spin, sizeof(*aff_entry), true);
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) {
- 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
- 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) {
*aff_entry->ae_flags++ = NUL;
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
// "spin->si_ascii" is true.
- if (!spin->si_ascii || !(has_non_ascii(aff_entry->ae_chop)
- || has_non_ascii(aff_entry->ae_add))) {
+ if (!spin->si_ascii || !(has_non_ascii((char_u *)aff_entry->ae_chop)
+ || has_non_ascii((char_u *)aff_entry->ae_add))) {
aff_entry->ae_next = cur_aff->ah_first;
cur_aff->ah_first = aff_entry;
if (strcmp(items[4], ".") != 0) {
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') {
sprintf((char *)buf, "^%s", items[4]); // NOLINT(runtime/printf)
} 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.
if (aff_entry->ae_chop != 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) {
int c, c_up;
- c = utf_ptr2char((char *)aff_entry->ae_chop);
+ c = utf_ptr2char(aff_entry->ae_chop);
c_up = SPELL_TOUPPER(c);
if (c_up != c
&& (aff_entry->ae_cond == NULL
|| utf_ptr2char((char *)aff_entry->ae_cond) == c)) {
- p = (char *)aff_entry->ae_add
- + STRLEN(aff_entry->ae_add);
+ p = aff_entry->ae_add + strlen(aff_entry->ae_add);
MB_PTR_BACK(aff_entry->ae_add, p);
if (utf_ptr2char(p) == c_up) {
upper = true;
@@ -2535,7 +2534,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
if (aff_entry->ae_cond != NULL) {
char_u buf[MAXLINELEN];
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) {
sprintf((char *)buf, "^%s", aff_entry->ae_cond); // NOLINT(runtime/printf)
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;
pp = GA_APPEND_VIA_PTR(char_u *, &spin->si_prefcond);
*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.
if (aff_entry->ae_add == NULL) {
p = "";
} else {
- p = (char *)aff_entry->ae_add;
+ p = aff_entry->ae_add;
}
// 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'
? &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)) {
// 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]);
} else {
// when "to" is "_" it means empty
- add_fromto(spin, &spin->si_sal, (char_u *)items[1],
- strcmp(items[2], "_") == 0 ? (char_u *)""
- : (char_u *)items[2]);
+ add_fromto(spin, &spin->si_sal, items[1],
+ strcmp(items[2], "_") == 0 ? ""
+ : items[2]);
}
}
} else if (is_aff_rule(items, itemcnt, "SOFOFROM", 2)
&& 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)
&& 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) {
int i;
for (i = 1; i < itemcnt; i++) {
if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, (char *)items[i]))) {
p = xstrdup(items[i]);
- hash_add(&spin->si_commonwords, (char_u *)p);
+ hash_add(&spin->si_commonwords, p);
}
}
} else {
@@ -2762,8 +2761,8 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
}
if (syllable != NULL) {
- aff_check_string((char *)spin->si_syllable, (char *)syllable, "SYLLABLE");
- spin->si_syllable = syllable;
+ aff_check_string(spin->si_syllable, (char *)syllable, "SYLLABLE");
+ spin->si_syllable = (char *)syllable;
}
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)) {
smsg(_("Both SAL and SOFO lines in %s"), fname);
} else {
- aff_check_string((char *)spin->si_sofofr, (char *)sofofrom, "SOFOFROM");
- aff_check_string((char *)spin->si_sofoto, (char *)sofoto, "SOFOTO");
- spin->si_sofofr = sofofrom;
- spin->si_sofoto = sofoto;
+ aff_check_string(spin->si_sofofr, (char *)sofofrom, "SOFOFROM");
+ aff_check_string(spin->si_sofoto, (char *)sofoto, "SOFOTO");
+ spin->si_sofofr = (char *)sofofrom;
+ spin->si_sofoto = (char *)sofoto;
}
}
if (midword != NULL) {
- aff_check_string((char *)spin->si_midword, (char *)midword, "MIDWORD");
- spin->si_midword = midword;
+ aff_check_string(spin->si_midword, (char *)midword, "MIDWORD");
+ spin->si_midword = (char *)midword;
}
xfree(pc);
@@ -2813,7 +2812,7 @@ static void aff_process_flags(afffile_T *affile, affentry_T *entry)
prevp = p;
flag = get_affitem(affile->af_flagtype, &p);
if (flag == affile->af_comppermit || flag == affile->af_compforbid) {
- STRMOVE(prevp, p);
+ STRMOVE(prevp, (char *)p);
p = prevp;
if (flag == affile->af_comppermit) {
entry->ae_comppermit = true;
@@ -2896,13 +2895,13 @@ static unsigned get_affitem(int flagtype, char_u **pp)
return (unsigned)res;
}
-// Process the "compflags" string used in an affix file and append it to
-// spin->si_compflags.
-// The processing involves changing the affix names to ID numbers, so that
-// they fit in one byte.
-static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compflags)
+/// Process the "compflags" string used in an affix file and append it to
+/// spin->si_compflags.
+/// The processing involves changing the affix names to ID numbers, so that
+/// they fit in one byte.
+static void process_compflags(spellinfo_T *spin, afffile_T *aff, char *compflags)
{
- char_u *p;
+ char *p;
char_u *prevp;
unsigned flag;
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
// between. Processing it makes it shorter, but we don't know by how
// much, thus allocate the maximum.
- len = (int)STRLEN(compflags) + 1;
+ len = (int)strlen(compflags) + 1;
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);
if (spin->si_compflags != NULL) {
@@ -2925,20 +2924,20 @@ static void process_compflags(spellinfo_T *spin, afffile_T *aff, char_u *compfla
STRCAT(p, "/");
}
spin->si_compflags = p;
- tp = p + STRLEN(p);
+ tp = (char_u *)p + strlen(p);
for (p = compflags; *p != NUL;) {
if (vim_strchr("/?*+[]", *p) != NULL) {
// Copy non-flag characters directly.
- *tp++ = *p++;
+ *tp++ = (char_u)(*p++);
} else {
// First get the flag number, also checks validity.
- prevp = p;
- flag = get_affitem(aff->af_flagtype, &p);
+ prevp = (char_u *)p;
+ flag = get_affitem(aff->af_flagtype, (char_u **)&p);
if (flag != 0) {
// Find the flag in the hashtable. If it was used before, use
// 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);
if (!HASHITEM_EMPTY(hi)) {
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--;
} while (vim_strchr("/?*+[]\\-^", id) != NULL);
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;
}
@@ -3050,17 +3049,17 @@ static bool str_equal(char *s1, char *s2)
return strcmp(s1, s2) == 0;
}
-// Add a from-to item to "gap". Used for REP and SAL items.
-// They are stored case-folded.
-static void add_fromto(spellinfo_T *spin, garray_T *gap, char_u *from, char_u *to)
+/// Add a from-to item to "gap". Used for REP and SAL items.
+/// They are stored case-folded.
+static void add_fromto(spellinfo_T *spin, garray_T *gap, char *from, char *to)
{
char_u word[MAXWLEN];
fromto_T *ftp = GA_APPEND_VIA_PTR(fromto_T, gap);
- (void)spell_casefold(curwin, from, (int)STRLEN(from), word, MAXWLEN);
- ftp->ft_from = (char_u *)getroom_save(spin, word);
- (void)spell_casefold(curwin, to, (int)STRLEN(to), word, MAXWLEN);
- ftp->ft_to = (char_u *)getroom_save(spin, word);
+ (void)spell_casefold(curwin, (char_u *)from, (int)strlen(from), word, MAXWLEN);
+ ftp->ft_from = (char_u *)getroom_save(spin, (char *)word);
+ (void)spell_casefold(curwin, (char_u *)to, (int)strlen(to), word, MAXWLEN);
+ ftp->ft_to = (char_u *)getroom_save(spin, (char *)word);
}
/// 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)
{
hashtab_T ht;
- char_u line[MAXLINELEN];
+ char line[MAXLINELEN];
char_u *p;
char_u *afflist;
char_u store_afflist[MAXWLEN];
int pfxlen;
bool need_affix;
- char_u *dw;
+ char *dw;
char_u *pc;
char_u *w;
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
// 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] <= ' ') {
l--;
}
@@ -3181,7 +3180,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
w = pc;
} else {
pc = NULL;
- w = line;
+ w = (char_u *)line;
}
// 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;
for (p = w; *p != NUL; MB_PTR_ADV(p)) {
if (*p == '\\' && (p[1] == '\\' || p[1] == '/')) {
- STRMOVE(p, p + 1);
+ STRMOVE(p, (char *)p + 1);
} else if (*p == '/') {
*p = NUL;
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.
- dw = (char_u *)getroom_save(spin, w);
+ dw = getroom_save(spin, (char *)w);
if (dw == NULL) {
retval = FAIL;
xfree(pc);
break;
}
- hash = hash_hash(dw);
- hi = hash_lookup(&ht, (const char *)dw, STRLEN(dw), hash);
+ hash = hash_hash((char_u *)dw);
+ hi = hash_lookup(&ht, (const char *)dw, strlen(dw), hash);
if (!HASHITEM_EMPTY(hi)) {
if (p_verbose > 0) {
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++;
} else {
- hash_add_item(&ht, hi, dw, hash);
+ hash_add_item(&ht, hi, (char_u *)dw, hash);
}
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
///
/// @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,
int pfxlen)
{
@@ -3435,7 +3434,7 @@ static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afff
hashitem_T *hi;
affheader_T *ah;
affentry_T *ae;
- char_u newword[MAXWLEN];
+ char newword[MAXWLEN];
int retval = OK;
int i, j;
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;
char_u store_afflist[MAXWLEN];
char_u pfx_pfxlist[MAXWLEN];
- size_t wordlen = STRLEN(word);
+ size_t wordlen = strlen(word);
int use_condit;
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_flags != NULL)
&& (ae->ae_chop == NULL
- || STRLEN(ae->ae_chop) < wordlen)
+ || strlen(ae->ae_chop) < wordlen)
&& (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_AFF) == 0
|| ae->ae_flags == NULL
@@ -3491,10 +3490,10 @@ static int store_aff_word(spellinfo_T *spin, char_u *word, char_u *afflist, afff
} else {
STRLCPY(newword, ae->ae_add, MAXWLEN);
}
- p = word;
+ p = (char_u *)word;
if (ae->ae_chop != NULL) {
// Skip chop string.
- i = mb_charlen(ae->ae_chop);
+ i = mb_charlen((char_u *)ae->ae_chop);
for (; i > 0; i--) {
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);
if (ae->ae_chop != NULL) {
// Remove chop string.
- p = newword + STRLEN(newword);
- i = mb_charlen(ae->ae_chop);
+ p = (char_u *)newword + strlen(newword);
+ i = mb_charlen((char_u *)ae->ae_chop);
for (; i > 0; i--) {
MB_PTR_BACK(newword, p);
}
@@ -3674,8 +3673,8 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
{
FILE *fd;
long lnum = 0;
- char_u rline[MAXLINELEN];
- char_u *line;
+ char rline[MAXLINELEN];
+ char *line;
char_u *pc = NULL;
char_u *p;
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.
- l = (int)STRLEN(rline);
- while (l > 0 && rline[l - 1] <= ' ') {
+ l = (int)strlen(rline);
+ while (l > 0 && (uint8_t)rline[l - 1] <= ' ') {
l--;
}
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.
xfree(pc);
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) {
smsg(_("Conversion failure for word in %s line %ld: %s"),
fname, lnum, rline);
continue;
}
- line = pc;
+ line = (char *)pc;
} else {
pc = NULL;
line = rline;
@@ -3744,7 +3743,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
// Setup for conversion to 'encoding'.
line += 9;
- enc = enc_canonize((char *)line);
+ enc = enc_canonize(line);
if (!spin->si_ascii
&& convert_setup(&spin->si_conv, enc, p_enc) == FAIL) {
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);
} else {
line += 8;
- if (STRLEN(line) > MAXREGIONS * 2) {
+ if (strlen(line) > MAXREGIONS * 2) {
smsg(_("Too many regions in %s line %ld: %s"),
fname, lnum, line);
} else {
- spin->si_region_count = (int)STRLEN(line) / 2;
+ spin->si_region_count = (int)strlen(line) / 2;
STRCPY(spin->si_region_name, line);
// 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;
// Check for flags and region after a slash.
- p = (char_u *)vim_strchr((char *)line, '/');
+ p = (char_u *)vim_strchr(line, '/');
if (p != NULL) {
*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.
- if (spin->si_ascii && has_non_ascii(line)) {
+ if (spin->si_ascii && has_non_ascii((char_u *)line)) {
non_ascii++;
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().
///
/// @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);
}
@@ -3936,20 +3935,20 @@ static bool valid_spell_word(const char *word, const char *end)
/// @param region supported region(s)
/// @param pfxlist list of prefix ids or null
/// @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)
{
- int len = (int)STRLEN(word);
- int ct = captype(word, word + len);
+ int len = (int)strlen(word);
+ int ct = captype((char_u *)word, (char_u *)word + len);
char_u foldword[MAXWLEN];
int res = OK;
// 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;
}
- (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++) {
if (!need_affix || (p != NULL && *p != NUL)) {
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))) {
for (const char_u *p = pfxlist; res == OK; p++) {
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);
}
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.
hash = hash_hash(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)) {
// There are children we encountered before with a hash value
// 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) {
putc(SN_INFO, fd); // <sectionID>
putc(0, fd); // <sectionflags>
- size_t i = STRLEN(spin->si_info);
+ size_t i = strlen(spin->si_info);
put_bytes(fd, i, 4); // <sectionlen>
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(SNF_REQUIRED, fd); // <sectionflags>
- size_t i = STRLEN(spin->si_midword);
+ size_t i = strlen(spin->si_midword);
put_bytes(fd, i, 4); // <sectionlen>
fwv &= fwrite(spin->si_midword, i, 1, fd);
// <midword>
@@ -4517,8 +4516,8 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
assert(gap->ga_len >= 0);
for (size_t i = 0; i < (size_t)gap->ga_len; i++) {
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
- l += 1 + STRLEN(ftp->ft_from); // count <*fromlen> and <*from>
- l += 1 + STRLEN(ftp->ft_to); // count <*tolen> and <*to>
+ l += 1 + strlen((char *)ftp->ft_from); // count <*fromlen> and <*from>
+ l += 1 + strlen((char *)ftp->ft_to); // count <*tolen> and <*to>
}
if (round == 2) {
l++; // count <salflags>
@@ -4545,8 +4544,8 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
// <sal> : <salfromlen> <salfrom> <saltolen> <salto>
fromto_T *ftp = &((fromto_T *)gap->ga_data)[i];
for (unsigned int rr = 1; rr <= 2; rr++) {
- char_u *p = rr == 1 ? ftp->ft_from : ftp->ft_to;
- l = STRLEN(p);
+ char *p = rr == 1 ? (char *)ftp->ft_from : (char *)ftp->ft_to;
+ l = strlen(p);
assert(l < INT_MAX);
putc((int)l, fd);
if (l > 0) {
@@ -4562,13 +4561,13 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
putc(SN_SOFO, fd); // <sectionID>
putc(0, fd); // <sectionflags>
- size_t l = STRLEN(spin->si_sofofr);
- put_bytes(fd, l + STRLEN(spin->si_sofoto) + 4, 4); // <sectionlen>
+ size_t l = strlen(spin->si_sofofr);
+ put_bytes(fd, l + strlen(spin->si_sofoto) + 4, 4); // <sectionlen>
put_bytes(fd, l, 2); // <sofofromlen>
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>
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;
for (hi = spin->si_commonwords.ht_array; todo > 0; hi++) {
if (!HASHITEM_EMPTY(hi)) {
- size_t l = STRLEN(hi->hi_key) + 1;
+ size_t l = strlen(hi->hi_key) + 1;
len += l;
if (round == 2) { // <word>
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(0, fd); // <sectionflags>
- size_t l = STRLEN(spin->si_compflags);
+ size_t l = strlen(spin->si_compflags);
assert(spin->si_comppat.ga_len >= 0);
for (size_t i = 0; i < (size_t)spin->si_comppat.ga_len; i++) {
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>
}
// <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
@@ -4694,7 +4693,7 @@ static int write_vim_spell(spellinfo_T *spin, char *fname)
putc(SN_SYLLABLE, fd); // <sectionID>
putc(0, fd); // <sectionflags>
- size_t l = STRLEN(spin->si_syllable);
+ size_t l = strlen(spin->si_syllable);
put_bytes(fd, l, 4); // <sectionlen>
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".
static void spell_make_sugfile(spellinfo_T *spin, char *wfname)
{
- char_u *fname = NULL;
+ char *fname = NULL;
int len;
slang_T *slang;
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".
fname = xmalloc(MAXPATHL);
STRLCPY(fname, wfname, MAXPATHL);
- len = (int)STRLEN(fname);
+ len = (int)strlen(fname);
fname[len - 2] = 'u';
fname[len - 1] = 'g';
- sug_write(spin, fname);
+ sug_write(spin, (char_u *)fname);
theend:
xfree(fname);
@@ -5036,7 +5035,7 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang)
if (c == 0) {
// Sound-fold the word.
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,
// "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++) {
// <sugline>: <sugnr> ... NUL
- char_u *line = (char_u *)ml_get_buf(spin->si_spellbuf, lnum, false);
- size_t len = STRLEN(line) + 1;
+ char *line = ml_get_buf(spin->si_spellbuf, lnum, false);
+ size_t len = strlen(line) + 1;
if (fwrite(line, len, 1, fd) == 0) {
emsg(_(e_write));
goto theend;
@@ -5316,7 +5315,7 @@ static void mkspell(int fcount, char **fnames, bool ascii, bool over_write, bool
char *wfname = xmalloc(MAXPATHL);
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) {
// For ":mkspell path/en.latin1.add" output file is
// "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.
static void init_spellfile(void)
{
- char_u *buf;
+ char *buf;
int l;
char_u *fname;
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);
} else {
// 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
// encoding used in the first loaded .spl file.
if (aspath) {
STRLCPY(buf, curbuf->b_s.b_p_spl, lend - (char_u *)curbuf->b_s.b_p_spl + 1);
} else {
// Create the "spell" directory if it doesn't exist yet.
- l = (int)STRLEN(buf);
- vim_snprintf((char *)buf + l, MAXPATHL - (size_t)l, "/spell");
- if (os_file_is_writable((char *)buf) != 2) {
- os_mkdir((char *)buf, 0755);
+ l = (int)strlen(buf);
+ vim_snprintf(buf + l, MAXPATHL - (size_t)l, "/spell");
+ if (os_file_is_writable(buf) != 2) {
+ os_mkdir(buf, 0755);
}
- l = (int)STRLEN(buf);
- vim_snprintf((char *)buf + l, MAXPATHL - (size_t)l,
+ l = (int)strlen(buf);
+ vim_snprintf(buf + l, MAXPATHL - (size_t)l,
"/%.*s", (int)(lend - lstart), lstart);
}
- l = (int)STRLEN(buf);
+ l = (int)strlen(buf);
fname = (char_u *)LANGP_ENTRY(curwin->w_s->b_langp, 0)
->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
&& strstr(path_tail((char *)fname), ".ascii.") != NULL)
? "ascii"
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index cc5c61b855..7b08fec48c 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -71,7 +71,7 @@ typedef struct suginfo_S {
int su_maxscore; ///< maximum score for adding to su_ga
int su_sfmaxscore; ///< idem, for when doing soundfold words
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_badflags; ///< caps flags for bad word
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) {
// Replacing less than "su_badlen", append the remainder 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,
sug.su_badlen - stp->st_orglen,
sug.su_badptr + stp->st_orglen);
repl_to = xstrdup((char *)IObuff);
} else {
// 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);
}
// Replace the word.
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);
STRCPY(p + c, stp->st_word);
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
// 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_wordlen, sug.su_badptr + stp->st_orglen);
((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);
- su->su_badptr = badptr;
+ su->su_badptr = (char *)badptr;
if (badlen != 0) {
su->su_badlen = badlen;
} 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);
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
}
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);
// 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;
// get caps flags for bad word
- su->su_badflags = badword_captype(su->su_badptr,
- su->su_badptr + su->su_badlen);
+ su->su_badflags = badword_captype((char_u *)su->su_badptr,
+ (char_u *)su->su_badptr + su->su_badlen);
if (need_cap) {
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
// have to do this many times.
if (su->su_sallang != NULL) {
- spell_soundfold(su->su_sallang, su->su_fbadword, true,
- su->su_sal_badword);
+ spell_soundfold(su->su_sallang, (char *)su->su_fbadword, true,
+ (char *)su->su_sal_badword);
}
// 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
// for that.
- c = utf_ptr2char((char *)su->su_badptr);
+ c = utf_ptr2char(su->su_badptr);
if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) {
make_case_word(su->su_badword, buf, WF_ONECAP);
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.
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.
@@ -1008,10 +1008,10 @@ static void suggest_try_special(suginfo_T *su)
char_u word[MAXWLEN];
// Recognize a word that is repeated: "the the".
- char_u *p = (char_u *)skiptowhite((char *)su->su_fbadword);
- size_t len = (size_t)(p - su->su_fbadword);
- p = (char_u *)skipwhite((char *)p);
- if (STRLEN(p) == len && STRNCMP(su->su_fbadword, p, len) == 0) {
+ char *p = skiptowhite((char *)su->su_fbadword);
+ size_t len = (size_t)(p - (char *)su->su_fbadword);
+ p = skipwhite(p);
+ if (strlen(p) == len && STRNCMP(su->su_fbadword, p, len) == 0) {
// Include badflags: if the badword is onecap or allcap
// use that for the goodword too: "The the" -> "The".
c = su->su_fbadword[len];
@@ -1074,21 +1074,21 @@ static void prof_report(char *name)
/// Try finding suggestions by adding/removing/swapping letters.
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;
- char_u *p;
+ char *p;
langp_T *lp;
// 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
// chars after the bad word may help.
STRCPY(fword, su->su_fbadword);
- n = (int)STRLEN(fword);
+ n = (int)strlen(fword);
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.
- n = (int)STRLEN(su->su_badptr);
+ n = (int)strlen(su->su_badptr);
if (n < MAXWLEN) {
fword[n] = NUL;
}
@@ -1106,7 +1106,7 @@ static void suggest_try_change(suginfo_T *su)
#ifdef SUGGEST_PROFILE
prof_init();
#endif
- suggest_trie_walk(su, lp, fword, false);
+ suggest_trie_walk(su, lp, (char_u *)fword, false);
#ifdef SUGGEST_PROFILE
prof_report("try_change");
#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)) {
// Set su->su_badflags to the caps type at this position.
// Use the caps type until here for the prefix itself.
- n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
- flags = badword_captype(su->su_badptr, su->su_badptr + n);
- su->su_badflags = badword_captype(su->su_badptr + n,
- su->su_badptr + su->su_badlen);
+ n = nofold_len(fword, sp->ts_fidx, (char_u *)su->su_badptr);
+ flags = badword_captype((char_u *)su->su_badptr, (char_u *)su->su_badptr + n);
+ su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
+ (char_u *)su->su_badptr + su->su_badlen);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "prefix"); // NOLINT(runtime/printf)
#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;
make_case_word(tword + sp->ts_splitoff,
(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;
}
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) {
p = (char_u *)skipwhite(skiptowhite((char *)p));
}
- if (fword_ends && !can_compound(slang, p,
- compflags + sp->ts_compsplit)) {
+ if (fword_ends && !can_compound(slang, (char *)p, compflags + sp->ts_compsplit)) {
// Compound is not allowed. But it may still be
// possible if we add another (short) word.
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
// allcap and it's only one char long use onecap.
c = su->su_badflags;
- if ((c & WF_ALLCAP)
- && su->su_badlen ==
- utfc_ptr2len((char *)su->su_badptr)) {
+ if ((c & WF_ALLCAP) && su->su_badlen == utfc_ptr2len(su->su_badptr)) {
c = WF_ONECAP;
}
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
// word, thus remember it.
if (flags & WF_BANNED) {
- add_banned(su, (char_u *)preword + sp->ts_prewordlen);
+ add_banned(su, preword + sp->ts_prewordlen);
break;
}
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) {
// For soundfolded words we need to find the original
// 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) {
// Give a penalty when changing non-word char to word
// char, e.g., "thes," -> "these".
p = fword + sp->ts_fidx;
MB_PTR_BACK(fword, p);
if (!spell_iswordp(p, curwin) && *preword != NUL) {
- p = (char_u *)preword + STRLEN(preword);
+ p = (char_u *)preword + strlen(preword);
MB_PTR_BACK(preword, p);
if (spell_iswordp(p, curwin)) {
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));
}
if (sp->ts_complen > sp->ts_compsplit
- && !can_compound(slang, p,
- compflags + sp->ts_compsplit)) {
+ && !can_compound(slang, (char *)p, compflags + sp->ts_compsplit)) {
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
// position
- n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
- su->su_badflags = badword_captype(su->su_badptr + n,
- su->su_badptr + su->su_badlen);
+ n = nofold_len(fword, sp->ts_fidx, (char_u *)su->su_badptr);
+ su->su_badflags = badword_captype((char_u *)su->su_badptr + n,
+ (char_u *)su->su_badptr + su->su_badlen);
// Restart at top of the tree.
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;
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)) {
go_deeper(stack, depth, SCORE_REP);
#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.
depth++;
- fl = (int)STRLEN(ftp->ft_from);
- tl = (int)STRLEN(ftp->ft_to);
+ fl = (int)strlen((char *)ftp->ft_from);
+ tl = (int)strlen((char *)ftp->ft_to);
if (fl != tl) {
- STRMOVE(p + tl, p + fl);
+ STRMOVE(p + tl, (char *)p + fl);
repextra += tl - fl;
}
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;
}
ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;
- fl = (int)STRLEN(ftp->ft_from);
- tl = (int)STRLEN(ftp->ft_to);
+ fl = (int)strlen((char *)ftp->ft_from);
+ tl = (int)strlen((char *)ftp->ft_to);
p = fword + sp->ts_fidx;
if (fl != tl) {
- STRMOVE(p + fl, p + tl);
+ STRMOVE(p + fl, (char *)p + tl);
repextra -= tl - 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);
if (!GA_EMPTY(&lp->lp_slang->sl_sal)) {
// 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++) {
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)) {
// soundfold the bad word
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++) {
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;
} else {
// 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"
// 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])
&& *skiptowhite(stp->st_word) == 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;
}
@@ -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.
- spell_soundfold(slang, pgood, false, goodsound);
+ spell_soundfold(slang, (char *)pgood, false, (char *)goodsound);
return soundalike_score((char *)goodsound, (char *)pbad);
}
@@ -2742,7 +2738,7 @@ static void suggest_try_soundalike(suginfo_T *su)
slang = lp->lp_slang;
if (!GA_EMPTY(&slang->sl_sal) && slang->sl_sbyts != NULL) {
// soundfold the bad word
- spell_soundfold(slang, su->su_fbadword, true, salword);
+ spell_soundfold(slang, (char *)su->su_fbadword, true, (char *)salword);
// try all kinds of inserts/deletes/swaps/etc.
// 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.
///
/// @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
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
// the words that have a better score than before. Use a hashtable to
// remember the words that have been done.
- hash = hash_hash(goodword);
- const size_t goodword_len = STRLEN(goodword);
+ hash = hash_hash((char_u *)goodword);
+ const size_t goodword_len = strlen(goodword);
hi = hash_lookup(&slang->sl_sounddone, (const char *)goodword, goodword_len,
hash);
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.
- sfwordnr = soundfold_find(slang, goodword);
+ sfwordnr = soundfold_find(slang, (char_u *)goodword);
if (sfwordnr < 0) {
internal_error("add_sound_suggest()");
return;
@@ -3064,7 +3060,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
if (HASHITEM_EMPTY(hi)) {
m1 = 0;
} 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 {
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)) {
m2 = 0;
} 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 {
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
// "thee the" is added next to changing the first "the" the "thee".
const char *pgood = goodword + strlen(goodword);
- char_u *pbad = su->su_badptr + badlenarg;
+ char *pbad = su->su_badptr + badlenarg;
for (;;) {
goodlen = (int)(pgood - goodword);
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(su->su_badptr, pbad);
- if (utf_ptr2char((char *)pgood) != utf_ptr2char((char *)pbad)) {
+ if (utf_ptr2char(pgood) != utf_ptr2char(pbad)) {
break;
}
}
@@ -3236,15 +3232,15 @@ static void check_suggestions(suginfo_T *su, garray_T *gap)
}
/// 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;
hash_T hash;
hashitem_T *hi;
- hash = hash_hash(word);
- const size_t word_len = STRLEN(word);
- hi = hash_lookup(&su->su_banned, (const char *)word, word_len, hash);
+ hash = hash_hash((char_u *)word);
+ const size_t word_len = strlen(word);
+ hi = hash_lookup(&su->su_banned, word, word_len, hash);
if (HASHITEM_EMPTY(hi)) {
s = xmemdupz(word, word_len);
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) {
p = su->su_sal_badword;
} else {
- spell_soundfold(slang, su->su_fbadword, true, sal_badword);
+ spell_soundfold(slang, (char *)su->su_fbadword, true, (char *)sal_badword);
p = sal_badword;
}
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index 9b9daa3883..34df46f448 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -808,7 +808,7 @@ void draw_tabline(void)
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;
}
grid_putchar(&default_grid, ' ', 0, col++, attr);
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index 7fdcaaa355..cfe821715c 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -137,15 +137,16 @@ char *vim_strnsave_unquoted(const char *const string, const size_t length)
return ret;
}
-// Escape "string" for use as a shell argument with system().
-// This uses single quotes, except when we know we need to use double quotes
-// (MS-Windows without 'shellslash' set).
-// Escape a newline, depending on the 'shell' option.
-// When "do_special" is true also replace "!", "%", "#" and things starting
-// with "<" like "<cfile>".
-// 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)
+/// Escape "string" for use as a shell argument with system().
+/// This uses single quotes, except when we know we need to use double quotes
+/// (MS-Windows without 'shellslash' set).
+/// Escape a newline, depending on the 'shell' option.
+/// When "do_special" is true also replace "!", "%", "#" and things starting
+/// with "<" like "<cfile>".
+/// When "do_newline" is false do not escape newline unless it is csh shell.
+///
+/// @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
{
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();
// First count the number of extra bytes required.
- size_t length = STRLEN(string) + 3; // two quotes and a trailing NUL
- for (const char_u *p = string; *p != NUL; MB_PTR_ADV(p)) {
+ size_t length = strlen(string) + 3; // two quotes and a trailing NUL
+ for (const char_u *p = (char_u *)string; *p != NUL; MB_PTR_ADV(p)) {
#ifdef MSWIN
if (!p_ssl) {
if (*p == '"') {
@@ -258,7 +259,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
*d++ = '\'';
*d = NUL;
- return escaped_string;
+ return (char *)escaped_string;
}
// 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
-void del_trailing_spaces(char_u *ptr)
+void del_trailing_spaces(char *ptr)
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) {
*q = NUL;
}
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index cafcc4f508..6af39d06d3 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -144,7 +144,7 @@ typedef struct {
proftime_T slowest;
proftime_T average;
int id;
- char_u *pattern;
+ char *pattern;
} time_entry_T;
struct name_list {
@@ -228,7 +228,7 @@ static int running_syn_inc_tag = 0;
// HI2KE() converts a hashitem pointer to a var pointer.
static keyentry_T dumkey;
#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)
// -V:HI2KE:782
@@ -2754,7 +2754,7 @@ static int check_keyword_id(char *const line, const int startcol, int *const end
// ignoring case
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);
}
@@ -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) {
force_newline = true;
} else {
- outlen = (int)STRLEN(kp->keyword);
+ outlen = (int)strlen(kp->keyword);
}
// output "contained" and "nextgroup" on each line
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) {
hash_remove(ht, hi);
} else {
- hi->hi_key = KE2HIKEY(kp_next);
+ hi->hi_key = (char *)KE2HIKEY(kp_next);
}
} else {
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];
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))
: 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);
- 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)
? &curwin->w_s->b_keywtab_ic
: &curwin->w_s->b_keywtab;
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
// 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)) {
// new keyword, add to hashtable
kp->ke_next = NULL;
- hash_add_item(ht, hi, kp->keyword, hash);
+ hash_add_item(ht, hi, (char_u *)kp->keyword, hash);
} else {
// keyword already exists, prepend to list
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);
p->average = tm;
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 {
len = Columns - 70;
}
- if (len > (int)STRLEN(p->pattern)) {
- len = (int)STRLEN(p->pattern);
+ if (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");
}
ga_clear(&ga);
diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h
index c656f21181..3f3101f7e3 100644
--- a/src/nvim/syntax_defs.h
+++ b/src/nvim/syntax_defs.h
@@ -30,7 +30,7 @@ struct keyentry {
int16_t *next_list; // ID list for next match (if non-zero)
int flags;
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.
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 7e4677e502..71164726eb 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -1481,7 +1481,7 @@ static bool findtags_in_help_init(findtags_state_T *st)
} else {
// Prefer help tags according to 'helplang'. Put the two-letter
// 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] == '-') {
STRLCPY(st->help_lang, st->tag_fname + i - 2, 3);
} else {
@@ -2599,7 +2599,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
// move the filename one char forward and truncate the
// filepath with a NUL
filename = (char_u *)path_tail(buf);
- STRMOVE(filename + 1, filename);
+ STRMOVE(filename + 1, (char *)filename);
*filename++ = NUL;
tnp->tn_search_ctx = vim_findfile_init(buf, (char *)filename,
diff --git a/src/nvim/testing.c b/src/nvim/testing.c
index f4ff27c9bc..3617670da9 100644
--- a/src/nvim/testing.c
+++ b/src/nvim/testing.c
@@ -188,7 +188,7 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_s
if (item2 == NULL
|| !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.
- 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_HI2DI(hi)->di_tv);
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);
if (item2 == NULL) {
// 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_HI2DI(hi)->di_tv);
}
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 054dcfa8d0..0b86a82619 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -3009,7 +3009,7 @@ void u_undoline(void)
char *oldp = (char *)u_save_line(curbuf->b_u_line_lnum);
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true);
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);
xfree(curbuf->b_u_line_ptr);
curbuf->b_u_line_ptr = oldp;
diff --git a/src/nvim/vim.h b/src/nvim/vim.h
index 7ac359da9a..50b186c750 100644
--- a/src/nvim/vim.h
+++ b/src/nvim/vim.h
@@ -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
// (vim_strchr() is now in strings.c)
-#define STRLEN(s) strlen((char *)(s))
#ifdef HAVE_STRNLEN
# define STRNLEN(s, n) strnlen((char *)(s), (size_t)(n))
#else
@@ -216,7 +215,7 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
#endif
// 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
# define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n))