diff options
Diffstat (limited to 'src')
35 files changed, 461 insertions, 466 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index e728bd6967..fb29a723bc 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -2192,7 +2192,7 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***f if (xp->xp_context == EXPAND_LUA) { ILOG("PAT %s", pat); - return nlua_expand_pat(xp, pat, num_file, file); + return nlua_expand_pat(xp, (char *)pat, num_file, file); } regmatch.regprog = vim_regcomp((char *)pat, p_magic ? RE_MAGIC : 0); diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 5a59f09113..b080b817a7 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -203,7 +203,7 @@ static int in_history(int type, char *str, int move_to_front, int sep) // well. char *p = history[type][i].hisstr; if (strcmp(str, p) == 0 - && (type != HIST_SEARCH || sep == p[STRLEN(p) + 1])) { + && (type != HIST_SEARCH || sep == p[strlen(p) + 1])) { if (!move_to_front) { return true; } diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 10e1d95730..6735551dc7 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1570,7 +1570,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, // Non-BMP character : display as ? or fullwidth ?. transchar_hex((char *)extra, mb_c); if (wp->w_p_rl) { // reverse - rl_mirror(extra); + rl_mirror((char *)extra); } p_extra = extra; @@ -2063,7 +2063,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, n_extra = byte2cells(c) - 1; } if ((dy_flags & DY_UHEX) && wp->w_p_rl) { - rl_mirror(p_extra); // reverse "<12>" + rl_mirror((char *)p_extra); // reverse "<12>" } c_extra = NUL; c_final = NUL; diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 09f20baebf..0e14567286 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -81,7 +81,7 @@ typedef struct insert_state { int did_restart_edit; // remember if insert mode was restarted // after a ctrl+o bool nomove; - char_u *ptr; + char *ptr; } InsertState; #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -143,14 +143,14 @@ static void insert_enter(InsertState *s) pos_T save_cursor = curwin->w_cursor; if (s->cmdchar == 'R') { - s->ptr = (char_u *)"r"; + s->ptr = "r"; } else if (s->cmdchar == 'V') { - s->ptr = (char_u *)"v"; + s->ptr = "v"; } else { - s->ptr = (char_u *)"i"; + s->ptr = "i"; } - set_vim_var_string(VV_INSERTMODE, (char *)s->ptr, 1); + set_vim_var_string(VV_INSERTMODE, s->ptr, 1); set_vim_var_string(VV_CHAR, NULL, -1); ins_apply_autocmds(EVENT_INSERTENTER); @@ -272,11 +272,11 @@ static void insert_enter(InsertState *s) update_curswant(); if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum) || curwin->w_curswant > curwin->w_virtcol) - && *(s->ptr = (char_u *)get_cursor_line_ptr() + curwin->w_cursor.col) != NUL) { + && *(s->ptr = get_cursor_line_ptr() + curwin->w_cursor.col) != NUL) { if (s->ptr[1] == NUL) { curwin->w_cursor.col++; } else { - s->i = utfc_ptr2len((char *)s->ptr); + s->i = utfc_ptr2len(s->ptr); if (s->ptr[s->i] == NUL) { curwin->w_cursor.col += s->i; } @@ -317,11 +317,11 @@ static void insert_enter(InsertState *s) // Get the current length of the redo buffer, those characters have to be // skipped if we want to get to the inserted characters. - s->ptr = get_inserted(); + s->ptr = (char *)get_inserted(); if (s->ptr == NULL) { new_insert_skip = 0; } else { - new_insert_skip = (int)STRLEN(s->ptr); + new_insert_skip = (int)strlen(s->ptr); xfree(s->ptr); } @@ -1449,28 +1449,28 @@ char *buf_prompt_text(const buf_T *const buf) return buf->b_prompt_text; } -// Return the effective prompt for the current buffer. -char_u *prompt_text(void) +/// @return the effective prompt for the current buffer. +char *prompt_text(void) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE { - return (char_u *)buf_prompt_text(curbuf); + return buf_prompt_text(curbuf); } // Prepare for prompt mode: Make sure the last line has the prompt text. // Move the cursor to this line. static void init_prompt(int cmdchar_todo) { - char_u *prompt = prompt_text(); - char_u *text; + char *prompt = prompt_text(); + char *text; curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; - text = (char_u *)get_cursor_line_ptr(); - if (STRNCMP(text, prompt, STRLEN(prompt)) != 0) { + text = get_cursor_line_ptr(); + if (STRNCMP(text, prompt, strlen(prompt)) != 0) { // prompt is missing, insert it or append a line with it if (*text == NUL) { - ml_replace(curbuf->b_ml.ml_line_count, (char *)prompt, true); + ml_replace(curbuf->b_ml.ml_line_count, prompt, true); } else { - ml_append(curbuf->b_ml.ml_line_count, (char *)prompt, 0, false); + ml_append(curbuf->b_ml.ml_line_count, prompt, 0, false); } curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; coladvance(MAXCOL); @@ -1478,9 +1478,9 @@ static void init_prompt(int cmdchar_todo) } // Insert always starts after the prompt, allow editing text after it. - if (Insstart_orig.lnum != curwin->w_cursor.lnum || Insstart_orig.col != (colnr_T)STRLEN(prompt)) { + if (Insstart_orig.lnum != curwin->w_cursor.lnum || Insstart_orig.col != (colnr_T)strlen(prompt)) { Insstart.lnum = curwin->w_cursor.lnum; - Insstart.col = (colnr_T)STRLEN(prompt); + Insstart.col = (colnr_T)strlen(prompt); Insstart_orig = Insstart; Insstart_textlen = Insstart.col; Insstart_blank_vcol = MAXCOL; @@ -1490,8 +1490,8 @@ static void init_prompt(int cmdchar_todo) if (cmdchar_todo == 'A') { coladvance(MAXCOL); } - if (curwin->w_cursor.col < (colnr_T)STRLEN(prompt)) { - curwin->w_cursor.col = (colnr_T)STRLEN(prompt); + if (curwin->w_cursor.col < (colnr_T)strlen(prompt)) { + curwin->w_cursor.col = (colnr_T)strlen(prompt); } // Make sure the cursor is in a valid position. check_cursor(); @@ -1502,7 +1502,7 @@ bool prompt_curpos_editable(void) FUNC_ATTR_PURE { return curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count - && curwin->w_cursor.col >= (int)STRLEN(prompt_text()); + && curwin->w_cursor.col >= (int)strlen(prompt_text()); } // Undo the previous edit_putchar(). @@ -1940,7 +1940,7 @@ int get_literal(bool no_simplify) /// @param ctrlv `c` was typed after CTRL-V static void insert_special(int c, int allow_modmask, int ctrlv) { - char_u *p; + char *p; int len; // Special function key, translate into "<Key>". Up to the last '>' is @@ -1952,16 +1952,16 @@ static void insert_special(int c, int allow_modmask, int ctrlv) allow_modmask = true; } if (IS_SPECIAL(c) || (mod_mask && allow_modmask)) { - p = get_special_key_name(c, mod_mask); - len = (int)STRLEN(p); - c = p[len - 1]; + p = (char *)get_special_key_name(c, mod_mask); + len = (int)strlen(p); + c = (uint8_t)p[len - 1]; if (len > 2) { if (stop_arrow() == FAIL) { return; } p[len - 1] = NUL; - ins_str((char *)p); - AppendToRedobuffLit((char *)p, -1); + ins_str(p); + AppendToRedobuffLit(p, -1); ctrlv = false; } } @@ -2286,7 +2286,7 @@ int stop_arrow(void) static void stop_insert(pos_T *end_insert_pos, int esc, int nomove) { int cc; - char_u *ptr; + char *ptr; stop_redo_ins(); replace_flush(); // abandon replace stack @@ -2294,11 +2294,11 @@ static void stop_insert(pos_T *end_insert_pos, int esc, int nomove) // Save the inserted text for later redo with ^@ and CTRL-A. // Don't do it when "restart_edit" was set and nothing was inserted, // otherwise CTRL-O w and then <Left> will clear "last_insert". - ptr = get_inserted(); + ptr = (char *)get_inserted(); if (did_restart_edit == 0 || (ptr != NULL - && (int)STRLEN(ptr) > new_insert_skip)) { + && (int)strlen(ptr) > new_insert_skip)) { xfree(last_insert); - last_insert = ptr; + last_insert = (char_u *)ptr; last_insert_skip = new_insert_skip; } else { xfree(ptr); @@ -2742,7 +2742,7 @@ char_u *get_last_insert_save(void) return NULL; } s = xstrdup((char *)last_insert + last_insert_skip); - len = (int)STRLEN(s); + len = (int)strlen(s); if (len > 0 && s[len - 1] == ESC) { // remove trailing ESC s[len - 1] = NUL; } @@ -2938,7 +2938,7 @@ static void replace_do_bs(int limit_col) int ins_len; int orig_vcols = 0; colnr_T start_vcol; - char_u *p; + char *p; int i; int vcol; const int l_State = State; @@ -2960,12 +2960,12 @@ static void replace_do_bs(int limit_col) if (l_State & VREPLACE_FLAG) { // Get the number of screen cells used by the inserted characters - p = (char_u *)get_cursor_pos_ptr(); - ins_len = (int)STRLEN(p) - orig_len; + p = get_cursor_pos_ptr(); + ins_len = (int)strlen(p) - orig_len; vcol = start_vcol; for (i = 0; i < ins_len; i++) { - vcol += win_chartabsize(curwin, (char *)p + i, vcol); - i += utfc_ptr2len((char *)p) - 1; + vcol += win_chartabsize(curwin, p + i, vcol); + i += utfc_ptr2len(p) - 1; } vcol -= start_vcol; @@ -3036,11 +3036,11 @@ void fix_indent(void) /// @param line_is_empty when true, accept keys with '0' before them. bool in_cinkeys(int keytyped, int when, bool line_is_empty) { - char_u *look; + uint8_t *look; int try_match; int try_match_word; - char_u *p; - char_u *line; + uint8_t *p; + uint8_t *line; bool icase; if (keytyped == NUL) { @@ -3049,9 +3049,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } if (*curbuf->b_p_inde != NUL) { - look = (char_u *)curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys' + look = (uint8_t *)curbuf->b_p_indk; // 'indentexpr' set: use 'indentkeys' } else { - look = (char_u *)curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys' + look = (uint8_t *)curbuf->b_p_cink; // 'indentexpr' empty: use 'cinkeys' } while (*look) { // Find out if we want to try a match with this key, depending on @@ -3104,8 +3104,8 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) // cursor. } else if (*look == 'e') { if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) { - p = (char_u *)get_cursor_line_ptr(); - if ((char_u *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4 + p = (uint8_t *)get_cursor_line_ptr(); + if ((uint8_t *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4 && STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) { return true; } @@ -3117,20 +3117,20 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) // class::method for C++). } else if (*look == ':') { if (try_match && keytyped == ':') { - p = (char_u *)get_cursor_line_ptr(); - if (cin_iscase(p, false) || cin_isscopedecl(p) || cin_islabel()) { + p = (uint8_t *)get_cursor_line_ptr(); + if (cin_iscase((char_u *)p, false) || cin_isscopedecl((char_u *)p) || cin_islabel()) { return true; } // Need to get the line again after cin_islabel(). - p = (char_u *)get_cursor_line_ptr(); + p = (uint8_t *)get_cursor_line_ptr(); if (curwin->w_cursor.col > 2 && p[curwin->w_cursor.col - 1] == ':' && p[curwin->w_cursor.col - 2] == ':') { p[curwin->w_cursor.col - 1] = ' '; - const bool i = cin_iscase(p, false) - || cin_isscopedecl(p) + const bool i = cin_iscase((char_u *)p, false) + || cin_isscopedecl((char_u *)p) || cin_islabel(); - p = (char_u *)get_cursor_line_ptr(); + p = (uint8_t *)get_cursor_line_ptr(); p[curwin->w_cursor.col - 1] = ':'; if (i) { return true; @@ -3150,7 +3150,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) return true; } - if (keytyped == get_special_key_code(look + 1)) { + if (keytyped == get_special_key_code((char_u *)look + 1)) { return true; } } @@ -3169,23 +3169,23 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } else { icase = false; } - p = (char_u *)vim_strchr((char *)look, ','); + p = (uint8_t *)vim_strchr((char *)look, ','); if (p == NULL) { - p = look + STRLEN(look); + p = look + strlen((char *)look); } if ((try_match || try_match_word) && curwin->w_cursor.col >= (colnr_T)(p - look)) { bool match = false; if (keytyped == KEY_COMPLETE) { - char_u *n, *s; + uint8_t *n, *s; // Just completed a word, check if it starts with "look". // search back for the start of a word. - line = (char_u *)get_cursor_line_ptr(); + line = (uint8_t *)get_cursor_line_ptr(); for (s = line + curwin->w_cursor.col; s > line; s = n) { - n = mb_prevptr(line, s); - if (!vim_iswordp(n)) { + n = mb_prevptr((char_u *)line, (char_u *)s); + if (!vim_iswordp((char_u *)n)) { break; } } @@ -3201,7 +3201,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) if (keytyped == (int)p[-1] || (icase && keytyped < 256 && TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) { - line = (char_u *)get_cursor_pos_ptr(); + line = (uint8_t *)get_cursor_pos_ptr(); assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX); if ((curwin->w_cursor.col == (colnr_T)(p - look) || !vim_iswordc(line[-(p - look) - 1])) @@ -3237,7 +3237,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) } // Skip over ", ". - look = (char_u *)skip_to_option_part((char *)look); + look = (uint8_t *)skip_to_option_part((char *)look); } return false; } @@ -3895,10 +3895,10 @@ static bool ins_bs(int c, int mode, int *inserted_space_p) // again when auto-formatting. if (has_format_option(FO_AUTO) && has_format_option(FO_WHITE_PAR)) { - char_u *ptr = (char_u *)ml_get_buf(curbuf, curwin->w_cursor.lnum, true); + char *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, true); int len; - len = (int)STRLEN(ptr); + len = (int)strlen(ptr); if (len > 0 && ptr[len - 1] == ' ') { ptr[len - 1] = NUL; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ebc60ea5c7..d9d276e8ea 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8626,7 +8626,7 @@ void invoke_prompt_callback(void) return; } char *text = ml_get(lnum); - char *prompt = (char *)prompt_text(); + char *prompt = prompt_text(); if (strlen(text) >= strlen(prompt)) { text += strlen(prompt); } diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 861f68993a..5073ab8f1b 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -577,7 +577,7 @@ buf_T *tv_get_buf(typval_T *tv, int curtab_only) return NULL; } - char_u *name = (char_u *)tv->vval.v_string; + char *name = tv->vval.v_string; if (name == NULL || *name == NUL) { return curbuf; @@ -592,7 +592,7 @@ buf_T *tv_get_buf(typval_T *tv, int curtab_only) char *save_cpo = p_cpo; p_cpo = empty_option; - buf_T *buf = buflist_findnr(buflist_findpat((char *)name, (char *)name + STRLEN(name), + buf_T *buf = buflist_findnr(buflist_findpat(name, name + strlen(name), true, false, curtab_only)); p_magic = save_magic; @@ -1056,12 +1056,12 @@ static void f_count(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } if (argvars[0].v_type == VAR_STRING) { - const char_u *expr = (char_u *)tv_get_string_chk(&argvars[1]); + const char *expr = tv_get_string_chk(&argvars[1]); const char_u *p = (char_u *)argvars[0].vval.v_string; if (!error && expr != NULL && *expr != NUL && p != NULL) { if (ic) { - const size_t len = STRLEN(expr); + const size_t len = strlen(expr); while (*p != NUL) { if (mb_strnicmp((char *)p, (char *)expr, len) == 0) { @@ -1075,7 +1075,7 @@ static void f_count(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) char_u *next; while ((next = (char_u *)strstr((char *)p, (char *)expr)) != NULL) { n++; - p = next + STRLEN(expr); + p = next + strlen(expr); } } } @@ -4855,9 +4855,9 @@ static void f_map(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) static void find_some_match(typval_T *const argvars, typval_T *const rettv, const SomeMatchType type) { - char_u *str = NULL; + char *str = NULL; long len = 0; - char_u *expr = NULL; + char *expr = NULL; regmatch_T regmatch; long start = 0; long nth = 1; @@ -4865,7 +4865,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, bool match = false; list_T *l = NULL; long idx = 0; - char_u *tofree = NULL; + char *tofree = NULL; // Make 'cpoptions' empty, the 'l' flag should not be used here. char *save_cpo = p_cpo; @@ -4902,8 +4902,8 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, } li = tv_list_first(l); } else { - expr = str = (char_u *)tv_get_string(&argvars[0]); - len = (long)STRLEN(str); + expr = str = (char *)tv_get_string(&argvars[0]); + len = (long)strlen(str); } char patbuf[NUMBUFLEN]; @@ -4962,14 +4962,13 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, break; } xfree(tofree); - tofree = expr = str = (char_u *)encode_tv2echo(TV_LIST_ITEM_TV(li), - NULL); + tofree = expr = str = encode_tv2echo(TV_LIST_ITEM_TV(li), NULL); if (str == NULL) { break; } } - match = vim_regexec_nl(®match, str, startcol); + match = vim_regexec_nl(®match, (char_u *)str, startcol); if (match && --nth <= 0) { break; @@ -4983,9 +4982,9 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, li = TV_LIST_ITEM_NEXT(l, li); idx++; } else { - startcol = (colnr_T)((char_u *)regmatch.startp[0] + startcol = (colnr_T)(regmatch.startp[0] + utfc_ptr2len(regmatch.startp[0]) - str); - if (startcol > (colnr_T)len || str + startcol <= (char_u *)regmatch.startp[0]) { + if (startcol > (colnr_T)len || str + startcol <= regmatch.startp[0]) { match = false; break; } @@ -5003,9 +5002,9 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, xfree(TV_LIST_ITEM_TV(li1)->vval.v_string); const size_t rd = (size_t)(regmatch.endp[0] - regmatch.startp[0]); - TV_LIST_ITEM_TV(li1)->vval.v_string = xmemdupz((const char *)regmatch.startp[0], rd); - TV_LIST_ITEM_TV(li3)->vval.v_number = (varnumber_T)((char_u *)regmatch.startp[0] - expr); - TV_LIST_ITEM_TV(li4)->vval.v_number = (varnumber_T)(regmatch.endp[0] - (char *)expr); + TV_LIST_ITEM_TV(li1)->vval.v_string = xmemdupz(regmatch.startp[0], rd); + TV_LIST_ITEM_TV(li3)->vval.v_number = (varnumber_T)(regmatch.startp[0] - expr); + TV_LIST_ITEM_TV(li4)->vval.v_number = (varnumber_T)(regmatch.endp[0] - expr); if (l != NULL) { TV_LIST_ITEM_TV(li2)->vval.v_number = (varnumber_T)idx; } @@ -5039,11 +5038,9 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, rettv->vval.v_number = idx; } else { if (type == kSomeMatch) { - rettv->vval.v_number = - (varnumber_T)((char_u *)regmatch.startp[0] - str); + rettv->vval.v_number = (varnumber_T)(regmatch.startp[0] - str); } else { - rettv->vval.v_number = - (varnumber_T)(regmatch.endp[0] - (char *)str); + rettv->vval.v_number = (varnumber_T)(regmatch.endp[0] - str); } rettv->vval.v_number += (varnumber_T)(str - expr); } diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index b0a56c4440..fdeb52053c 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -206,12 +206,12 @@ char_u *get_lambda_name(void) return name; } -static void set_ufunc_name(ufunc_T *fp, char_u *name) +static void set_ufunc_name(ufunc_T *fp, char *name) { STRCPY(fp->uf_name, name); - if (name[0] == K_SPECIAL) { - fp->uf_name_exp = xmalloc(STRLEN(name) + 3); + if ((uint8_t)name[0] == K_SPECIAL) { + fp->uf_name_exp = xmalloc(strlen(name) + 3); STRCPY(fp->uf_name_exp, "<SNR>"); STRCAT(fp->uf_name_exp, fp->uf_name + 3); } @@ -275,9 +275,9 @@ int get_lambda_tv(char **arg, typval_T *rettv, bool evaluate) char_u *p; garray_T newlines; - char_u *name = get_lambda_name(); + char *name = (char *)get_lambda_name(); - fp = xcalloc(1, offsetof(ufunc_T, uf_name) + STRLEN(name) + 1); + fp = xcalloc(1, offsetof(ufunc_T, uf_name) + strlen(name) + 1); pt = xcalloc(1, sizeof(partial_T)); ga_init(&newlines, (int)sizeof(char_u *), 1); @@ -378,9 +378,9 @@ char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp, if (partialp != NULL) { *partialp = pt; } - char_u *s = (char_u *)partial_name(pt); - *lenp = (int)STRLEN(s); - return s; + char *s = partial_name(pt); + *lenp = (int)strlen(s); + return (char_u *)s; } return (char_u *)name; @@ -2476,8 +2476,8 @@ void ex_function(exarg_T *eap) if (SOURCING_NAME != NULL) { scriptname = (char_u *)autoload_name((const char *)name, strlen(name)); p = vim_strchr((char *)scriptname, '/'); - plen = (int)STRLEN(p); - slen = (int)STRLEN(SOURCING_NAME); + plen = (int)strlen(p); + slen = (int)strlen(SOURCING_NAME); if (slen > plen && path_fnamecmp(p, SOURCING_NAME + slen - plen) == 0) { j = OK; } @@ -2513,7 +2513,7 @@ void ex_function(exarg_T *eap) } // insert the new function in the function list - set_ufunc_name(fp, (char_u *)name); + set_ufunc_name(fp, name); if (overwrite) { hi = hash_find(&func_hashtab, name); hi->hi_key = UF2HIKEY(fp); @@ -2887,7 +2887,7 @@ void ex_call(exarg_T *eap) char_u *arg = (char_u *)eap->arg; char_u *startarg; char_u *name; - char_u *tofree; + char *tofree; int len; typval_T rettv; linenr_T lnum; @@ -2908,7 +2908,7 @@ void ex_call(exarg_T *eap) return; } - tofree = trans_function_name((char **)&arg, false, TFN_INT, &fudi, &partial); + tofree = (char *)trans_function_name((char **)&arg, false, TFN_INT, &fudi, &partial); if (fudi.fd_newkey != NULL) { // Still need to give an error message for missing key. semsg(_(e_dictkey), fudi.fd_newkey); @@ -2927,9 +2927,8 @@ void ex_call(exarg_T *eap) // If it is the name of a variable of type VAR_FUNC or VAR_PARTIAL use its // contents. For VAR_PARTIAL get its partial, unless we already have one // from trans_function_name(). - len = (int)STRLEN(tofree); - name = deref_func_name((const char *)tofree, &len, - partial != NULL ? NULL : &partial, false); + len = (int)strlen(tofree); + name = deref_func_name(tofree, &len, partial != NULL ? NULL : &partial, false); // Skip white space to allow ":call func ()". Not good, but required for // backward compatibility. @@ -3556,8 +3555,8 @@ bool set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID) /// Registers a luaref as a lambda. char_u *register_luafunc(LuaRef ref) { - char_u *name = get_lambda_name(); - ufunc_T *fp = xcalloc(1, offsetof(ufunc_T, uf_name) + STRLEN(name) + 1); + char *name = (char *)get_lambda_name(); + ufunc_T *fp = xcalloc(1, offsetof(ufunc_T, uf_name) + strlen(name) + 1); fp->uf_refcount = 1; fp->uf_varargs = true; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 77d310e338..c5ba750eb3 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2869,7 +2869,7 @@ static void append_command(char *cmd) STRCPY(d, "..."); } STRCAT(IObuff, ": "); - d = (char *)IObuff + STRLEN(IObuff); + d = IObuff + strlen(IObuff); while (*s != NUL && d - IObuff + 5 < IOSIZE) { if ((char_u)s[0] == 0xc2 && (char_u)s[1] == 0xa0) { s += 2; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 031226c5a1..52abbd13f3 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -370,7 +370,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat pos_T end_pos; proftime_T tm; int skiplen, patlen; - char_u next_char; + char next_char; char_u use_last_pat; int search_delim; @@ -408,7 +408,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat int found; // do_search() result // Use the previous pattern for ":s//". - next_char = (char_u)ccline.cmdbuff[skiplen + patlen]; + next_char = ccline.cmdbuff[skiplen + patlen]; use_last_pat = patlen == 0 && skiplen > 0 && ccline.cmdbuff[skiplen - 1] == next_char; @@ -437,7 +437,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim, (char_u *)ccline.cmdbuff + skiplen, count, search_flags, &sia); - ccline.cmdbuff[skiplen + patlen] = (char)next_char; + ccline.cmdbuff[skiplen + patlen] = next_char; emsg_off--; if (curwin->w_cursor.lnum < search_first_line || curwin->w_cursor.lnum > search_last_line) { @@ -486,13 +486,13 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat // Disable 'hlsearch' highlighting if the pattern matches // everything. Avoids a flash when typing "foo\|". if (!use_last_pat) { - next_char = (char_u)ccline.cmdbuff[skiplen + patlen]; + next_char = ccline.cmdbuff[skiplen + patlen]; ccline.cmdbuff[skiplen + patlen] = NUL; if (empty_pattern(ccline.cmdbuff) && !no_hlsearch) { redraw_all_later(UPD_SOME_VALID); set_no_hlsearch(true); } - ccline.cmdbuff[skiplen + patlen] = (char)next_char; + ccline.cmdbuff[skiplen + patlen] = next_char; } validate_cursor(); @@ -1051,7 +1051,7 @@ static int command_line_execute(VimState *state, int key) vungetc(s->c); s->c = Ctrl_BSL; } else if (s->c == 'e') { - char_u *p = NULL; + char *p = NULL; int len; // Replace the command line with the result of an expression. @@ -1066,11 +1066,11 @@ static int command_line_execute(VimState *state, int key) s->c = get_expr_register(); if (s->c == '=') { textlock++; - p = (char_u *)get_expr_line(); + p = get_expr_line(); textlock--; if (p != NULL) { - len = (int)STRLEN(p); + len = (int)strlen(p); realloc_cmdbuff(len + 1); ccline.cmdlen = len; STRCPY(ccline.cmdbuff, p); @@ -1303,20 +1303,20 @@ static int may_do_command_line_next_incsearch(int firstc, long count, incsearch_ ui_flush(); pos_T t; - char_u *pat; + char *pat; int search_flags = SEARCH_NOOF; - char_u save; + char save; if (search_delim == ccline.cmdbuff[skiplen]) { - pat = last_search_pattern(); + pat = (char *)last_search_pattern(); if (pat == NULL) { restore_last_search_pattern(); return FAIL; } skiplen = 0; - patlen = (int)STRLEN(pat); + patlen = (int)strlen(pat); } else { - pat = (char_u *)ccline.cmdbuff + skiplen; + pat = ccline.cmdbuff + skiplen; } if (next_match) { @@ -1338,7 +1338,7 @@ static int may_do_command_line_next_incsearch(int firstc, long count, incsearch_ pat[patlen] = NUL; int found = searchit(curwin, curbuf, &t, NULL, next_match ? FORWARD : BACKWARD, - pat, count, search_flags, + (char_u *)pat, count, search_flags, RE_SEARCH, NULL); emsg_off--; pat[patlen] = save; @@ -1843,21 +1843,21 @@ static int command_line_handle_key(CommandLineState *s) if (s->hiscnt != s->save_hiscnt) { // jumped to other entry - char_u *p; + char *p; int len = 0; int old_firstc; XFREE_CLEAR(ccline.cmdbuff); s->xpc.xp_context = EXPAND_NOTHING; if (s->hiscnt == get_hislen()) { - p = (char_u *)s->lookfor; // back to the old one + p = s->lookfor; // back to the old one } else { - p = (char_u *)get_histentry(s->histype)[s->hiscnt].hisstr; + p = get_histentry(s->histype)[s->hiscnt].hisstr; } if (s->histype == HIST_SEARCH - && p != (char_u *)s->lookfor - && (old_firstc = p[STRLEN(p) + 1]) != s->firstc) { + && p != s->lookfor + && (old_firstc = (uint8_t)p[strlen(p) + 1]) != s->firstc) { // Correct for the separator character used when // adding the history entry vs the one used now. // First loop: count length. @@ -1884,7 +1884,7 @@ static int command_line_handle_key(CommandLineState *s) } if (i > 0) { - ccline.cmdbuff[len] = (char)p[j]; + ccline.cmdbuff[len] = p[j]; } } len++; @@ -1896,7 +1896,7 @@ static int command_line_handle_key(CommandLineState *s) } ccline.cmdbuff[len] = NUL; } else { - alloc_cmdbuff((int)STRLEN(p)); + alloc_cmdbuff((int)strlen(p)); STRCPY(ccline.cmdbuff, p); } @@ -3381,7 +3381,7 @@ void put_on_cmdline(char_u *str, int len, int redraw) int c; if (len < 0) { - len = (int)STRLEN(str); + len = (int)strlen((char *)str); } realloc_cmdbuff(ccline.cmdlen + len + 1); diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index e907c45e79..eae3b4af1a 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -956,7 +956,7 @@ void ex_mkrc(exarg_T *eap) } // When using 'viewdir' may have to create the directory. - if (using_vdir && !os_isdir((char *)p_vdir)) { + if (using_vdir && !os_isdir(p_vdir)) { vim_mkdir_emsg((const char *)p_vdir, 0755); } @@ -1095,7 +1095,7 @@ static char *get_view_file(int c) len++; } } - char *retval = xmalloc(strlen(sname) + len + STRLEN(p_vdir) + 9); + char *retval = xmalloc(strlen(sname) + len + strlen(p_vdir) + 9); STRCPY(retval, p_vdir); add_pathsep(retval); char *s = retval + strlen(retval); diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 1872558669..04e6818d53 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1583,7 +1583,7 @@ static void foldAddMarker(buf_T *buf, pos_T pos, const char *marker, size_t mark // Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end char *line = ml_get_buf(buf, lnum, false); - size_t line_len = STRLEN(line); + size_t line_len = strlen(line); size_t added = 0; if (u_save(lnum - 1, lnum + 1) == OK) { @@ -3249,14 +3249,14 @@ void f_foldtext(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } // Find interesting text in this line. - char_u *s = (char_u *)skipwhite(ml_get(lnum)); + char *s = skipwhite(ml_get(lnum)); // skip C comment-start if (s[0] == '/' && (s[1] == '*' || s[1] == '/')) { - s = (char_u *)skipwhite((char *)s + 2); - if (*skipwhite((char *)s) == NUL && lnum + 1 < foldend) { - s = (char_u *)skipwhite(ml_get(lnum + 1)); + s = skipwhite(s + 2); + if (*skipwhite(s) == NUL && lnum + 1 < foldend) { + s = skipwhite(ml_get(lnum + 1)); if (*s == '*') { - s = (char_u *)skipwhite((char *)s + 1); + s = skipwhite(s + 1); } } } @@ -3265,7 +3265,7 @@ void f_foldtext(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) size_t len = strlen(txt) + strlen(dashes) // for %s + 20 // for %3ld - + STRLEN(s); // concatenated + + strlen(s); // concatenated char *r = xmalloc(len); snprintf(r, len, txt, dashes, count); len = strlen(r); diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 4135065787..16f3c477f6 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -170,15 +170,15 @@ static char_u *get_buffcont(buffheader_T *buffer, int dozero) /// K_SPECIAL in the returned string is escaped. char_u *get_recorded(void) { - char_u *p; + char *p; size_t len; - p = get_buffcont(&recordbuff, true); + p = (char *)get_buffcont(&recordbuff, true); free_buff(&recordbuff); // Remove the characters that were added the last time, these must be the // (possibly mapped) characters that stopped the recording. - len = STRLEN(p); + len = strlen(p); if (len >= last_recorded_len) { len -= last_recorded_len; p[len] = NUL; @@ -190,7 +190,7 @@ char_u *get_recorded(void) p[len - 1] = NUL; } - return p; + return (char_u *)p; } /// Return the contents of the redo buffer as a single string. @@ -2237,7 +2237,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth) // If this is a LANGMAP mapping, then we didn't record the keys // at the start of the function and have to record them now. if (keylen > typebuf.tb_maplen && (mp->m_mode & MODE_LANGMAP) != 0) { - gotchars((char_u *)map_str, STRLEN(map_str)); + gotchars((char_u *)map_str, strlen(map_str)); } if (save_m_noremap != REMAP_YES) { diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index c46f95b64f..7cc434a197 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -253,14 +253,14 @@ struct prt_resfile_buffer_S { // Returns an error message or NULL; char *parse_printoptions(void) { - return parse_list_options((char_u *)p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS); + return parse_list_options(p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS); } // Parse 'printoptions' and set the flags in "printer_opts". // Returns an error message or NULL; char *parse_printmbfont(void) { - return parse_list_options((char_u *)p_pmfn, mbfont_opts, OPT_MBFONT_NUM_OPTIONS); + return parse_list_options(p_pmfn, mbfont_opts, OPT_MBFONT_NUM_OPTIONS); } // Parse a list of options in the form @@ -270,12 +270,12 @@ char *parse_printmbfont(void) // // Returns an error message for an illegal option, NULL otherwise. // Only used for the printer at the moment... -static char *parse_list_options(char_u *option_str, option_table_T *table, size_t table_size) +static char *parse_list_options(char *option_str, option_table_T *table, size_t table_size) { option_table_T *old_opts; char *ret = NULL; - char_u *stringp; - char_u *colonp; + char *stringp; + char *colonp; char *commap; char *p; size_t idx = 0; // init for GCC @@ -292,14 +292,14 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ // Repeat for all comma separated parts. stringp = option_str; while (*stringp) { - colonp = (char_u *)vim_strchr((char *)stringp, ':'); + colonp = vim_strchr(stringp, ':'); if (colonp == NULL) { ret = N_("E550: Missing colon"); break; } - commap = vim_strchr((char *)stringp, ','); + commap = vim_strchr(stringp, ','); if (commap == NULL) { - commap = (char *)option_str + STRLEN(option_str); + commap = option_str + strlen(option_str); } len = (int)(colonp - stringp); @@ -315,7 +315,7 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ break; } - p = (char *)colonp + 1; + p = colonp + 1; table[idx].present = true; if (table[idx].hasnum) { @@ -330,7 +330,7 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_ table[idx].string = (char_u *)p; table[idx].strlen = (int)(commap - p); - stringp = (char_u *)commap; + stringp = commap; if (*stringp == ',') { stringp++; } @@ -1171,8 +1171,8 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] = // VIM Prolog CIDProlog // 6.2 1.3 // 7.0 1.4 1.0 -#define PRT_PROLOG_VERSION ((char_u *)"1.4") -#define PRT_CID_PROLOG_VERSION ((char_u *)"1.0") +#define PRT_PROLOG_VERSION "1.4" +#define PRT_CID_PROLOG_VERSION "1.0" // Strings to look for in a PS resource file #define PRT_RESOURCE_HEADER "%!PS-Adobe-" @@ -1737,11 +1737,11 @@ static bool prt_open_resource(struct prt_ps_resource_S *resource) return true; } -static bool prt_check_resource(const struct prt_ps_resource_S *resource, const char_u *version) +static bool prt_check_resource(const struct prt_ps_resource_S *resource, const char *version) FUNC_ATTR_NONNULL_ALL { // Version number m.n should match, the revision number does not matter - if (STRNCMP(resource->version, version, STRLEN(version))) { + if (STRNCMP(resource->version, version, strlen(version))) { semsg(_("E621: \"%s\" resource file has wrong version"), resource->name); return false; diff --git a/src/nvim/help.c b/src/nvim/help.c index 7c61a56785..5cc2cda52b 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -659,7 +659,7 @@ void fix_help_buffer(void) if (!syntax_present(curwin)) { for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { line = ml_get_buf(curbuf, lnum, false); - const size_t len = STRLEN(line); + const size_t len = strlen(line); if (in_example && len > 0 && !ascii_iswhite(line[0])) { // End of example: non-white or '<' in first column. if (line[0] == '<') { diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 0f7a5a8e44..2509388009 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -434,10 +434,10 @@ int get_indent_str_vtab(const char *ptr, long ts, long *vts, bool list) // Returns true if the line was changed. int set_indent(int size, int flags) { - char_u *p; - char_u *newline; - char_u *oldline; - char_u *s; + char *p; + char *newline; + char *oldline; + char *s; int todo; int ind_len; // Measured in characters. int line_len; @@ -454,7 +454,7 @@ int set_indent(int size, int flags) // characters needed for the indent. todo = size; ind_len = 0; - p = oldline = (char_u *)get_cursor_line_ptr(); + p = oldline = get_cursor_line_ptr(); // Calculate the buffer size for the new indent, and check to see if it // isn't already set. @@ -549,7 +549,7 @@ int set_indent(int size, int flags) if (flags & SIN_INSERT) { p = oldline; } else { - p = (char_u *)skipwhite((char *)p); + p = skipwhite(p); } line_len = (int)STRLEN(p) + 1; @@ -631,7 +631,7 @@ int set_indent(int size, int flags) todo -= tab_pad; ind_done += tab_pad; } - p = (char_u *)skipwhite((char *)p); + p = skipwhite(p); } for (;;) { @@ -659,7 +659,7 @@ int set_indent(int size, int flags) const colnr_T new_offset = (colnr_T)(s - newline); // this may free "newline" - ml_replace(curwin->w_cursor.lnum, (char *)newline, false); + ml_replace(curwin->w_cursor.lnum, newline, false); if (!(flags & SIN_NOMARK)) { extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, @@ -1130,13 +1130,13 @@ int get_lisp_indent(void) static int lisp_match(char_u *p) { - char_u buf[LSIZE]; + char buf[LSIZE]; int len; char *word = (char *)(*curbuf->b_p_lw != NUL ? (char_u *)curbuf->b_p_lw : p_lispwords); while (*word != NUL) { - (void)copy_option_part(&word, (char *)buf, LSIZE, ","); - len = (int)STRLEN(buf); + (void)copy_option_part(&word, buf, LSIZE, ","); + len = (int)strlen(buf); if ((STRNCMP(buf, p, len) == 0) && (p[len] == ' ')) { return true; diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 643b7f477c..f136aa960b 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -1311,9 +1311,9 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i // to only match at the start of a line. Otherwise just match the // pattern. Also need to double backslashes. if (ctrl_x_mode_line_or_eval()) { - char_u *pat_esc = vim_strsave_escaped(pat, (char_u *)"\\"); + char *pat_esc = (char *)vim_strsave_escaped(pat, (char_u *)"\\"); - size_t len = STRLEN(pat_esc) + 10; + size_t len = strlen(pat_esc) + 10; ptr = xmalloc(len); vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc); regmatch.regprog = vim_regcomp((char *)ptr, RE_MAGIC); @@ -1788,13 +1788,13 @@ static void ins_compl_set_original_text(char *str) /// matches. void ins_compl_addfrommatch(void) { - char_u *p; + char *p; int len = (int)curwin->w_cursor.col - (int)compl_col; int c; compl_T *cp; assert(compl_shown_match != NULL); - p = (char_u *)compl_shown_match->cp_str; - if ((int)STRLEN(p) <= len) { // the match is too short + p = compl_shown_match->cp_str; + if ((int)strlen(p) <= len) { // the match is too short // When still at the original match use the first entry that matches // the leader. if (!match_at_original_text(compl_shown_match)) { @@ -1805,17 +1805,17 @@ void ins_compl_addfrommatch(void) for (cp = compl_shown_match->cp_next; cp != NULL && !is_first_match(cp); cp = cp->cp_next) { if (compl_leader == NULL - || ins_compl_equal(cp, (char_u *)compl_leader, STRLEN(compl_leader))) { - p = (char_u *)cp->cp_str; + || ins_compl_equal(cp, (char_u *)compl_leader, strlen(compl_leader))) { + p = cp->cp_str; break; } } - if (p == NULL || (int)STRLEN(p) <= len) { + if (p == NULL || (int)strlen(p) <= len) { return; } } p += len; - c = utf_ptr2char((char *)p); + c = utf_ptr2char(p); ins_compl_addleader(c); } @@ -2008,17 +2008,17 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval) // but only do this, if the Popup is still visible if (c == Ctrl_E) { ins_compl_delete(); - char_u *p = NULL; + char *p = NULL; if (compl_leader != NULL) { - p = (char_u *)compl_leader; + p = compl_leader; } else if (compl_first_match != NULL) { - p = (char_u *)compl_orig_text; + p = compl_orig_text; } if (p != NULL) { const int compl_len = get_compl_len(); - const int len = (int)STRLEN(p); + const int len = (int)strlen(p); if (len > compl_len) { - ins_bytes_len((char *)p + compl_len, (size_t)(len - compl_len)); + ins_bytes_len(p + compl_len, (size_t)(len - compl_len)); } } retval = true; @@ -2929,33 +2929,33 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p bool *cont_s_ipos) { *match_len = 0; - char_u *ptr = (char_u *)ml_get_buf(ins_buf, cur_match_pos->lnum, false) + cur_match_pos->col; + char *ptr = ml_get_buf(ins_buf, cur_match_pos->lnum, false) + cur_match_pos->col; int len; if (ctrl_x_mode_line_or_eval()) { if (compl_status_adding()) { if (cur_match_pos->lnum >= ins_buf->b_ml.ml_line_count) { return NULL; } - ptr = (char_u *)ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false); + ptr = ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false); if (!p_paste) { - ptr = (char_u *)skipwhite((char *)ptr); + ptr = skipwhite(ptr); } } - len = (int)STRLEN(ptr); + len = (int)strlen(ptr); } else { - char_u *tmp_ptr = ptr; + char *tmp_ptr = ptr; - if (compl_status_adding() && compl_length <= (int)STRLEN(tmp_ptr)) { + if (compl_status_adding() && compl_length <= (int)strlen(tmp_ptr)) { tmp_ptr += compl_length; // Skip if already inside a word. - if (vim_iswordp(tmp_ptr)) { + if (vim_iswordp((char_u *)tmp_ptr)) { return NULL; } // Find start of next word. - tmp_ptr = find_word_start(tmp_ptr); + tmp_ptr = (char *)find_word_start((char_u *)tmp_ptr); } // Find end of this word. - tmp_ptr = find_word_end(tmp_ptr); + tmp_ptr = (char *)find_word_end((char_u *)tmp_ptr); len = (int)(tmp_ptr - ptr); if (compl_status_adding() && len == compl_length) { @@ -2964,12 +2964,12 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p // normal command "J" was used. IOSIZE is always greater than // compl_length, so the next STRNCPY always works -- Acevedo STRNCPY(IObuff, ptr, len); // NOLINT(runtime/printf) - ptr = (char_u *)ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false); - tmp_ptr = ptr = (char_u *)skipwhite((char *)ptr); + ptr = ml_get_buf(ins_buf, cur_match_pos->lnum + 1, false); + tmp_ptr = ptr = skipwhite(ptr); // Find start of next word. - tmp_ptr = find_word_start(tmp_ptr); + tmp_ptr = (char *)find_word_start((char_u *)tmp_ptr); // Find end of next word. - tmp_ptr = find_word_end(tmp_ptr); + tmp_ptr = (char *)find_word_end((char_u *)tmp_ptr); if (tmp_ptr > ptr) { if (*ptr != ')' && IObuff[len - 1] != TAB) { if (IObuff[len - 1] != ' ') { @@ -2992,7 +2992,7 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p *cont_s_ipos = true; } IObuff[len] = NUL; - ptr = (char_u *)IObuff; + ptr = IObuff; } if (len == compl_length) { return NULL; @@ -3001,7 +3001,7 @@ static char_u *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_p } *match_len = len; - return ptr; + return (char_u *)ptr; } /// Get the next set of words matching "compl_pattern" for default completion(s) @@ -3285,7 +3285,7 @@ static int ins_compl_get_exp(pos_T *ini) static void ins_compl_update_shown_match(void) { while (!ins_compl_equal(compl_shown_match, - (char_u *)compl_leader, STRLEN(compl_leader)) + (char_u *)compl_leader, strlen(compl_leader)) && compl_shown_match->cp_next != NULL && !is_first_match(compl_shown_match->cp_next)) { compl_shown_match = compl_shown_match->cp_next; @@ -3294,10 +3294,10 @@ static void ins_compl_update_shown_match(void) // If we didn't find it searching forward, and compl_shows_dir is // backward, find the last match. if (compl_shows_dir_backward() - && !ins_compl_equal(compl_shown_match, (char_u *)compl_leader, STRLEN(compl_leader)) + && !ins_compl_equal(compl_shown_match, (char_u *)compl_leader, strlen(compl_leader)) && (compl_shown_match->cp_next == NULL || is_first_match(compl_shown_match->cp_next))) { - while (!ins_compl_equal(compl_shown_match, (char_u *)compl_leader, STRLEN(compl_leader)) + while (!ins_compl_equal(compl_shown_match, (char_u *)compl_leader, strlen(compl_leader)) && compl_shown_match->cp_prev != NULL && !is_first_match(compl_shown_match->cp_prev)) { compl_shown_match = compl_shown_match->cp_prev; @@ -3442,7 +3442,7 @@ static int find_next_completion_match(bool allow_get_expansion, int todo, bool a if (!match_at_original_text(compl_shown_match) && compl_leader != NULL && !ins_compl_equal(compl_shown_match, - (char_u *)compl_leader, STRLEN(compl_leader))) { + (char_u *)compl_leader, strlen(compl_leader))) { todo++; } else { // Remember a matching item. @@ -3721,17 +3721,17 @@ static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col) compl_pattern = xstrnsave(line + compl_col, (size_t)compl_length); } } else if (compl_status_adding()) { - char_u *prefix = (char_u *)"\\<"; + char *prefix = "\\<"; // we need up to 2 extra chars for the prefix compl_pattern = xmalloc(quote_meta(NULL, (char_u *)line + compl_col, compl_length) + 2); if (!vim_iswordp((char_u *)line + compl_col) || (compl_col > 0 && (vim_iswordp(mb_prevptr((char_u *)line, (char_u *)line + compl_col))))) { - prefix = (char_u *)""; + prefix = ""; } STRCPY(compl_pattern, prefix); - (void)quote_meta((char_u *)compl_pattern + STRLEN(prefix), + (void)quote_meta((char_u *)compl_pattern + strlen(prefix), (char_u *)line + compl_col, compl_length); } else if (--startcol < 0 || !vim_iswordp(mb_prevptr((char_u *)line, (char_u *)line + startcol + 1))) { diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index f3821f149a..fca07ee146 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1758,7 +1758,7 @@ static void nlua_add_treesitter(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL lua_setfield(lstate, -2, "_ts_get_minimum_language_version"); } -int nlua_expand_pat(expand_T *xp, char_u *pat, int *num_results, char ***results) +int nlua_expand_pat(expand_T *xp, char *pat, int *num_results, char ***results) { lua_State *const lstate = global_lstate; int ret = OK; @@ -1771,7 +1771,7 @@ int nlua_expand_pat(expand_T *xp, char_u *pat, int *num_results, char ***results luaL_checktype(lstate, -1, LUA_TFUNCTION); // [ vim, vim._expand_pat, buf ] - lua_pushlstring(lstate, (const char *)pat, STRLEN(pat)); + lua_pushlstring(lstate, (const char *)pat, strlen(pat)); if (nlua_pcall(lstate, 1, 2) != 0) { nlua_error(lstate, diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 2f46f6ff65..6974c6181c 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -111,14 +111,14 @@ static int regex_match_line(lua_State *lstate) return luaL_error(lstate, "invalid row"); } - char_u *line = (char_u *)ml_get_buf(buf, rownr + 1, false); - size_t len = STRLEN(line); + char *line = ml_get_buf(buf, rownr + 1, false); + size_t len = strlen(line); if (start < 0 || (size_t)start > len) { return luaL_error(lstate, "invalid start"); } - char_u save = NUL; + char save = NUL; if (end >= 0) { if ((size_t)end > len || end < start) { return luaL_error(lstate, "invalid end"); @@ -127,7 +127,7 @@ static int regex_match_line(lua_State *lstate) line[end] = NUL; } - int nret = regex_match(lstate, prog, line + start); + int nret = regex_match(lstate, prog, (char_u *)line + start); if (end >= 0) { line[end] = save; diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index 79b11eca4a..9d871939f8 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -333,7 +333,7 @@ static const char *input_cb(void *payload, uint32_t byte_index, TSPoint position return ""; } char *line = ml_get_buf(bp, (linenr_T)position.row + 1, false); - size_t len = STRLEN(line); + size_t len = strlen(line); if (position.column > len) { *bytes_read = 0; return ""; diff --git a/src/nvim/mark.c b/src/nvim/mark.c index f41793c8a6..8172aec543 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1698,18 +1698,18 @@ void mark_mb_adjustpos(buf_T *buf, pos_T *lp) FUNC_ATTR_NONNULL_ALL { if (lp->col > 0 || lp->coladd > 1) { - const char_u *const p = (char_u *)ml_get_buf(buf, lp->lnum, false); - if (*p == NUL || (int)STRLEN(p) < lp->col) { + const char *const p = ml_get_buf(buf, lp->lnum, false); + if (*p == NUL || (int)strlen(p) < lp->col) { lp->col = 0; } else { - lp->col -= utf_head_off((char *)p, (char *)p + lp->col); + lp->col -= utf_head_off(p, p + lp->col); } // Reset "coladd" when the cursor would be on the right half of a // double-wide character. if (lp->coladd == 1 && p[lp->col] != TAB - && vim_isprintc(utf_ptr2char((char *)p + lp->col)) - && ptr2cells((char *)p + lp->col) > 1) { + && vim_isprintc(utf_ptr2char(p + lp->col)) + && ptr2cells(p + lp->col) > 1) { lp->coladd = 0; } } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 0ef7b76de3..1ac8d7013e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2622,7 +2622,7 @@ void may_clear_cmdline(void) // Routines for displaying a partly typed command #define SHOWCMD_BUFLEN (SHOWCMD_COLS + 1 + 30) -static char_u showcmd_buf[SHOWCMD_BUFLEN]; +static char showcmd_buf[SHOWCMD_BUFLEN]; static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd() static bool showcmd_is_clear = true; static bool showcmd_visual = false; @@ -2662,10 +2662,10 @@ void clear_showcmd(void) getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol); p_sbr = saved_sbr; curwin->w_p_sbr = saved_w_sbr; - snprintf((char *)showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64 "x%" PRId64, + snprintf(showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64 "x%" PRId64, (int64_t)lines, (int64_t)rightcol - leftcol + 1); } else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) { - snprintf((char *)showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64, (int64_t)lines); + snprintf(showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64, (int64_t)lines); } else { char_u *s, *e; int l; @@ -2691,9 +2691,9 @@ void clear_showcmd(void) s += l; } if (bytes == chars) { - sprintf((char *)showcmd_buf, "%d", chars); + snprintf(showcmd_buf, SHOWCMD_BUFLEN, "%d", chars); } else { - sprintf((char *)showcmd_buf, "%d-%d", chars, bytes); + snprintf(showcmd_buf, SHOWCMD_BUFLEN, "%d-%d", chars, bytes); } } int limit = ui_has(kUIMessages) ? SHOWCMD_BUFLEN - 1 : SHOWCMD_COLS; @@ -2783,7 +2783,7 @@ static void del_from_showcmd(int len) return; } - old_len = (int)STRLEN(showcmd_buf); + old_len = (int)strlen(showcmd_buf); if (len > old_len) { len = old_len; } @@ -2822,7 +2822,7 @@ static void display_showcmd(void) } int len; - len = (int)STRLEN(showcmd_buf); + len = (int)strlen(showcmd_buf); showcmd_is_clear = (len == 0); if (ui_has(kUIMessages)) { @@ -2831,7 +2831,7 @@ static void display_showcmd(void) if (len > 0) { // placeholder for future highlight support ADD_C(chunk, INTEGER_OBJ(0)); - ADD_C(chunk, STRING_OBJ(cstr_as_string((char *)showcmd_buf))); + ADD_C(chunk, STRING_OBJ(cstr_as_string(showcmd_buf))); ADD_C(content, ARRAY_OBJ(chunk)); } ui_call_msg_showcmd(content); @@ -2843,7 +2843,7 @@ static void display_showcmd(void) grid_puts_line_start(&msg_grid_adj, showcmd_row); if (!showcmd_is_clear) { - grid_puts(&msg_grid_adj, (char *)showcmd_buf, showcmd_row, sc_col, + grid_puts(&msg_grid_adj, showcmd_buf, showcmd_row, sc_col, HL_ATTR(HLF_MSG)); } @@ -4360,7 +4360,7 @@ static void nv_ident(cmdarg_T *cap) aux_ptr = "\\|\"\n*?["; } - p = buf + STRLEN(buf); + p = buf + strlen(buf); while (n-- > 0) { // put a backslash before \ and some others if (vim_strchr(aux_ptr, *ptr) != NULL) { @@ -5295,7 +5295,7 @@ static void nv_kundo(cmdarg_T *cap) /// Handle the "r" command. static void nv_replace(cmdarg_T *cap) { - char_u *ptr; + char *ptr; int had_ctrl_v; if (checkclearop(cap->oap)) { @@ -5358,9 +5358,9 @@ static void nv_replace(cmdarg_T *cap) } // Abort if not enough characters to replace. - ptr = (char_u *)get_cursor_pos_ptr(); - if (STRLEN(ptr) < (unsigned)cap->count1 - || (mb_charlen(ptr) < cap->count1)) { + ptr = get_cursor_pos_ptr(); + if (strlen(ptr) < (unsigned)cap->count1 + || (mb_charlen((char_u *)ptr) < cap->count1)) { clearopbeep(cap->oap); return; } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 3bb397fdd8..8b2fea9535 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -418,7 +418,7 @@ static void shift_block(oparg_T *oap, int amount) size_t fill; // nr of spaces that replace a TAB size_t new_line_len; // the length of the line after the // block shift - char_u *non_white = bd.textstart; + char *non_white = (char *)bd.textstart; // Firstly, let's find the first non-whitespace character that is // displayed after the block's start column and the character's column @@ -438,13 +438,13 @@ static void shift_block(oparg_T *oap, int amount) chartabsize_T cts; init_chartabsize_arg(&cts, curwin, curwin->w_cursor.lnum, - non_white_col, (char *)bd.textstart, (char *)non_white); + non_white_col, (char *)bd.textstart, non_white); while (ascii_iswhite(*cts.cts_ptr)) { incr = lbr_chartabsize_adv(&cts); cts.cts_vcol += incr; } non_white_col = cts.cts_vcol; - non_white = (char_u *)cts.cts_ptr; + non_white = cts.cts_ptr; clear_chartabsize_arg(&cts); const colnr_T block_space_width = non_white_col - oap->start_vcol; @@ -492,11 +492,11 @@ static void shift_block(oparg_T *oap, int amount) // - the beginning of the original line up to "verbatim_copy_end", // - "fill" number of spaces, // - the rest of the line, pointed to by non_white. - new_line_len = verbatim_diff + fill + STRLEN(non_white) + 1; + new_line_len = verbatim_diff + fill + strlen(non_white) + 1; newp = (char_u *)xmalloc(new_line_len); startcol = (int)verbatim_diff; - oldlen = bd.textcol + (int)(non_white - bd.textstart) - (int)verbatim_diff; + oldlen = bd.textcol + (int)(non_white - (char *)bd.textstart) - (int)verbatim_diff; newlen = (int)fill; memmove(newp, oldp, verbatim_diff); memset(newp + verbatim_diff, ' ', fill); @@ -515,14 +515,14 @@ static void shift_block(oparg_T *oap, int amount) /// Insert string "s" (b_insert ? before : after) block :AKelly /// Caller must prepare for undo. -static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def *bdp) +static void block_insert(oparg_T *oap, char *s, int b_insert, struct block_def *bdp) { int ts_val; int count = 0; // extra spaces to replace a cut TAB int spaces = 0; // non-zero if cutting a TAB colnr_T offset; // pointer along new line - size_t s_len = STRLEN(s); - char_u *newp, *oldp; // new, old lines + size_t s_len = strlen(s); + char *newp, *oldp; // new, old lines linenr_T lnum; // loop var int oldstate = State; State = MODE_INSERT; // don't want MODE_REPLACE for State @@ -533,7 +533,7 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def continue; // OP_INSERT, line ends before block start } - oldp = (char_u *)ml_get(lnum); + oldp = ml_get(lnum); if (b_insert) { ts_val = bdp->start_char_vcols; @@ -562,7 +562,7 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def if (spaces > 0) { // avoid copying part of a multi-byte character - offset -= utf_head_off((char *)oldp, (char *)oldp + offset); + offset -= utf_head_off(oldp, oldp + offset); } if (spaces < 0) { // can happen when the cursor was moved spaces = 0; @@ -570,7 +570,7 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def assert(count >= 0); // Make sure the allocated size matches what is actually copied below. - newp = xmalloc(STRLEN(oldp) + (size_t)spaces + s_len + newp = xmalloc(strlen(oldp) + (size_t)spaces + s_len + (spaces > 0 && !bdp->is_short ? (size_t)ts_val - (size_t)spaces : 0) + (size_t)count + 1); @@ -607,7 +607,7 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def } STRMOVE(newp + offset, oldp); - ml_replace(lnum, (char *)newp, false); + ml_replace(lnum, newp, false); extmark_splice_cols(curbuf, (int)lnum - 1, startcol, skipped, offset - startcol, kExtmarkUndo); @@ -706,7 +706,7 @@ void op_reindent(oparg_T *oap, Indenter how) } // Keep the last expression line here, for repeating. -static char_u *expr_line = NULL; +static char *expr_line = NULL; /// Get an expression for the "\"=expr1" or "CTRL-R =expr1" /// @@ -732,7 +732,7 @@ int get_expr_register(void) void set_expr_line(char *new_line) { xfree(expr_line); - expr_line = (char_u *)new_line; + expr_line = new_line; } /// Get the result of the '=' register expression. @@ -750,7 +750,7 @@ char *get_expr_line(void) // Make a copy of the expression, because evaluating it may cause it to be // changed. - expr_copy = xstrdup((char *)expr_line); + expr_copy = xstrdup(expr_line); // When we are invoked recursively limit the evaluation to 10 levels. // Then return the string as-is. @@ -771,7 +771,7 @@ char *get_expr_line_src(void) if (expr_line == NULL) { return NULL; } - return xstrdup((char *)expr_line); + return xstrdup(expr_line); } /// @return whether `regname` is a valid name of a yank register. @@ -952,7 +952,7 @@ int do_record(int c) // restore the current register name. old_y_previous = y_previous; - retval = stuff_yank(regname, p); + retval = stuff_yank(regname, (char *)p); y_previous = old_y_previous; } @@ -974,7 +974,7 @@ static void set_yreg_additional_data(yankreg_T *reg, dict_T *additional_data) /// uppercase). "p" must have been allocated. /// /// @return FAIL for failure, OK otherwise -static int stuff_yank(int regname, char_u *p) +static int stuff_yank(int regname, char *p) { // check for read-only register if (regname != 0 && !valid_yank_reg(regname, true)) { @@ -988,7 +988,7 @@ static int stuff_yank(int regname, char_u *p) yankreg_T *reg = get_yank_register(regname, YREG_YANK); if (is_append_register(regname) && reg->y_array != NULL) { char **pp = &(reg->y_array[reg->y_size - 1]); - char_u *lp = xmalloc(strlen(*pp) + STRLEN(p) + 1); + char_u *lp = xmalloc(strlen(*pp) + strlen(p) + 1); STRCPY(lp, *pp); // TODO(philix): use xstpcpy() in stuff_yank() STRCAT(lp, p); @@ -999,7 +999,7 @@ static int stuff_yank(int regname, char_u *p) free_register(reg); set_yreg_additional_data(reg, NULL); reg->y_array = xmalloc(sizeof(char_u *)); - reg->y_array[0] = (char *)p; + reg->y_array[0] = p; reg->y_size = 1; reg->y_type = kMTCharWise; } @@ -1448,7 +1448,7 @@ int op_delete(oparg_T *oap) int n; linenr_T lnum; char_u *ptr; - char_u *newp, *oldp; + char *newp, *oldp; struct block_def bd = { 0 }; linenr_T old_lcount = curbuf->b_ml.ml_line_count; @@ -1579,8 +1579,8 @@ int op_delete(oparg_T *oap) // If we delete a TAB, it may be replaced by several characters. // Thus the number of characters may increase! n = bd.textlen - bd.startspaces - bd.endspaces; - oldp = (char_u *)ml_get(lnum); - newp = (char_u *)xmalloc(STRLEN(oldp) - (size_t)n + 1); + oldp = ml_get(lnum); + newp = xmalloc(strlen(oldp) - (size_t)n + 1); // copy up to deleted part memmove(newp, oldp, (size_t)bd.textcol); // insert spaces @@ -1590,7 +1590,7 @@ int op_delete(oparg_T *oap) oldp += bd.textcol + bd.textlen; STRMOVE(newp + bd.textcol + bd.startspaces + bd.endspaces, oldp); // replace the line - ml_replace(lnum, (char *)newp, false); + ml_replace(lnum, newp, false); extmark_splice_cols(curbuf, (int)lnum - 1, bd.textcol, bd.textlen, bd.startspaces + bd.endspaces, @@ -1697,8 +1697,8 @@ int op_delete(oparg_T *oap) if (virtual_op) { // fix up things for virtualedit-delete: // break the tabs which are going to get in our way - char_u *curline = (char_u *)get_cursor_line_ptr(); - int len = (int)STRLEN(curline); + char *curline = get_cursor_line_ptr(); + int len = (int)strlen(curline); if (oap->end.coladd != 0 && (int)oap->end.col >= len - 1 @@ -1811,7 +1811,7 @@ static int op_replace(oparg_T *oap, int c) { int n, numc; int num_chars; - char_u *newp, *oldp; + char *newp, *oldp; colnr_T oldlen; struct block_def bd; char_u *after_p = NULL; @@ -1886,8 +1886,8 @@ static int op_replace(oparg_T *oap, int c) num_chars = numc; numc *= utf_char2len(c); - oldp = (char_u *)get_cursor_line_ptr(); - oldlen = (int)STRLEN(oldp); + oldp = get_cursor_line_ptr(); + oldlen = (int)strlen(oldp); size_t newp_size = (size_t)bd.textcol + (size_t)bd.startspaces; if (had_ctrl_v_cr || (c != '\r' && c != '\n')) { @@ -1913,7 +1913,7 @@ static int op_replace(oparg_T *oap, int c) // strlen(newp) at this point int newp_len = bd.textcol + bd.startspaces; while (--num_chars >= 0) { - newp_len += utf_char2bytes(c, (char *)newp + newp_len); + newp_len += utf_char2bytes(c, newp + newp_len); } if (!bd.is_short) { // insert post-spaces @@ -1931,7 +1931,7 @@ static int op_replace(oparg_T *oap, int c) newrows = 1; } // replace the line - ml_replace(curwin->w_cursor.lnum, (char *)newp, false); + ml_replace(curwin->w_cursor.lnum, newp, false); curbuf_splice_pending++; linenr_T baselnum = curwin->w_cursor.lnum; if (after_p != NULL) { @@ -2408,7 +2408,7 @@ void op_insert(oparg_T *oap, long count1) ins_text = xstrnsave(firstline, (size_t)ins_len); // block handled here if (u_save(oap->start.lnum, (linenr_T)(oap->end.lnum + 1)) == OK) { - block_insert(oap, (char_u *)ins_text, (oap->op_type == OP_INSERT), &bd); + block_insert(oap, ins_text, (oap->op_type == OP_INSERT), &bd); } curwin->w_cursor.col = oap->start.col; @@ -2431,9 +2431,9 @@ int op_change(oparg_T *oap) long pre_textlen = 0; long pre_indent = 0; char_u *newp; - char_u *firstline; + char *firstline; char_u *ins_text; - char_u *oldp; + char *oldp; struct block_def bd; l = oap->start.col; @@ -2465,9 +2465,9 @@ int op_change(oparg_T *oap) || gchar_cursor() == NUL)) { coladvance_force(getviscol()); } - firstline = (char_u *)ml_get(oap->start.lnum); - pre_textlen = (long)STRLEN(firstline); - pre_indent = (long)getwhitecols((char *)firstline); + firstline = ml_get(oap->start.lnum); + pre_textlen = (long)strlen(firstline); + pre_indent = (long)getwhitecols(firstline); bd.textcol = curwin->w_cursor.col; } @@ -2484,15 +2484,15 @@ int op_change(oparg_T *oap) && oap->start.lnum != oap->end.lnum && !got_int) { // Auto-indenting may have changed the indent. If the cursor was past // the indent, exclude that indent change from the inserted text. - firstline = (char_u *)ml_get(oap->start.lnum); + firstline = ml_get(oap->start.lnum); if (bd.textcol > (colnr_T)pre_indent) { - long new_indent = (long)getwhitecols((char *)firstline); + long new_indent = (long)getwhitecols(firstline); pre_textlen += new_indent - pre_indent; bd.textcol += (colnr_T)(new_indent - pre_indent); } - ins_len = (long)STRLEN(firstline) - pre_textlen; + ins_len = (long)strlen(firstline) - pre_textlen; if (ins_len > 0) { // Subsequent calls to ml_get() flush the firstline data - take a // copy of the inserted text. @@ -2512,8 +2512,8 @@ int op_change(oparg_T *oap) } else { vpos.coladd = 0; } - oldp = (char_u *)ml_get(linenr); - newp = xmalloc(STRLEN(oldp) + (size_t)vpos.coladd + oldp = ml_get(linenr); + newp = xmalloc(strlen(oldp) + (size_t)vpos.coladd + (size_t)ins_len + 1); // copy up to block start memmove(newp, oldp, (size_t)bd.textcol); @@ -2604,7 +2604,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) MotionType yank_type = oap->motion_type; size_t yanklines = (size_t)oap->line_count; linenr_T yankendlnum = oap->end.lnum; - char_u *p; + char *p; char_u *pnew; struct block_def bd; @@ -2663,7 +2663,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) colnr_T startcol = 0, endcol = MAXCOL; int is_oneChar = false; colnr_T cs, ce; - p = (char_u *)ml_get(lnum); + p = ml_get(lnum); bd.startspaces = 0; bd.endspaces = 0; @@ -2688,7 +2688,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) // Don't add space for double-wide // char; endcol will be on last byte // of multi-byte char. - && utf_head_off((char *)p, (char *)p + endcol) == 0)) { + && utf_head_off(p, p + endcol) == 0)) { if (oap->start.lnum == oap->end.lnum && oap->start.col == oap->end.col) { // Special case: inside a single char @@ -2705,7 +2705,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) } } if (endcol == MAXCOL) { - endcol = (colnr_T)STRLEN(p); + endcol = (colnr_T)strlen(p); } if (startcol > endcol || is_oneChar) { @@ -2713,7 +2713,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) } else { bd.textlen = endcol - startcol + oap->inclusive; } - bd.textstart = p + startcol; + bd.textstart = (char_u *)p + startcol; yank_copy_line(reg, &bd, y_idx, false); break; } @@ -3874,9 +3874,9 @@ void ex_display(exarg_T *eap) // display last used expression if (expr_line != NULL && (arg == NULL || vim_strchr((char *)arg, '=') != NULL) - && !got_int && !message_filtered((char *)expr_line)) { + && !got_int && !message_filtered(expr_line)) { msg_puts("\n c \"= "); - dis_msg((char *)expr_line, false); + dis_msg(expr_line, false); } } @@ -4452,12 +4452,12 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) { int col; char_u *buf1 = NULL; - char_u buf2[NUMBUFLEN]; + char buf2[NUMBUFLEN]; int pre; // 'X' or 'x': hex; '0': octal; 'B' or 'b': bin static bool hexupper = false; // 0xABC uvarnumber_T n; uvarnumber_T oldn; - char_u *ptr; + char *ptr; int c; int todel; int firstdigit; @@ -4484,10 +4484,10 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) } curwin->w_cursor = *pos; - ptr = (char_u *)ml_get(pos->lnum); + ptr = ml_get(pos->lnum); col = pos->col; - if (*ptr == NUL || col + !!save_coladd >= (int)STRLEN(ptr)) { + if (*ptr == NUL || col + !!save_coladd >= (int)strlen(ptr)) { goto theend; } @@ -4496,14 +4496,14 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) if (do_bin) { while (col > 0 && ascii_isbdigit(ptr[col])) { col--; - col -= utf_head_off((char *)ptr, (char *)ptr + col); + col -= utf_head_off(ptr, ptr + col); } } if (do_hex) { while (col > 0 && ascii_isxdigit(ptr[col])) { col--; - col -= utf_head_off((char *)ptr, (char *)ptr + col); + col -= utf_head_off(ptr, ptr + col); } } if (do_bin @@ -4511,7 +4511,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) && !((col > 0 && (ptr[col] == 'X' || ptr[col] == 'x') && ptr[col - 1] == '0' - && !utf_head_off((char *)ptr, (char *)ptr + col - 1) + && !utf_head_off(ptr, ptr + col - 1) && ascii_isxdigit(ptr[col + 1])))) { // In case of binary/hexadecimal pattern overlap match, rescan @@ -4519,7 +4519,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) while (col > 0 && ascii_isdigit(ptr[col])) { col--; - col -= utf_head_off((char *)ptr, (char *)ptr + col); + col -= utf_head_off(ptr, ptr + col); } } @@ -4527,17 +4527,17 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) && col > 0 && (ptr[col] == 'X' || ptr[col] == 'x') && ptr[col - 1] == '0' - && !utf_head_off((char *)ptr, (char *)ptr + col - 1) + && !utf_head_off(ptr, ptr + col - 1) && ascii_isxdigit(ptr[col + 1])) || (do_bin && col > 0 && (ptr[col] == 'B' || ptr[col] == 'b') && ptr[col - 1] == '0' - && !utf_head_off((char *)ptr, (char *)ptr + col - 1) + && !utf_head_off(ptr, ptr + col - 1) && ascii_isbdigit(ptr[col + 1]))) { // Found hexadecimal or binary number, move to its start. col--; - col -= utf_head_off((char *)ptr, (char *)ptr + col); + col -= utf_head_off(ptr, ptr + col); } else { // Search forward and then backward to find the start of number. col = pos->col; @@ -4559,7 +4559,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) if (visual) { while (ptr[col] != NUL && length > 0 && !ascii_isdigit(ptr[col]) && !(do_alpha && ASCII_ISALPHA(ptr[col]))) { - int mb_len = utfc_ptr2len((char *)ptr + col); + int mb_len = utfc_ptr2len(ptr + col); col += mb_len; length -= mb_len; @@ -4570,7 +4570,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) } if (col > pos->col && ptr[col - 1] == '-' - && !utf_head_off((char *)ptr, (char *)ptr + col - 1) + && !utf_head_off(ptr, ptr + col - 1) && !do_unsigned) { negative = true; was_positive = false; @@ -4578,7 +4578,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) } // If a number was found, and saving for undo works, replace the number. - firstdigit = ptr[col]; + firstdigit = (uint8_t)ptr[col]; if (!ascii_isdigit(firstdigit) && !(do_alpha && ASCII_ISALPHA(firstdigit))) { beep_flush(); goto theend; @@ -4616,7 +4616,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) curwin->w_cursor.col = col; } else { if (col > 0 && ptr[col - 1] == '-' - && !utf_head_off((char *)ptr, (char *)ptr + col - 1) + && !utf_head_off(ptr, ptr + col - 1) && !visual && !do_unsigned) { // negative number @@ -4627,11 +4627,11 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) // get the number value (unsigned) if (visual && VIsual_mode != 'V') { maxlen = (curbuf->b_visual.vi_curswant == MAXCOL - ? (int)STRLEN(ptr) - col + ? (int)strlen(ptr) - col : length); } - vim_str2nr((char *)ptr + col, &pre, &length, + vim_str2nr(ptr + col, &pre, &length, 0 + (do_bin ? STR2NR_BIN : 0) + (do_oct ? STR2NR_OCT : 0) + (do_hex ? STR2NR_HEX : 0), @@ -4723,7 +4723,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) // When there are many leading zeros it could be very long. // Allocate a bit too much. buf1 = xmalloc((size_t)length + NUMBUFLEN); - ptr = buf1; + ptr = (char *)buf1; if (negative && (!visual || was_positive)) { *ptr++ = '-'; } @@ -4732,7 +4732,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) length--; } if (pre == 'b' || pre == 'B' || pre == 'x' || pre == 'X') { - *ptr++ = (char_u)pre; + *ptr++ = (char)pre; length--; } @@ -4754,15 +4754,15 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1) buf2[i] = '\0'; } else if (pre == 0) { - vim_snprintf((char *)buf2, ARRAY_SIZE(buf2), "%" PRIu64, (uint64_t)n); + vim_snprintf(buf2, ARRAY_SIZE(buf2), "%" PRIu64, (uint64_t)n); } else if (pre == '0') { - vim_snprintf((char *)buf2, ARRAY_SIZE(buf2), "%" PRIo64, (uint64_t)n); + vim_snprintf(buf2, ARRAY_SIZE(buf2), "%" PRIo64, (uint64_t)n); } else if (hexupper) { - vim_snprintf((char *)buf2, ARRAY_SIZE(buf2), "%" PRIX64, (uint64_t)n); + vim_snprintf(buf2, ARRAY_SIZE(buf2), "%" PRIX64, (uint64_t)n); } else { - vim_snprintf((char *)buf2, ARRAY_SIZE(buf2), "%" PRIx64, (uint64_t)n); + vim_snprintf(buf2, ARRAY_SIZE(buf2), "%" PRIx64, (uint64_t)n); } - length -= (int)STRLEN(buf2); + length -= (int)strlen(buf2); // Adjust number of zeros to the new number of digits, so the // total length of the number remains the same. @@ -5032,7 +5032,7 @@ void write_reg_contents_lst(int name, char **strings, bool must_append, MotionTy return; } - str_to_reg(reg, yank_type, (char *)strings, STRLEN(strings), + str_to_reg(reg, yank_type, (char *)strings, strlen((char *)strings), block_len, true); finish_write_reg(name, reg, old_y_previous); } @@ -5096,7 +5096,7 @@ void write_reg_contents_ex(int name, const char *str, ssize_t len, bool must_app if (must_append && expr_line) { // append has been specified and expr_line already exists, so we'll // append the new string to expr_line. - size_t exprlen = STRLEN(expr_line); + size_t exprlen = strlen(expr_line); totlen += exprlen; offset = exprlen; @@ -5186,8 +5186,8 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str, // Find the end of each line and save it into the array. if (str_list) { - for (char_u **ss = (char_u **)str; *ss != NULL; ss++, lnum++) { - size_t ss_len = STRLEN(*ss); + for (char **ss = (char **)str; *ss != NULL; ss++, lnum++) { + size_t ss_len = strlen(*ss); pp[lnum] = xmemdupz(*ss, ss_len); if (ss_len > maxlen) { maxlen = ss_len; @@ -5294,7 +5294,7 @@ static varnumber_T line_count_info(char_u *line, varnumber_T *wc, varnumber_T *c /// @param dict when not NULL, store the info there instead of showing it. void cursor_pos_info(dict_T *dict) { - char_u *p; + char *p; char_u buf1[50]; char_u buf2[40]; linenr_T lnum; @@ -5378,7 +5378,7 @@ void cursor_pos_info(dict_T *dict) // Do extra processing for VIsual mode. if (l_VIsual_active && lnum >= min_pos.lnum && lnum <= max_pos.lnum) { - char_u *s = NULL; + char *s = NULL; long len = 0L; switch (l_VIsual_mode) { @@ -5386,11 +5386,11 @@ void cursor_pos_info(dict_T *dict) virtual_op = virtual_active(); block_prep(&oparg, &bd, lnum, false); virtual_op = kNone; - s = bd.textstart; + s = (char *)bd.textstart; len = (long)bd.textlen; break; case 'V': - s = (char_u *)ml_get(lnum); + s = ml_get(lnum); len = MAXCOL; break; case 'v': { @@ -5399,18 +5399,18 @@ void cursor_pos_info(dict_T *dict) colnr_T end_col = (lnum == max_pos.lnum) ? max_pos.col - start_col + 1 : MAXCOL; - s = (char_u *)ml_get(lnum) + start_col; + s = ml_get(lnum) + start_col; len = end_col; } break; } if (s != NULL) { - byte_count_cursor += line_count_info(s, &word_count_cursor, + byte_count_cursor += line_count_info((char_u *)s, &word_count_cursor, &char_count_cursor, len, eol_size); if (lnum == curbuf->b_ml.ml_line_count && !curbuf->b_p_eol && (curbuf->b_p_bin || !curbuf->b_p_fixeol) - && (long)STRLEN(s) < len) { + && (long)strlen(s) < len) { byte_count_cursor -= eol_size; } } @@ -5471,11 +5471,11 @@ void cursor_pos_info(dict_T *dict) (int64_t)byte_count_cursor, (int64_t)byte_count); } } else { - p = (char_u *)get_cursor_line_ptr(); + p = get_cursor_line_ptr(); validate_virtcol(); col_print((char *)buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1); - col_print((char *)buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p)); + col_print((char *)buf2, sizeof(buf2), (int)strlen(p), linetabsize((char_u *)p)); if (char_count_cursor == byte_count_cursor && char_count == byte_count) { @@ -5512,14 +5512,14 @@ void cursor_pos_info(dict_T *dict) } if (dict == NULL) { // Don't shorten this message, the user asked for it. - p = (char_u *)p_shm; + p = p_shm; p_shm = ""; if (p_ch < 1) { msg_start(); msg_scroll = true; } msg((char *)IObuff); - p_shm = (char *)p; + p_shm = p; } } @@ -6554,8 +6554,8 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) if (TV_LIST_ITEM_TV(tv_list_last(res))->v_type != VAR_STRING) { goto err; } - char_u *regtype = (char_u *)TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string; - if (regtype == NULL || STRLEN(regtype) > 1) { + char *regtype = TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string; + if (regtype == NULL || strlen(regtype) > 1) { goto err; } switch (regtype[0]) { diff --git a/src/nvim/option.c b/src/nvim/option.c index 11a92f7d56..7202156c46 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -219,7 +219,7 @@ void set_init_1(bool clean_arg) xstrlcpy(item, p, len); add_pathsep(item); xstrlcat(item, "*", len); - if (find_dup_item(ga.ga_data, (char_u *)item, options[opt_idx].flags) + if (find_dup_item(ga.ga_data, item, options[opt_idx].flags) == NULL) { ga_grow(&ga, (int)len); if (!GA_EMPTY(&ga)) { @@ -242,15 +242,15 @@ void set_init_1(bool clean_arg) } { - char_u *cdpath; - char_u *buf; + char *cdpath; + char *buf; int i; int j; // Initialize the 'cdpath' option's default value. - cdpath = (char_u *)vim_getenv("CDPATH"); + cdpath = vim_getenv("CDPATH"); if (cdpath != NULL) { - buf = xmalloc(2 * STRLEN(cdpath) + 2); + buf = xmalloc(2 * strlen(cdpath) + 2); { buf[0] = ','; // start with ",", current dir first j = 1; @@ -267,7 +267,7 @@ void set_init_1(bool clean_arg) buf[j] = NUL; opt_idx = findoption("cdpath"); if (opt_idx >= 0) { - options[opt_idx].def_val = (char *)buf; + options[opt_idx].def_val = buf; options[opt_idx].flags |= P_DEF_ALLOCED; } else { xfree(buf); // cannot happen @@ -515,9 +515,9 @@ static void set_string_default(const char *name, char *val, bool allocated) } } -// For an option value that contains comma separated items, find "newval" in -// "origval". Return NULL if not found. -static char_u *find_dup_item(char_u *origval, const char_u *newval, uint32_t flags) +/// For an option value that contains comma separated items, find "newval" in +/// "origval". Return NULL if not found. +static char *find_dup_item(char *origval, const char *newval, uint32_t flags) FUNC_ATTR_NONNULL_ARG(2) { int bs = 0; @@ -526,8 +526,8 @@ static char_u *find_dup_item(char_u *origval, const char_u *newval, uint32_t fla return NULL; } - const size_t newlen = STRLEN(newval); - for (char_u *s = origval; *s != NUL; s++) { + const size_t newlen = strlen(newval); + for (char *s = origval; *s != NUL; s++) { if ((!(flags & P_COMMA) || s == origval || (s[-1] == ',' && !(bs & 1))) && STRNCMP(s, newval, newlen) == 0 && (!(flags & P_COMMA) || s[newlen] == ',' || s[newlen] == NUL)) { @@ -948,7 +948,7 @@ static int do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar, int len = 0; if (op == OP_REMOVING || (flags & P_NODUP)) { len = (int)STRLEN(newval); - s = (char *)find_dup_item(origval, (char_u *)newval, flags); + s = find_dup_item((char *)origval, newval, flags); // do not add if already there if ((op == OP_ADDING || op == OP_PREPENDING) && s != NULL) { @@ -1182,7 +1182,7 @@ int do_set(char *arg, int opt_flags) } len++; if (opt_idx == -1) { - key = find_key_option((char_u *)arg + 1, true); + key = find_key_option(arg + 1, true); } } else { len = 0; @@ -1196,7 +1196,7 @@ int do_set(char *arg, int opt_flags) } opt_idx = findoption_len((const char *)arg, (size_t)len); if (opt_idx == -1) { - key = find_key_option((char_u *)arg, false); + key = find_key_option(arg, false); } } @@ -1543,7 +1543,7 @@ void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked int string_to_key(char_u *arg) { if (*arg == '<') { - return find_key_option(arg + 1, true); + return find_key_option((char *)arg + 1, true); } if (*arg == '^') { return CTRL_CHR(arg[1]); @@ -3151,9 +3151,9 @@ int find_key_option_len(const char_u *arg_arg, size_t len, bool has_lt) return key; } -static int find_key_option(const char_u *arg, bool has_lt) +static int find_key_option(const char *arg, bool has_lt) { - return find_key_option_len(arg, STRLEN(arg), has_lt); + return find_key_option_len((char_u *)arg, strlen(arg), has_lt); } /// if 'all' == 0: show changed options diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index e5bd065aef..196ab865a2 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -679,7 +679,7 @@ EXTERN unsigned ssop_flags; EXTERN char *p_sh; // 'shell' EXTERN char_u *p_shcf; // 'shellcmdflag' EXTERN char *p_sp; // 'shellpipe' -EXTERN char_u *p_shq; // 'shellquote' +EXTERN char *p_shq; // 'shellquote' EXTERN char *p_sxq; // 'shellxquote' EXTERN char_u *p_sxe; // 'shellxescape' EXTERN char *p_srr; // 'shellredir' @@ -775,7 +775,7 @@ EXTERN char *p_shada; ///< 'shada' EXTERN char *p_shadafile; ///< 'shadafile' EXTERN char *p_vsts; ///< 'varsofttabstop' EXTERN char *p_vts; ///< 'vartabstop' -EXTERN char_u *p_vdir; ///< 'viewdir' +EXTERN char *p_vdir; ///< 'viewdir' EXTERN char *p_vop; ///< 'viewoptions' EXTERN unsigned vop_flags; ///< uses SSOP_ flags EXTERN int p_vb; ///< 'visualbell' diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index a65635cf5e..2d8100595f 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3983,7 +3983,7 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, const qfli } if (ml_append_buf(buf, lnum, (char_u *)IObuff, - (colnr_T)STRLEN(IObuff) + 1, false) == FAIL) { + (colnr_T)strlen(IObuff) + 1, false) == FAIL) { return FAIL; } return OK; @@ -4239,7 +4239,7 @@ static char *make_get_fullcmd(const char *makecmd, const char *fname) len += strlen(p_sp) + strlen(fname) + 3; } char *const cmd = xmalloc(len); - snprintf(cmd, len, "%s%s%s", (char *)p_shq, (char *)makecmd, (char *)p_shq); + snprintf(cmd, len, "%s%s%s", p_shq, (char *)makecmd, p_shq); // If 'shellpipe' empty: don't redirect to 'errorfile'. if (*p_sp != NUL) { @@ -5284,7 +5284,7 @@ static bool existing_swapfile(const buf_T *buf) { if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) { const char *const fname = buf->b_ml.ml_mfp->mf_fname; - const size_t len = STRLEN(fname); + const size_t len = strlen(fname); return fname[len - 1] != 'p' || fname[len - 2] != 'w'; } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 90011eb2c7..cd1d6553cb 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -237,12 +237,12 @@ size_t fill_foldcolumn(char_u *p, win_T *wp, foldinfo_T foldinfo, linenr_T lnum) /// Mirror text "str" for right-left displaying. /// Only works for single-byte characters (e.g., numbers). -void rl_mirror(char_u *str) +void rl_mirror(char *str) { - char_u *p1, *p2; - char_u t; + char *p1, *p2; + char t; - for (p1 = str, p2 = str + STRLEN(str) - 1; p1 < p2; p1++, p2--) { + for (p1 = str, p2 = str + strlen(str) - 1; p1 < p2; p1++, p2--) { t = *p1; *p1 = *p2; *p2 = t; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 69c2b027bc..adfbbb9573 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -344,7 +344,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou // Count the word in the first language where it's found to be OK. if (count_word && mi.mi_result == SP_OK) { - count_common_word(mi.mi_lp->lp_slang, ptr, + count_common_word(mi.mi_lp->lp_slang, (char *)ptr, (int)(mi.mi_end - ptr), 1); count_word = false; } @@ -911,12 +911,12 @@ static void find_word(matchinf_T *mip, int mode) bool match_checkcompoundpattern(char_u *ptr, int wlen, garray_T *gap) { for (int i = 0; i + 1 < gap->ga_len; i += 2) { - char_u *p = ((char_u **)gap->ga_data)[i + 1]; - if (STRNCMP(ptr + wlen, p, STRLEN(p)) == 0) { + char *p = ((char **)gap->ga_data)[i + 1]; + if (STRNCMP(ptr + wlen, p, strlen(p)) == 0) { // Second part matches at start of following compound word, now // check if first part matches at end of previous word. - p = ((char_u **)gap->ga_data)[i]; - int len = (int)STRLEN(p); + p = ((char **)gap->ga_data)[i]; + int len = (int)strlen(p); if (len <= wlen && STRNCMP(ptr + wlen - len, p, len) == 0) { return true; } @@ -1236,7 +1236,7 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att size_t len; int has_syntax = syntax_present(wp); colnr_T col; - char_u *buf = NULL; + char *buf = NULL; size_t buflen = 0; int skip = 0; colnr_T capcol = -1; @@ -1275,9 +1275,9 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att decor_spell_nav_start(wp); while (!got_int) { - char_u *line = (char_u *)ml_get_buf(wp->w_buffer, lnum, false); + char *line = ml_get_buf(wp->w_buffer, lnum, false); - len = STRLEN(line); + len = strlen(line); if (buflen < len + MAXWLEN + 2) { xfree(buf); buflen = len + MAXWLEN + 2; @@ -1292,17 +1292,17 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att // For checking first word with a capital skip white space. if (capcol == 0) { - capcol = (colnr_T)getwhitecols((char *)line); + capcol = (colnr_T)getwhitecols(line); } else if (curline && wp == curwin) { // For spellbadword(): check if first word needs a capital. - col = (colnr_T)getwhitecols((char *)line); + col = (colnr_T)getwhitecols(line); if (check_need_cap(lnum, col)) { capcol = col; } // Need to get the line again, may have looked at the previous // one. - line = (char_u *)ml_get_buf(wp->w_buffer, lnum, false); + line = ml_get_buf(wp->w_buffer, lnum, false); } // Copy the line into "buf" and append the start of the next line if @@ -1311,12 +1311,12 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att bool empty_line = *skipwhite((const char *)line) == NUL; STRCPY(buf, line); if (lnum < wp->w_buffer->b_ml.ml_line_count) { - spell_cat_line(buf + STRLEN(buf), + spell_cat_line((char_u *)buf + strlen(buf), (char_u *)ml_get_buf(wp->w_buffer, lnum + 1, false), MAXWLEN); } - char_u *p = buf + skip; - char_u *endp = buf + len; + char *p = buf + skip; + char *endp = buf + len; while (p < endp) { // When searching backward don't search after the cursor. Unless // we wrapped around the end of the buffer. @@ -1329,7 +1329,7 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att // start of word attr = HLF_COUNT; - len = spell_check(wp, p, &attr, &capcol, false); + len = spell_check(wp, (char_u *)p, &attr, &capcol, false); if (attr != HLF_COUNT) { // We found a bad word. Check the attribute. @@ -1565,7 +1565,7 @@ static void spell_load_lang(char_u *lang) // use "latin1" for "latin9". And limit to 60 characters (just in case). char_u *spell_enc(void) { - if (STRLEN(p_enc) < 60 && strcmp(p_enc, "iso-8859-15") != 0) { + if (strlen(p_enc) < 60 && strcmp(p_enc, "iso-8859-15") != 0) { return (char_u *)p_enc; } return (char_u *)"latin1"; @@ -1720,10 +1720,10 @@ static void spell_load_cb(char *fname, void *cookie) /// @param[in] word added to common words hashtable /// @param[in] len length of word or -1 for NUL terminated /// @param[in] count 1 to count once, 10 to init -void count_common_word(slang_T *lp, char_u *word, int len, uint8_t count) +void count_common_word(slang_T *lp, char *word, int len, uint8_t count) { - char_u buf[MAXWLEN]; - char_u *p; + char buf[MAXWLEN]; + char *p; if (len == -1) { p = word; @@ -1735,8 +1735,8 @@ void count_common_word(slang_T *lp, char_u *word, int len, uint8_t count) } wordcount_T *wc; - hash_T hash = hash_hash(p); - const size_t p_len = STRLEN(p); + hash_T hash = hash_hash((char_u *)p); + const size_t p_len = strlen(p); hashitem_T *hi = hash_lookup(&lp->sl_wordcount, (const char *)p, p_len, hash); if (HASHITEM_EMPTY(hi)) { wc = xmalloc(sizeof(wordcount_T) + p_len); @@ -1769,17 +1769,17 @@ bool byte_in_str(char_u *str, int n) int init_syl_tab(slang_T *slang) { ga_init(&slang->sl_syl_items, sizeof(syl_item_T), 4); - char_u *p = (char_u *)vim_strchr((char *)slang->sl_syllable, '/'); + char *p = vim_strchr((char *)slang->sl_syllable, '/'); while (p != NULL) { *p++ = NUL; if (*p == NUL) { // trailing slash break; } - char_u *s = p; - p = (char_u *)vim_strchr((char *)p, '/'); + char *s = p; + p = vim_strchr(p, '/'); int l; if (p == NULL) { - l = (int)STRLEN(s); + l = (int)strlen(s); } else { l = (int)(p - s); } @@ -2518,23 +2518,23 @@ bool check_need_cap(linenr_T lnum, colnr_T col) return false; } - char_u *line = (char_u *)get_cursor_line_ptr(); - char_u *line_copy = NULL; + char *line = get_cursor_line_ptr(); + char *line_copy = NULL; colnr_T endcol = 0; - if (getwhitecols((char *)line) >= (int)col) { + if (getwhitecols(line) >= (int)col) { // At start of line, check if previous line is empty or sentence // ends there. if (lnum == 1) { need_cap = true; } else { - line = (char_u *)ml_get(lnum - 1); - if (*skipwhite((char *)line) == NUL) { + line = ml_get(lnum - 1); + if (*skipwhite(line) == NUL) { need_cap = true; } else { // Append a space in place of the line break. - line_copy = (char_u *)concat_str((char *)line, " "); + line_copy = concat_str(line, " "); line = line_copy; - endcol = (colnr_T)STRLEN(line); + endcol = (colnr_T)strlen(line); } } } else { @@ -2547,14 +2547,14 @@ bool check_need_cap(linenr_T lnum, colnr_T col) .regprog = curwin->w_s->b_cap_prog, .rm_ic = false }; - char_u *p = line + endcol; + char *p = line + endcol; for (;;) { MB_PTR_BACK(line, p); - if (p == line || spell_iswordp_nmw(p, curwin)) { + if (p == line || spell_iswordp_nmw((char_u *)p, curwin)) { break; } - if (vim_regexec(®match, (char *)p, 0) - && (char_u *)regmatch.endp[0] == line + endcol) { + if (vim_regexec(®match, p, 0) + && regmatch.endp[0] == line + endcol) { need_cap = true; break; } @@ -2596,7 +2596,7 @@ void ex_spellrepall(exarg_T *eap) // Only replace when the right word isn't there yet. This happens // when changing "etc" to "etc.". - char_u *line = (char_u *)get_cursor_line_ptr(); + 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); diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 611c43e85e..d7a3efda83 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -1314,7 +1314,7 @@ static int read_words_section(FILE *fd, slang_T *lp, int len) } // Init the count to 10. - count_common_word(lp, word, -1, 10); + count_common_word(lp, (char *)word, -1, 10); done += i + 1; } return 0; diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index f2a0da188e..2ff41d5157 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -533,7 +533,7 @@ void spell_suggest(int count) } vim_snprintf((char *)IObuff, IOSIZE, "%2d", i + 1); if (cmdmsg_rl) { - rl_mirror((char_u *)IObuff); + rl_mirror(IObuff); } msg_puts((const char *)IObuff); @@ -559,7 +559,7 @@ void spell_suggest(int count) } if (cmdmsg_rl) { // Mirror the numbers, but keep the leading space. - rl_mirror((char_u *)IObuff + 1); + rl_mirror(IObuff + 1); } msg_advance(30); msg_puts((const char *)IObuff); diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 33c5c3a347..c4329fd84d 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -43,7 +43,7 @@ void win_redr_status(win_T *wp) { int row; int col; - char_u *p; + char *p; int len; int fillchar; int attr; @@ -77,8 +77,8 @@ void win_redr_status(win_T *wp) width = is_stl_global ? Columns : wp->w_width; get_trans_bufname(wp->w_buffer); - p = (char_u *)NameBuff; - len = (int)STRLEN(p); + p = NameBuff; + len = (int)strlen(p); if ((bt_help(wp->w_buffer) || wp->w_p_pvw @@ -88,19 +88,19 @@ void win_redr_status(win_T *wp) *(p + len++) = ' '; } if (bt_help(wp->w_buffer)) { - snprintf((char *)p + len, MAXPATHL - (size_t)len, "%s", _("[Help]")); - len += (int)STRLEN(p + len); + snprintf(p + len, MAXPATHL - (size_t)len, "%s", _("[Help]")); + len += (int)strlen(p + len); } if (wp->w_p_pvw) { - snprintf((char *)p + len, MAXPATHL - (size_t)len, "%s", _("[Preview]")); - len += (int)STRLEN(p + len); + snprintf(p + len, MAXPATHL - (size_t)len, "%s", _("[Preview]")); + len += (int)strlen(p + len); } if (bufIsChanged(wp->w_buffer)) { - snprintf((char *)p + len, MAXPATHL - (size_t)len, "%s", "[+]"); - len += (int)STRLEN(p + len); + snprintf(p + len, MAXPATHL - (size_t)len, "%s", "[+]"); + len += (int)strlen(p + len); } if (wp->w_buffer->b_p_ro) { - snprintf((char *)p + len, MAXPATHL - (size_t)len, "%s", _("[RO]")); + snprintf(p + len, MAXPATHL - (size_t)len, "%s", _("[RO]")); // len += (int)strlen(p + len); // dead assignment } @@ -109,19 +109,19 @@ void win_redr_status(win_T *wp) this_ru_col = (width + 1) / 2; } if (this_ru_col <= 1) { - p = (char_u *)"<"; // No room for file name! + p = "<"; // No room for file name! len = 1; } else { int clen = 0, i; // Count total number of display cells. - clen = (int)mb_string2cells((char *)p); + clen = (int)mb_string2cells(p); // Find first character that will fit. // Going from start to end is much faster for DBCS. for (i = 0; p[i] != NUL && clen >= this_ru_col - 1; - i += utfc_ptr2len((char *)p + i)) { - clen -= utf_ptr2cells((char *)p + i); + i += utfc_ptr2len(p + i)) { + clen -= utf_ptr2cells(p + i); } len = clen; if (i > 0) { @@ -133,7 +133,7 @@ void win_redr_status(win_T *wp) row = is_stl_global ? (Rows - (int)p_ch - 1) : W_ENDROW(wp); col = is_stl_global ? 0 : wp->w_wincol; - grid_puts(&default_grid, (char *)p, row, col, attr); + grid_puts(&default_grid, p, row, col, attr); grid_fill(&default_grid, row, row + 1, len + col, this_ru_col + col, fillchar, fillchar, attr); diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index ea78397d8c..527cca05f5 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -504,7 +504,7 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid) bool had_sync_point; stateitem_T *cur_si; synpat_T *spp; - char_u *line; + char *line; int found_flags = 0; int found_match_idx = 0; linenr_T found_current_lnum = 0; @@ -554,8 +554,8 @@ static void syn_sync(win_T *wp, linenr_T start_lnum, synstate_T *last_valid) // Skip lines that end in a backslash. for (; start_lnum > 1; start_lnum--) { - line = (char_u *)ml_get(start_lnum - 1); - if (*line == NUL || *(line + STRLEN(line) - 1) != '\\') { + line = ml_get(start_lnum - 1); + if (*line == NUL || *(line + strlen(line) - 1) != '\\') { break; } } @@ -2366,7 +2366,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_ regmmatch_T regmatch; regmmatch_T best_regmatch; // startpos/endpos of best match lpos_T pos; - char_u *line; + char *line; bool had_match = false; char_u buf_chartab[32]; // chartab array for syn option iskeyword @@ -2471,8 +2471,8 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_ break; } - line = (char_u *)ml_get_buf(syn_buf, startpos->lnum, false); - int line_len = (int)STRLEN(line); + line = ml_get_buf(syn_buf, startpos->lnum, false); + int line_len = (int)strlen(line); // take care of an empty match or negative offset if (pos.col <= matchcol) { diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 2ac3fed8b7..7c465ac909 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -58,7 +58,7 @@ typedef struct tag_pointers { char_u *command; // first char of command // filled in by parse_match(): char_u *command_end; // first char after command - char_u *tag_fname; // file name of the tags file. This is used + char *tag_fname; // file name of the tags file. This is used // when 'tr' is set. char_u *tagkind; // "kind:" value char_u *tagkind_end; // end of tagkind @@ -1212,30 +1212,30 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl char *const mfp = name_only ? xstrdup(res_name) : xmalloc(len + 2); if (!name_only) { - char_u *p = (char_u *)mfp; + char *p = mfp; *p++ = MT_GL_OTH + 1; // mtt *p++ = TAG_SEP; // no tag file name STRCPY(p, res_name); - p += STRLEN(p); + p += strlen(p); *p++ = TAB; STRCPY(p, res_fname); - p += STRLEN(p); + p += strlen(p); *p++ = TAB; STRCPY(p, res_cmd); - p += STRLEN(p); + p += strlen(p); if (has_extra) { STRCPY(p, ";\""); - p += STRLEN(p); + p += strlen(p); if (res_kind) { *p++ = TAB; STRCPY(p, res_kind); - p += STRLEN(p); + p += strlen(p); } TV_DICT_ITER(TV_LIST_ITEM_TV(li)->vval.v_dict, di, { @@ -1260,11 +1260,11 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl *p++ = TAB; STRCPY(p, dict_key); - p += STRLEN(p); + p += strlen(p); STRCPY(p, ":"); - p += STRLEN(p); + p += strlen(p); STRCPY(p, tv->vval.v_string); - p += STRLEN(p); + p += strlen(p); }); } } @@ -1316,9 +1316,9 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc char *buf_ffname) { FILE *fp; - char_u *lbuf; // line buffer + char *lbuf; // line buffer int lbuf_size = LSIZE; // length of lbuf - char_u *tag_fname; // name of tag file + char *tag_fname; // name of tag file tagname_T tn; // info for get_tagfname() int first_file; // trying first tag file tagptrs_T tagp; @@ -1328,7 +1328,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc int is_static; // current tag line is static int is_current; // file name matches bool eof = false; // found end-of-file - char_u *p; + char *p; char_u *s; int i; int tag_file_sorted = NUL; // !_TAG_FILE_SORTED value @@ -1617,7 +1617,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc // Adjust the search file offset to the correct position search_info.curr_offset_used = search_info.curr_offset; vim_fseek(fp, search_info.curr_offset, SEEK_SET); - eof = vim_fgets(lbuf, lbuf_size, fp); + eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); if (!eof && search_info.curr_offset != 0) { // The explicit cast is to work around a bug in gcc 3.4.2 // (repeated below). @@ -1627,12 +1627,12 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc vim_fseek(fp, search_info.low_offset, SEEK_SET); search_info.curr_offset = search_info.low_offset; } - eof = vim_fgets(lbuf, lbuf_size, fp); + eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); } // skip empty and blank lines - while (!eof && vim_isblankline((char *)lbuf)) { + while (!eof && vim_isblankline(lbuf)) { search_info.curr_offset = vim_ftell(fp); - eof = vim_fgets(lbuf, lbuf_size, fp); + eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); } if (eof) { // Hit end of file. Skip backwards. @@ -1646,7 +1646,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc // skip empty and blank lines do { - eof = vim_fgets(lbuf, lbuf_size, fp); + eof = vim_fgets((char_u *)lbuf, lbuf_size, fp); } while (!eof && vim_isblankline((char *)lbuf)); if (eof) { @@ -1656,16 +1656,16 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc line_read_in: if (vimconv.vc_type != CONV_NONE) { - char_u *conv_line; + char *conv_line; int len; // Convert every line. Converting the pattern from 'enc' to // the tags file encoding doesn't work, because characters are // not recognized. - conv_line = (char_u *)string_convert(&vimconv, (char *)lbuf, NULL); + conv_line = string_convert(&vimconv, lbuf, NULL); if (conv_line != NULL) { // Copy or swap lbuf and conv_line. - len = (int)STRLEN(conv_line) + 1; + len = (int)strlen(conv_line) + 1; if (len > lbuf_size) { xfree(lbuf); lbuf = conv_line; @@ -1691,14 +1691,14 @@ line_read_in: // Read header line. if (STRNCMP(lbuf, "!_TAG_FILE_SORTED\t", 18) == 0) { - tag_file_sorted = lbuf[18]; + tag_file_sorted = (uint8_t)lbuf[18]; } if (STRNCMP(lbuf, "!_TAG_FILE_ENCODING\t", 20) == 0) { // Prepare to convert every line from the specified // encoding to 'encoding'. for (p = lbuf + 20; *p > ' ' && *p < 127; p++) {} *p = NUL; - convert_setup(&vimconv, (char *)lbuf + 20, p_enc); + convert_setup(&vimconv, lbuf + 20, p_enc); } // Read the next line. Unrecognized flags are ignored. @@ -1779,8 +1779,8 @@ parse_line: // This speeds up tag searching a lot! if (orgpat.headlen) { CLEAR_FIELD(tagp); - tagp.tagname = (char *)lbuf; - tagp.tagname_end = (char_u *)vim_strchr((char *)lbuf, TAB); + tagp.tagname = lbuf; + tagp.tagname_end = (char_u *)vim_strchr(lbuf, TAB); if (tagp.tagname_end == NULL) { // Corrupted tag line. line_error = true; @@ -1898,8 +1898,7 @@ parse_line: i = OK; } } else { - i = parse_tag_line(lbuf, - &tagp); + i = parse_tag_line((char_u *)lbuf, &tagp); } if (i == FAIL) { line_error = true; @@ -1992,11 +1991,11 @@ parse_line: len = (size_t)(tagp.tagname_end - (char_u *)tagp.tagname); mfp = xmalloc(sizeof(char) + len + 10 + ML_EXTRA + 1); - p = (char_u *)mfp; + p = mfp; STRCPY(p, tagp.tagname); p[len] = '@'; STRCPY(p + len + 1, help_lang); - snprintf((char *)p + len + 1 + ML_EXTRA, STRLEN(p) + len + 1 + ML_EXTRA, "%06d", + snprintf(p + len + 1 + ML_EXTRA, strlen(p) + len + 1 + ML_EXTRA, "%06d", help_heuristic(tagp.tagname, match_re ? matchoff : 0, !match_no_ic) + help_pri); @@ -2033,7 +2032,7 @@ parse_line: } } } else { - size_t tag_fname_len = STRLEN(tag_fname); + size_t tag_fname_len = strlen(tag_fname); // Save the tag in a buffer. // Use 0x02 to separate fields (Can't use NUL, because the // hash key is terminated by NUL). @@ -2041,10 +2040,10 @@ parse_line: // other tag: <mtt><tag_fname><0x02><0x02><lbuf><NUL> // without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL> // Here <mtt> is the "mtt" value plus 1 to avoid NUL. - len = tag_fname_len + STRLEN(lbuf) + 3; + len = tag_fname_len + strlen(lbuf) + 3; mfp = xmalloc(sizeof(char) + len + 1); - p = (char_u *)mfp; - p[0] = (char_u)(mtt + 1); + p = mfp; + p[0] = (char)(mtt + 1); STRCPY(p + 1, tag_fname); #ifdef BACKSLASH_IN_FILENAME // Ignore differences in slashes, avoid adding @@ -2052,7 +2051,7 @@ parse_line: slash_adjust(p + 1); #endif p[tag_fname_len + 1] = TAG_SEP; - s = p + 1 + tag_fname_len + 1; + s = (char_u *)p + 1 + tag_fname_len + 1; STRCPY(s, lbuf); } @@ -2154,7 +2153,7 @@ findtag_end: *mfp = (char)(*mfp - 1); // change the TAG_SEP back to NUL - for (p = (char_u *)mfp + 1; *p != NUL; p++) { + for (p = mfp + 1; *p != NUL; p++) { if (*p == TAG_SEP) { *p = NUL; } @@ -2395,14 +2394,14 @@ static bool test_for_static(tagptrs_T *tagp) return false; } -// Returns the length of a matching tag line. -static size_t matching_line_len(const char_u *const lbuf) +/// @return the length of a matching tag line. +static size_t matching_line_len(const char *const lbuf) { - const char_u *p = lbuf + 1; + const char *p = lbuf + 1; // does the same thing as parse_match() - p += STRLEN(p) + 1; - return (size_t)(p - lbuf) + STRLEN(p); + p += strlen(p) + 1; + return (size_t)(p - lbuf) + strlen(p); } /// Parse a line from a matching tag. Does not change the line itself. @@ -2422,8 +2421,8 @@ static int parse_match(char *lbuf, tagptrs_T *tagp) char *p; char *pc, *pt; - tagp->tag_fname = (char_u *)lbuf + 1; - lbuf += STRLEN(tagp->tag_fname) + 2; + tagp->tag_fname = lbuf + 1; + lbuf += strlen(tagp->tag_fname) + 2; // Find search pattern and the file name for non-etags. retval = parse_tag_line((char_u *)lbuf, tagp); @@ -2494,7 +2493,7 @@ static char_u *tag_full_fname(tagptrs_T *tagp) int c = *tagp->fname_end; *tagp->fname_end = NUL; char_u *fullname = - (char_u *)expand_tag_fname((char *)tagp->fname, (char *)tagp->tag_fname, false); + (char_u *)expand_tag_fname((char *)tagp->fname, tagp->tag_fname, false); *tagp->fname_end = (char_u)c; return fullname; @@ -2526,7 +2525,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) char_u *full_fname = NULL; const bool old_KeyTyped = KeyTyped; // getting the file may reset it const int l_g_do_tagpreview = g_do_tagpreview; - const size_t len = matching_line_len(lbuf_arg) + 1; + const size_t len = matching_line_len((char *)lbuf_arg) + 1; char_u *lbuf = xmalloc(len); memmove(lbuf, lbuf_arg, len); @@ -2563,7 +2562,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) // Expand file name, when needed (for environment variables). // If 'tagrelative' option set, may change file name. - fname = expand_tag_fname(fname, (char *)tagp.tag_fname, true); + fname = expand_tag_fname(fname, tagp.tag_fname, true); tofree_fname = (char_u *)fname; // free() it later // Check if the file with the tag exists before abandoning the current diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index 25728ef0f1..61949fec6a 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -493,14 +493,14 @@ static int fmt_check_par(linenr_T lnum, int *leader_len, char_u **leader_flags, /// @return true if line "lnum" ends in a white character. static bool ends_in_white(linenr_T lnum) { - char_u *s = (char_u *)ml_get(lnum); + char *s = ml_get(lnum); size_t l; if (*s == NUL) { return false; } - l = STRLEN(s) - 1; - return ascii_iswhite(s[l]); + l = strlen(s) - 1; + return ascii_iswhite((uint8_t)s[l]); } /// @return true if the two comment leaders given are the same. diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index e6b330cbf1..dbe7110d60 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -213,13 +213,13 @@ bool findpar(bool *pincl, int dir, long count, int what, bool both) } curwin->w_cursor.lnum = curr; if (curr == curbuf->b_ml.ml_line_count && what != '}') { - char_u *line = (char_u *)ml_get(curr); + char *line = ml_get(curr); // Put the cursor on the last character in the last line and make the // motion inclusive. - if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0) { + if ((curwin->w_cursor.col = (colnr_T)strlen(line)) != 0) { curwin->w_cursor.col--; - curwin->w_cursor.col -= utf_head_off((char *)line, (char *)line + curwin->w_cursor.col); + curwin->w_cursor.col -= utf_head_off(line, line + curwin->w_cursor.col); *pincl = true; } } else { diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 1a9066d7f1..ef8dc0775b 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -621,8 +621,8 @@ void u_compute_hash(buf_T *buf, char_u *hash) context_sha256_T ctx; sha256_start(&ctx); for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { - char_u *p = (char_u *)ml_get_buf(buf, lnum, false); - sha256_update(&ctx, p, (uint32_t)(STRLEN(p) + 1)); + char *p = ml_get_buf(buf, lnum, false); + sha256_update(&ctx, (char_u *)p, (uint32_t)(strlen(p) + 1)); } sha256_finish(&ctx, hash); } @@ -2636,7 +2636,7 @@ void ex_undolist(exarg_T *eap) if (uhp->uh_prev.ptr == NULL && uhp->uh_walk != nomark && uhp->uh_walk != mark) { vim_snprintf((char *)IObuff, IOSIZE, "%6ld %7d ", uhp->uh_seq, changes); - undo_fmt_time((char_u *)IObuff + STRLEN(IObuff), IOSIZE - STRLEN(IObuff), uhp->uh_time); + undo_fmt_time((char_u *)IObuff + strlen(IObuff), IOSIZE - strlen(IObuff), uhp->uh_time); if (uhp->uh_save_nr > 0) { while (strlen(IObuff) < 33) { STRCAT(IObuff, " "); @@ -2991,13 +2991,13 @@ void u_undoline(void) return; } - char_u *oldp = u_save_line(curbuf->b_u_line_lnum); + char *oldp = (char *)u_save_line(curbuf->b_u_line_lnum); ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true); changed_bytes(curbuf->b_u_line_lnum, 0); 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 = (char *)oldp; + curbuf->b_u_line_ptr = oldp; colnr_T t = curbuf->b_u_line_colnr; if (curwin->w_cursor.lnum == curbuf->b_u_line_lnum) { |