diff options
author | Dundar Göc <gocdundar@gmail.com> | 2022-08-26 23:11:25 +0200 |
---|---|---|
committer | dundargoc <gocdundar@gmail.com> | 2022-11-19 16:27:10 +0100 |
commit | 40f3f75867bf03abfd90e0389a38197a00d37af1 (patch) | |
tree | d14642161d70ef658f5b23fea1693e0be9a84804 | |
parent | 6e8ed5abaa9c33d1d78ab7ff5b07dd5bac623a1d (diff) | |
download | rneovim-40f3f75867bf03abfd90e0389a38197a00d37af1.tar.gz rneovim-40f3f75867bf03abfd90e0389a38197a00d37af1.tar.bz2 rneovim-40f3f75867bf03abfd90e0389a38197a00d37af1.zip |
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
33 files changed, 513 insertions, 512 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index b7cd0c82fb..ca8ad16cbf 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -505,7 +505,7 @@ String buf_get_text(buf_T *buf, int64_t lnum, int64_t start_col, int64_t end_col return rv; } - return cstrn_as_string((char *)&bufstr[start_col], (size_t)(end_col - start_col)); + return cstrn_as_string(&bufstr[start_col], (size_t)(end_col - start_col)); } void api_free_string(String value) diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 82a4698058..1f9b8f9a65 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -274,7 +274,7 @@ int buf_init_chartab(buf_T *buf, int global) /// @param bufsize void trans_characters(char *buf, int bufsize) { - char_u *trs; // translated character + char *trs; // translated character int len = (int)strlen(buf); // length of string needing translation int room = bufsize - len; // room in buffer after string @@ -284,8 +284,8 @@ void trans_characters(char *buf, int bufsize) if ((trs_len = utfc_ptr2len(buf)) > 1) { len -= trs_len; } else { - trs = transchar_byte((uint8_t)(*buf)); - trs_len = (int)STRLEN(trs); + trs = (char *)transchar_byte((uint8_t)(*buf)); + trs_len = (int)strlen(trs); if (trs_len > 1) { room -= trs_len - 1; diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 39865d7508..79ffd7552d 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -180,7 +180,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape) CmdlineInfo *const ccline = get_cmdline_info(); int i, j; char_u *p1; - char_u *p2; + char *p2; int difflen; if (xp->xp_numfiles == -1) { @@ -210,7 +210,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape) if (type == WILD_NEXT || type == WILD_PREV || type == WILD_PUM_WANT) { // Get next/previous match for a previous expanded pattern. - p2 = (char_u *)ExpandOne(xp, NULL, NULL, 0, type); + p2 = ExpandOne(xp, NULL, NULL, 0, type); } else { // Translate string into pattern and expand it. p1 = (char_u *)addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context); @@ -220,8 +220,8 @@ int nextwild(expand_T *xp, int type, int options, bool escape) | WILD_SILENT | (escape ? WILD_ESCAPE : 0) | (p_wic ? WILD_ICASE : 0)); - p2 = (char_u *)ExpandOne(xp, (char *)p1, xstrnsave(&ccline->cmdbuff[i], xp->xp_pattern_len), - use_options, type); + p2 = ExpandOne(xp, (char *)p1, xstrnsave(&ccline->cmdbuff[i], xp->xp_pattern_len), + use_options, type); xfree(p1); // xp->xp_pattern might have been modified by ExpandOne (for example, @@ -237,14 +237,14 @@ int nextwild(expand_T *xp, int type, int options, bool escape) break; } } - if ((int)STRLEN(p2) < j) { + if ((int)strlen(p2) < j) { XFREE_CLEAR(p2); } } } if (p2 != NULL && !got_int) { - difflen = (int)STRLEN(p2) - (int)(xp->xp_pattern_len); + difflen = (int)strlen(p2) - (int)(xp->xp_pattern_len); if (ccline->cmdlen + difflen + 4 > ccline->cmdbufflen) { realloc_cmdbuff(ccline->cmdlen + difflen + 4); xp->xp_pattern = ccline->cmdbuff + i; @@ -253,7 +253,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape) memmove(&ccline->cmdbuff[ccline->cmdpos + difflen], &ccline->cmdbuff[ccline->cmdpos], (size_t)ccline->cmdlen - (size_t)ccline->cmdpos + 1); - memmove(&ccline->cmdbuff[i], p2, STRLEN(p2)); + memmove(&ccline->cmdbuff[i], p2, strlen(p2)); ccline->cmdlen += difflen; ccline->cmdpos += difflen; } @@ -588,7 +588,7 @@ static char *ExpandOne_start(int mode, expand_T *xp, char *str, int options) char *ss = NULL; // Do the expansion. - if (ExpandFromContext(xp, (char_u *)str, &xp->xp_numfiles, &xp->xp_files, options) == FAIL) { + if (ExpandFromContext(xp, str, &xp->xp_numfiles, &xp->xp_files, options) == FAIL) { #ifdef FNAME_ILLEGAL // Illegal file name has been silently skipped. But when there // are wildcards, the real problem is that there was no match, @@ -1600,13 +1600,13 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons case CMD_doautoall: return (const char *)set_context_in_autocmd(xp, (char *)arg, true); case CMD_set: - set_context_in_set_cmd(xp, (char_u *)arg, 0); + set_context_in_set_cmd(xp, (char *)arg, 0); break; case CMD_setglobal: - set_context_in_set_cmd(xp, (char_u *)arg, OPT_GLOBAL); + set_context_in_set_cmd(xp, (char *)arg, OPT_GLOBAL); break; case CMD_setlocal: - set_context_in_set_cmd(xp, (char_u *)arg, OPT_LOCAL); + set_context_in_set_cmd(xp, (char *)arg, OPT_LOCAL); break; case CMD_tag: case CMD_stag: @@ -2163,7 +2163,7 @@ int expand_cmdline(expand_T *xp, const char_u *str, int col, int *matchcount, ch } // find all files that match the description - if (ExpandFromContext(xp, file_str, matchcount, matches, options) == FAIL) { + if (ExpandFromContext(xp, (char *)file_str, matchcount, matches, options) == FAIL) { *matchcount = 0; *matches = NULL; } @@ -2352,7 +2352,7 @@ static int ExpandOther(expand_T *xp, regmatch_T *rmp, int *num_file, char ***fil /// Do the expansion based on xp->xp_context and "pat". /// /// @param options WILD_ flags -static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***file, int options) +static int ExpandFromContext(expand_T *xp, char *pat, int *num_file, char ***file, int options) { regmatch_T regmatch; int ret; @@ -2381,7 +2381,7 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***f if (xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_DIRECTORIES || xp->xp_context == EXPAND_FILES_IN_PATH) { - return expand_files_and_dirs(xp, (char *)pat, file, num_file, flags, options); + return expand_files_and_dirs(xp, pat, file, num_file, flags, options); } *file = NULL; @@ -2389,7 +2389,7 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***f if (xp->xp_context == EXPAND_HELP) { // With an empty argument we would get all the help tags, which is // very slow. Get matches for "help" instead. - if (find_help_tags(*pat == NUL ? "help" : (char *)pat, + if (find_help_tags(*pat == NUL ? "help" : pat, num_file, file, false) == OK) { cleanup_help_tags(*num_file, *file); return OK; @@ -2399,7 +2399,7 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***f if (xp->xp_context == EXPAND_SHELLCMD) { *file = NULL; - expand_shellcmd((char *)pat, num_file, file, flags); + expand_shellcmd(pat, num_file, file, flags); return OK; } if (xp->xp_context == EXPAND_OLD_SETTING) { @@ -2407,30 +2407,30 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***f return OK; } if (xp->xp_context == EXPAND_BUFFERS) { - return ExpandBufnames((char *)pat, num_file, file, options); + return ExpandBufnames(pat, num_file, file, options); } if (xp->xp_context == EXPAND_DIFF_BUFFERS) { - return ExpandBufnames((char *)pat, num_file, file, options | BUF_DIFF_FILTER); + return ExpandBufnames(pat, num_file, file, options | BUF_DIFF_FILTER); } if (xp->xp_context == EXPAND_TAGS || xp->xp_context == EXPAND_TAGS_LISTFILES) { - return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file); + return expand_tags(xp->xp_context == EXPAND_TAGS, (char_u *)pat, num_file, file); } if (xp->xp_context == EXPAND_COLORS) { char *directories[] = { "colors", NULL }; - return ExpandRTDir((char *)pat, DIP_START + DIP_OPT + DIP_LUA, num_file, file, directories); + return ExpandRTDir(pat, DIP_START + DIP_OPT + DIP_LUA, num_file, file, directories); } if (xp->xp_context == EXPAND_COMPILER) { char *directories[] = { "compiler", NULL }; - return ExpandRTDir((char *)pat, DIP_LUA, num_file, file, directories); + return ExpandRTDir(pat, DIP_LUA, num_file, file, directories); } if (xp->xp_context == EXPAND_OWNSYNTAX) { char *directories[] = { "syntax", NULL }; - return ExpandRTDir((char *)pat, 0, num_file, file, directories); + return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_FILETYPE) { char *directories[] = { "syntax", "indent", "ftplugin", NULL }; - return ExpandRTDir((char *)pat, DIP_LUA, num_file, file, directories); + return ExpandRTDir(pat, DIP_LUA, num_file, file, directories); } if (xp->xp_context == EXPAND_USER_LIST) { return ExpandUserList(xp, num_file, file); @@ -2439,32 +2439,32 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***f return ExpandUserLua(xp, num_file, file); } if (xp->xp_context == EXPAND_PACKADD) { - return ExpandPackAddDir((char *)pat, num_file, file); + return ExpandPackAddDir(pat, num_file, file); } // When expanding a function name starting with s:, match the <SNR>nr_ // prefix. char *tofree = NULL; if (xp->xp_context == EXPAND_USER_FUNC && STRNCMP(pat, "^s:", 3) == 0) { - const size_t len = STRLEN(pat) + 20; + const size_t len = strlen(pat) + 20; tofree = xmalloc(len); snprintf(tofree, len, "^<SNR>\\d\\+_%s", pat + 3); - pat = (char_u *)tofree; + pat = tofree; } if (xp->xp_context == EXPAND_LUA) { ILOG("PAT %s", pat); - return nlua_expand_pat(xp, (char *)pat, num_file, file); + return nlua_expand_pat(xp, pat, num_file, file); } - regmatch.regprog = vim_regcomp((char *)pat, p_magic ? RE_MAGIC : 0); + regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); if (regmatch.regprog == NULL) { return FAIL; } // set ignore-case according to p_ic, p_scs and pat - regmatch.rm_ic = ignorecase(pat); + regmatch.rm_ic = ignorecase((char_u *)pat); if (xp->xp_context == EXPAND_SETTINGS || xp->xp_context == EXPAND_BOOL_SETTINGS) { @@ -2651,19 +2651,19 @@ static void expand_shellcmd(char *filepat, int *num_file, char ***file, int flag ga_grow(&ga, *num_file); { for (i = 0; i < *num_file; i++) { - char_u *name = (char_u *)(*file)[i]; + char *name = (*file)[i]; - if (STRLEN(name) > l) { + if (strlen(name) > l) { // Check if this name was already found. - hash_T hash = hash_hash(name + l); + hash_T hash = hash_hash((char_u *)name + l); hashitem_T *hi = hash_lookup(&found_ht, (const char *)(name + l), - STRLEN(name + l), hash); + strlen(name + l), hash); if (HASHITEM_EMPTY(hi)) { // Remove the path that was prepended. STRMOVE(name, name + l); - ((char_u **)ga.ga_data)[ga.ga_len++] = name; - hash_add_item(&found_ht, hi, name, hash); + ((char **)ga.ga_data)[ga.ga_len++] = name; + hash_add_item(&found_ht, hi, (char_u *)name, hash); name = NULL; } } @@ -2834,14 +2834,14 @@ void globpath(char *path, char *file, garray_T *ga, int expand_options) ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; - char_u *buf = xmalloc(MAXPATHL); + char *buf = xmalloc(MAXPATHL); // Loop over all entries in {path}. while (*path != NUL) { // Copy one item of the path to buf[] and concatenate the file name. - copy_option_part(&path, (char *)buf, MAXPATHL, ","); - if (STRLEN(buf) + strlen(file) + 2 < MAXPATHL) { - add_pathsep((char *)buf); + copy_option_part(&path, buf, MAXPATHL, ","); + if (strlen(buf) + strlen(file) + 2 < MAXPATHL) { + add_pathsep(buf); STRCAT(buf, file); // NOLINT char **p; @@ -2849,7 +2849,7 @@ void globpath(char *path, char *file, garray_T *ga, int expand_options) (void)ExpandFromContext(&xpc, buf, &num_p, &p, WILD_SILENT | expand_options); if (num_p > 0) { - ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT | expand_options); + ExpandEscape(&xpc, (char_u *)buf, num_p, p, WILD_SILENT | expand_options); // Concatenate new results to previous ones. ga_grow(ga, num_p); diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index 811f397cb8..84a2cf83ac 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -108,14 +108,14 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a || (VIsual_active && *p_sel != 'o') || ((get_ve_flags() & VE_ONEMORE) && wcol < MAXCOL); - char_u *line = (char_u *)ml_get_buf(curbuf, pos->lnum, false); + char *line = ml_get_buf(curbuf, pos->lnum, false); if (wcol >= MAXCOL) { - idx = (int)STRLEN(line) - 1 + one_more; + idx = (int)strlen(line) - 1 + one_more; col = wcol; if ((addspaces || finetune) && !VIsual_active) { - curwin->w_curswant = linetabsize(line) + one_more; + curwin->w_curswant = linetabsize((char_u *)line) + one_more; if (curwin->w_curswant > 0) { curwin->w_curswant--; } @@ -129,7 +129,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a && curwin->w_width_inner != 0 && wcol >= (colnr_T)width && width > 0) { - csize = linetabsize(line); + csize = linetabsize((char_u *)line); if (csize > 0) { csize--; } @@ -145,7 +145,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a } chartabsize_T cts; - init_chartabsize_arg(&cts, curwin, pos->lnum, 0, (char *)line, (char *)line); + init_chartabsize_arg(&cts, curwin, pos->lnum, 0, line, line); while (cts.cts_vcol <= wcol && *cts.cts_ptr != NUL) { // Count a tab for what it's worth (if list mode not on) csize = win_lbr_chartabsize(&cts, &head); @@ -153,7 +153,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a cts.cts_vcol += csize; } col = cts.cts_vcol; - idx = (int)(cts.cts_ptr - (char *)line); + idx = (int)(cts.cts_ptr - line); clear_chartabsize_arg(&cts); // Handle all the special cases. The virtual_active() check @@ -188,7 +188,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a col = wcol; } else { // Break a tab - int linelen = (int)STRLEN(line); + int linelen = (int)strlen(line); int correct = wcol - col - csize + 1; // negative!! char_u *newline; @@ -315,8 +315,8 @@ void check_pos(buf_T *buf, pos_T *pos) } if (pos->col > 0) { - char_u *line = (char_u *)ml_get_buf(buf, pos->lnum, false); - colnr_T len = (colnr_T)STRLEN(line); + char *line = ml_get_buf(buf, pos->lnum, false); + colnr_T len = (colnr_T)strlen(line); if (pos->col > len) { pos->col = len; } diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 4b71142c11..121b98d047 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1043,7 +1043,7 @@ static int check_external_diff(diffio_T *diffio) for (;;) { // For normal diff there must be a line that contains // "1c1". For unified diff "@@ -1 +1 @@". - if (vim_fgets((char_u *)linebuf, LBUFLEN, fd)) { + if (vim_fgets(linebuf, LBUFLEN, fd)) { break; } @@ -1218,9 +1218,9 @@ void ex_diffpatch(exarg_T *eap) esc_name = (char *)vim_strsave_shellescape((char_u *)(fullname != NULL ? fullname : eap->arg), true, true); #else - esc_name = vim_strsave_shellescape(eap->arg, true, true); + esc_name = (char *)vim_strsave_shellescape(eap->arg, true, true); #endif - size_t buflen = STRLEN(tmp_orig) + STRLEN(esc_name) + STRLEN(tmp_new) + 16; + size_t buflen = strlen(tmp_orig) + strlen(esc_name) + strlen(tmp_new) + 16; buf = xmalloc(buflen); #ifdef UNIX @@ -1557,7 +1557,7 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle) { for (;;) { char line[LBUFLEN]; // only need to hold the diff line - if (vim_fgets((char_u *)line, LBUFLEN, fd)) { + if (vim_fgets(line, LBUFLEN, fd)) { return true; // end of file } @@ -1577,9 +1577,9 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle) } else if ((STRNCMP(line, "@@ ", 3) == 0)) { *diffstyle = DIFF_UNIFIED; } else if ((STRNCMP(line, "--- ", 4) == 0) // -V501 - && (vim_fgets((char_u *)line, LBUFLEN, fd) == 0) // -V501 + && (vim_fgets(line, LBUFLEN, fd) == 0) // -V501 && (STRNCMP(line, "+++ ", 4) == 0) - && (vim_fgets((char_u *)line, LBUFLEN, fd) == 0) // -V501 + && (vim_fgets(line, LBUFLEN, fd) == 0) // -V501 && (STRNCMP(line, "@@ ", 3) == 0)) { *diffstyle = DIFF_UNIFIED; } else { diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 12568ec965..e49b0fd14c 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2343,13 +2343,13 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST) { xfree(fresult); } - fresult = find_file_in_path_option(first ? (char_u *)fname : NULL, - first ? strlen(fname) : 0, - 0, first, path, - find_what, (char_u *)curbuf->b_ffname, - (find_what == FINDFILE_DIR - ? (char_u *)"" - : (char_u *)curbuf->b_p_sua)); + fresult = (char_u *)find_file_in_path_option(first ? (char *)fname : NULL, + first ? strlen(fname) : 0, + 0, first, (char *)path, + find_what, curbuf->b_ffname, + (find_what == FINDFILE_DIR + ? "" + : curbuf->b_p_sua)); first = false; if (fresult != NULL && rettv->v_type == VAR_LIST) { diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 0733bcf683..a2bd6fb43f 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3378,7 +3378,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int } searchcmdlen = 0; flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG; - if (!do_search(NULL, c, c, (char_u *)cmd, 1L, flags, NULL)) { + if (!do_search(NULL, c, c, cmd, 1L, flags, NULL)) { curwin->w_cursor = pos; cmd = NULL; goto error; @@ -3831,7 +3831,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp) // if there are still wildcards present. if (vim_strchr(eap->arg, '$') != NULL || vim_strchr(eap->arg, '~') != NULL) { - expand_env_esc((char_u *)eap->arg, (char_u *)NameBuff, MAXPATHL, true, true, NULL); + expand_env_esc(eap->arg, NameBuff, MAXPATHL, true, true, NULL); has_wildcards = path_has_wildcard(NameBuff); p = (char *)NameBuff; } else { @@ -5541,7 +5541,7 @@ bool changedir_func(char *new_dir, CdScope scope) bool dir_differs = pdir == NULL || pathcmp(pdir, new_dir, -1) != 0; if (dir_differs) { do_autocmd_dirchanged(new_dir, scope, kCdCauseManual, true); - if (vim_chdir((char_u *)new_dir) != 0) { + if (vim_chdir(new_dir) != 0) { emsg(_(e_failed)); xfree(pdir); return false; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 89d295e1a8..fc9559172f 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -439,7 +439,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat .sa_tm = &tm, }; found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim, - (char_u *)ccline.cmdbuff + skiplen, count, + ccline.cmdbuff + skiplen, count, search_flags, &sia); ccline.cmdbuff[skiplen + patlen] = next_char; emsg_off--; diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 1d891799a5..36d58923b0 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -82,8 +82,8 @@ typedef struct ff_stack { // the fix part (no wildcards) and the part containing the wildcards // of the search path - char_u *ffs_fix_path; - char_u *ffs_wc_path; + char *ffs_fix_path; + char *ffs_wc_path; // files/dirs found in the above directory, matched by the first wildcard // of wc_part @@ -511,7 +511,7 @@ char_u *vim_findfile_stopdir(char_u *buf) while (*r_ptr != NUL && *r_ptr != ';') { if (r_ptr[0] == '\\' && r_ptr[1] == ';') { // Overwrite the escape char, - // use STRLEN(r_ptr) to move the trailing '\0'. + // use strlen(r_ptr) to move the trailing '\0'. STRMOVE(r_ptr, r_ptr + 1); r_ptr++; } @@ -553,12 +553,12 @@ void vim_findfile_cleanup(void *ctx) /// NULL if nothing found. char_u *vim_findfile(void *search_ctx_arg) { - char_u *file_path; - char_u *rest_of_wildcards; + char *file_path; + char *rest_of_wildcards; char_u *path_end = NULL; ff_stack_T *stackp = NULL; size_t len; - char_u *p; + char *p; char *suf; ff_search_ctx_T *search_ctx; @@ -612,7 +612,7 @@ char_u *vim_findfile(void *search_ctx_arg) // first time (hence stackp->ff_filearray == NULL) if (stackp->ffs_filearray == NULL && ff_check_visited(&search_ctx->ffsc_dir_visited_list->ffvl_visited_list, - (char *)stackp->ffs_fix_path, (char *)stackp->ffs_wc_path) == FAIL) { + stackp->ffs_fix_path, stackp->ffs_wc_path) == FAIL) { #ifdef FF_VERBOSE if (p_verbose >= 5) { verbose_enter_scroll(); @@ -650,37 +650,37 @@ char_u *vim_findfile(void *search_ctx_arg) char *dirptrs[2]; // we use filepath to build the path expand_wildcards() should expand. - dirptrs[0] = (char *)file_path; + dirptrs[0] = file_path; dirptrs[1] = NULL; // if we have a start dir copy it in - if (!vim_isAbsName(stackp->ffs_fix_path) + if (!vim_isAbsName((char_u *)stackp->ffs_fix_path) && search_ctx->ffsc_start_dir) { if (strlen(search_ctx->ffsc_start_dir) + 1 >= MAXPATHL) { ff_free_stack_element(stackp); goto fail; } STRCPY(file_path, search_ctx->ffsc_start_dir); - if (!add_pathsep((char *)file_path)) { + if (!add_pathsep(file_path)) { ff_free_stack_element(stackp); goto fail; } } // append the fix part of the search path - if (STRLEN(file_path) + STRLEN(stackp->ffs_fix_path) + 1 >= MAXPATHL) { + if (strlen(file_path) + strlen(stackp->ffs_fix_path) + 1 >= MAXPATHL) { ff_free_stack_element(stackp); goto fail; } STRCAT(file_path, stackp->ffs_fix_path); - if (!add_pathsep((char *)file_path)) { + if (!add_pathsep(file_path)) { ff_free_stack_element(stackp); goto fail; } rest_of_wildcards = stackp->ffs_wc_path; if (*rest_of_wildcards != NUL) { - len = STRLEN(file_path); + len = strlen(file_path); if (STRNCMP(rest_of_wildcards, "**", 2) == 0) { // pointer to the restrict byte // The restrict byte is not a character! @@ -705,7 +705,7 @@ char_u *vim_findfile(void *search_ctx_arg) if (stackp->ffs_star_star_empty == 0) { // if not done before, expand '**' to empty stackp->ffs_star_star_empty = 1; - dirptrs[1] = (char *)stackp->ffs_fix_path; + dirptrs[1] = stackp->ffs_fix_path; } } @@ -748,7 +748,7 @@ char_u *vim_findfile(void *search_ctx_arg) stackp->ffs_filearray_cur = 0; stackp->ffs_stage = 0; } else { - rest_of_wildcards = &stackp->ffs_wc_path[STRLEN(stackp->ffs_wc_path)]; + rest_of_wildcards = &stackp->ffs_wc_path[strlen(stackp->ffs_wc_path)]; } if (stackp->ffs_stage == 0) { @@ -768,7 +768,7 @@ char_u *vim_findfile(void *search_ctx_arg) goto fail; } STRCPY(file_path, stackp->ffs_filearray[i]); - if (!add_pathsep((char *)file_path)) { + if (!add_pathsep(file_path)) { ff_free_stack_element(stackp); goto fail; } @@ -776,7 +776,7 @@ char_u *vim_findfile(void *search_ctx_arg) // Try without extra suffix and then with suffixes // from 'suffixesadd'. - len = STRLEN(file_path); + len = strlen(file_path); if (search_ctx->ffsc_tagfile) { suf = ""; } else { @@ -784,14 +784,14 @@ char_u *vim_findfile(void *search_ctx_arg) } for (;;) { // if file exists and we didn't already find it - if ((path_with_url((char *)file_path) - || (os_path_exists((char *)file_path) + if ((path_with_url(file_path) + || (os_path_exists(file_path) && (search_ctx->ffsc_find_what == FINDFILE_BOTH || ((search_ctx->ffsc_find_what == FINDFILE_DIR) - == os_isdir((char *)file_path))))) + == os_isdir(file_path))))) #ifndef FF_VERBOSE && (ff_check_visited(&search_ctx->ffsc_visited_list->ffvl_visited_list, - (char *)file_path, "") == OK) + file_path, "") == OK) #endif ) { #ifdef FF_VERBOSE @@ -812,12 +812,11 @@ char_u *vim_findfile(void *search_ctx_arg) stackp->ffs_filearray_cur = i + 1; ff_push(search_ctx, stackp); - if (!path_with_url((char *)file_path)) { - simplify_filename(file_path); + if (!path_with_url(file_path)) { + simplify_filename((char_u *)file_path); } - if (os_dirname((char_u *)ff_expand_buffer, MAXPATHL) - == OK) { - p = (char_u *)path_shorten_fname((char *)file_path, ff_expand_buffer); + if (os_dirname((char_u *)ff_expand_buffer, MAXPATHL) == OK) { + p = path_shorten_fname(file_path, ff_expand_buffer); if (p != NULL) { STRMOVE(file_path, p); } @@ -830,7 +829,7 @@ char_u *vim_findfile(void *search_ctx_arg) verbose_leave_scroll(); } #endif - return file_path; + return (char_u *)file_path; } // Not found or found already, try next suffix. @@ -838,7 +837,7 @@ char_u *vim_findfile(void *search_ctx_arg) break; } assert(MAXPATHL >= len); - copy_option_part(&suf, (char *)file_path + len, MAXPATHL - len, ","); + copy_option_part(&suf, file_path + len, MAXPATHL - len, ","); } } } else { @@ -849,7 +848,7 @@ char_u *vim_findfile(void *search_ctx_arg) } ff_push(search_ctx, ff_create_stack_element(stackp->ffs_filearray[i], - (char *)rest_of_wildcards, + rest_of_wildcards, stackp->ffs_level - 1, 0)); } } @@ -863,7 +862,7 @@ char_u *vim_findfile(void *search_ctx_arg) for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; i++) { if (path_fnamecmp(stackp->ffs_filearray[i], - (char *)stackp->ffs_fix_path) == 0) { + stackp->ffs_fix_path) == 0) { continue; // don't repush same directory } if (!os_isdir(stackp->ffs_filearray[i])) { @@ -871,7 +870,7 @@ char_u *vim_findfile(void *search_ctx_arg) } ff_push(search_ctx, ff_create_stack_element(stackp->ffs_filearray[i], - (char *)stackp->ffs_wc_path, stackp->ffs_level - 1, 1)); + stackp->ffs_wc_path, stackp->ffs_level - 1, 1)); } } @@ -911,13 +910,13 @@ char_u *vim_findfile(void *search_ctx_arg) goto fail; } STRCPY(file_path, search_ctx->ffsc_start_dir); - if (!add_pathsep((char *)file_path)) { + if (!add_pathsep(file_path)) { goto fail; } STRCAT(file_path, search_ctx->ffsc_fix_path); // create a new stack entry - sptr = ff_create_stack_element((char *)file_path, + sptr = ff_create_stack_element(file_path, search_ctx->ffsc_wc_path, search_ctx->ffsc_level, 0); ff_push(search_ctx, sptr); } else { @@ -1136,12 +1135,12 @@ static ff_stack_T *ff_create_stack_element(char *fix_part, char *wc_part, int le if (fix_part == NULL) { fix_part = ""; } - new->ffs_fix_path = (char_u *)xstrdup(fix_part); + new->ffs_fix_path = xstrdup(fix_part); if (wc_part == NULL) { wc_part = ""; } - new->ffs_wc_path = (char_u *)xstrdup(wc_part); + new->ffs_wc_path = xstrdup(wc_part); return new; } @@ -1242,7 +1241,7 @@ static int ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v) } for (i = 0; stopdirs_v[i] != NULL; i++) { - if ((int)STRLEN(stopdirs_v[i]) > path_len) { + if ((int)strlen(stopdirs_v[i]) > path_len) { // match for parent directory. So '/home' also matches // '/home/rks'. Check for PATHSEP in stopdirs_v[i], else // '/home/r' would also match '/home/rks' @@ -1288,11 +1287,11 @@ static int ff_path_in_stoplist(char *path, int path_len, char **stopdirs_v) /// @return an allocated string for the file name. NULL for error. char_u *find_file_in_path(char_u *ptr, size_t len, int options, int first, char_u *rel_fname) { - return find_file_in_path_option(ptr, len, options, first, - (*curbuf->b_p_path == NUL - ? p_path - : (char_u *)curbuf->b_p_path), - FINDFILE_BOTH, rel_fname, (char_u *)curbuf->b_p_sua); + return (char_u *)find_file_in_path_option((char *)ptr, len, options, first, + (*curbuf->b_p_path == NUL + ? (char *)p_path + : curbuf->b_p_path), + FINDFILE_BOTH, (char *)rel_fname, curbuf->b_p_sua); } static char *ff_file_to_find = NULL; @@ -1323,8 +1322,8 @@ void free_findfile(void) /// @return an allocated string for the file name. NULL for error. char_u *find_directory_in_path(char_u *ptr, size_t len, int options, char_u *rel_fname) { - return find_file_in_path_option(ptr, len, options, true, p_cdpath, - FINDFILE_DIR, rel_fname, (char_u *)""); + return (char_u *)find_file_in_path_option((char *)ptr, len, options, true, (char *)p_cdpath, + FINDFILE_DIR, (char *)rel_fname, ""); } /// @param ptr file name @@ -1334,13 +1333,12 @@ char_u *find_directory_in_path(char_u *ptr, size_t len, int options, char_u *rel /// @param find_what FINDFILE_FILE, _DIR or _BOTH /// @param rel_fname file name we are looking relative to. /// @param suffixes list of suffixes, 'suffixesadd' option -char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first, - char_u *path_option, int find_what, char_u *rel_fname, - char_u *suffixes) +char *find_file_in_path_option(char *ptr, size_t len, int options, int first, char *path_option, + int find_what, char *rel_fname, char *suffixes) { static char *dir; static int did_findfile_init = false; - char_u save_char; + char save_char; char *file_name = NULL; char *buf = NULL; int rel_to_curdir; @@ -1358,16 +1356,16 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first // copy file name into NameBuff, expanding environment variables save_char = ptr[len]; ptr[len] = NUL; - expand_env_esc(ptr, (char_u *)NameBuff, MAXPATHL, false, true, NULL); + expand_env_esc(ptr, NameBuff, MAXPATHL, false, true, NULL); ptr[len] = save_char; xfree(ff_file_to_find); ff_file_to_find = xstrdup(NameBuff); if (options & FNAME_UNESC) { // Change all "\ " to " ". - for (ptr = (char_u *)ff_file_to_find; *ptr != NUL; ptr++) { + for (ptr = ff_file_to_find; *ptr != NUL; ptr++) { if (ptr[0] == '\\' && ptr[1] == ' ') { - memmove(ptr, ptr + 1, STRLEN(ptr)); + memmove(ptr, ptr + 1, strlen(ptr)); } } } @@ -1406,7 +1404,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first && rel_to_curdir && (options & FNAME_REL) && rel_fname != NULL - && STRLEN(rel_fname) + l < MAXPATHL) { + && strlen(rel_fname) + l < MAXPATHL) { STRCPY(NameBuff, rel_fname); STRCPY(path_tail((char *)NameBuff), ff_file_to_find); l = strlen(NameBuff); @@ -1416,7 +1414,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first } // When the file doesn't exist, try adding parts of 'suffixesadd'. - buf = (char *)suffixes; + buf = suffixes; for (;;) { if ((os_path_exists(NameBuff) && (find_what == FINDFILE_BOTH @@ -1440,7 +1438,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first if (first == true) { // vim_findfile_free_visited can handle a possible NULL pointer vim_findfile_free_visited(fdip_search_ctx); - dir = (char *)path_option; + dir = path_option; did_findfile_init = false; } @@ -1472,7 +1470,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first r_ptr = vim_findfile_stopdir((char_u *)buf); fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find, (char *)r_ptr, 100, false, find_what, - fdip_search_ctx, false, (char *)rel_fname); + fdip_search_ctx, false, rel_fname); if (fdip_search_ctx != NULL) { did_findfile_init = true; } @@ -1501,7 +1499,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first } theend: - return (char_u *)file_name; + return file_name; } void do_autocmd_dirchanged(char *new_dir, CdScope scope, CdCause cause, bool pre) @@ -1608,9 +1606,9 @@ int vim_chdirfile(char *fname, CdCause cause) } /// Change directory to "new_dir". Search 'cdpath' for relative directory names. -int vim_chdir(char_u *new_dir) +int vim_chdir(char *new_dir) { - char *dir_name = (char *)find_directory_in_path(new_dir, STRLEN(new_dir), + char *dir_name = (char *)find_directory_in_path((char_u *)new_dir, strlen(new_dir), FNAME_MESS, (char_u *)curbuf->b_ffname); if (dir_name == NULL) { return -1; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index d6bc861c09..746788413f 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -993,7 +993,7 @@ retry: tlen = 0; for (;;) { p = (char_u *)ml_get(read_buf_lnum) + read_buf_col; - n = (int)STRLEN(p); + n = (int)strlen((char *)p); if ((int)tlen + n + 1 > size) { // Filled up to "size", append partial line. // Change NL to NUL to reverse the effect done @@ -3737,22 +3737,22 @@ static bool msg_add_fileformat(int eol_type) /// Append line and character count to IObuff. void msg_add_lines(int insert_space, long lnum, off_T nchars) { - char_u *p; + char *p; - p = (char_u *)IObuff + STRLEN(IObuff); + p = IObuff + strlen(IObuff); if (insert_space) { *p++ = ' '; } if (shortmess(SHM_LINES)) { - vim_snprintf((char *)p, (size_t)(IOSIZE - (p - (char_u *)IObuff)), "%" PRId64 "L, %" PRId64 "B", + vim_snprintf(p, (size_t)(IOSIZE - (p - IObuff)), "%" PRId64 "L, %" PRId64 "B", (int64_t)lnum, (int64_t)nchars); } else { - vim_snprintf((char *)p, (size_t)(IOSIZE - (p - (char_u *)IObuff)), + vim_snprintf(p, (size_t)(IOSIZE - (p - IObuff)), NGETTEXT("%" PRId64 " line, ", "%" PRId64 " lines, ", lnum), (int64_t)lnum); - p += STRLEN(p); - vim_snprintf((char *)p, (size_t)(IOSIZE - (p - (char_u *)IObuff)), + p += strlen(p); + vim_snprintf(p, (size_t)(IOSIZE - (p - IObuff)), NGETTEXT("%" PRId64 " byte", "%" PRId64 " bytes", nchars), (int64_t)nchars); } @@ -4342,7 +4342,8 @@ char *modname(const char *fname, const char *ext, bool prepend_dot) /// @param fp file to read from /// /// @return true for EOF or error -bool vim_fgets(char_u *buf, int size, FILE *fp) FUNC_ATTR_NONNULL_ALL +bool vim_fgets(char *buf, int size, FILE *fp) + FUNC_ATTR_NONNULL_ALL { char *retval; @@ -4351,7 +4352,7 @@ bool vim_fgets(char_u *buf, int size, FILE *fp) FUNC_ATTR_NONNULL_ALL do { errno = 0; - retval = fgets((char *)buf, size, fp); + retval = fgets(buf, size, fp); } while (retval == NULL && errno == EINTR && ferror(fp)); if (buf[size - 2] != NUL && buf[size - 2] != '\n') { diff --git a/src/nvim/help.c b/src/nvim/help.c index 7ea7dfb709..8930f74e7f 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -570,7 +570,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep void cleanup_help_tags(int num_file, char **file) { char buf[4]; - char_u *p = (char_u *)buf; + char *p = buf; if (p_hlg[0] != NUL && (p_hlg[0] != 'e' || p_hlg[1] != 'n')) { *p++ = '@'; @@ -785,7 +785,7 @@ void fix_help_buffer(void) if (fd == NULL) { continue; } - vim_fgets((char_u *)IObuff, IOSIZE, fd); + vim_fgets(IObuff, IOSIZE, fd); if (IObuff[0] == '*' && (s = vim_strchr((char *)IObuff + 1, '*')) != NULL) { @@ -944,7 +944,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool const char *const fname = files[fi] + dirlen + 1; bool firstline = true; - while (!vim_fgets((char_u *)IObuff, IOSIZE, fd) && !got_int) { + while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) { if (firstline) { // Detect utf-8 file by a non-ASCII char in the first line. TriState this_utf8 = kNone; diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 77fe176de1..0f1159fb94 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -1003,7 +1003,7 @@ static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX curwin->w_cursor.col++; } if ((trypos = findmatchlimit(NULL, 0, 0, curbuf->b_ind_maxparen)) != NULL - && *cin_skipcomment(ml_get_pos(trypos) + 1) == ';') { + && *cin_skipcomment((char_u *)ml_get_pos(trypos) + 1) == ';') { retval = true; } curwin->w_cursor = cursor_save; diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index ed851683fd..65380b92fc 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -1463,12 +1463,12 @@ static void ins_compl_files(int count, char **files, int thesaurus, int flags, r // Read dictionary file line by line. // Check each line for a match. - while (!got_int && !compl_interrupted && !vim_fgets(buf, LSIZE, fp)) { + while (!got_int && !compl_interrupted && !vim_fgets((char *)buf, LSIZE, fp)) { ptr = buf; while (vim_regexec(regmatch, (char *)buf, (colnr_T)(ptr - buf))) { ptr = (char_u *)regmatch->startp[0]; if (ctrl_x_mode_line_or_eval()) { - ptr = find_line_end(ptr); + ptr = (char_u *)find_line_end((char *)ptr); } else { ptr = find_word_end(ptr); } @@ -1529,12 +1529,13 @@ char_u *find_word_end(char_u *ptr) } /// Find the end of the line, omitting CR and NL at the end. -/// Returns a pointer to just after the line. -static char_u *find_line_end(char_u *ptr) +/// +/// @return a pointer to just after the line. +static char *find_line_end(char *ptr) { - char_u *s; + char *s; - s = ptr + STRLEN(ptr); + s = ptr + strlen(ptr); while (s > ptr && (s[-1] == CAR || s[-1] == NL)) { s--; } diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 76a646083e..cc8ebe10cf 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -419,7 +419,7 @@ static int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *ma // {lhs_end} is a pointer to the "terminating whitespace" after {lhs}. // Use that to initialize {rhs_start}. - const char_u *rhs_start = (char_u *)skipwhite((char *)lhs_end); + const char *rhs_start = skipwhite((char *)lhs_end); // Given {lhs} might be larger than MAXMAPLEN before replace_termcodes // (e.g. "<Space>" is longer than ' '), so first copy into a buffer. @@ -430,9 +430,9 @@ static int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *ma char_u lhs_to_replace[256]; STRLCPY(lhs_to_replace, to_parse, orig_lhs_len + 1); - size_t orig_rhs_len = STRLEN(rhs_start); + size_t orig_rhs_len = strlen(rhs_start); if (!set_maparg_lhs_rhs((char *)lhs_to_replace, orig_lhs_len, - (char *)rhs_start, orig_rhs_len, LUA_NOREF, + rhs_start, orig_rhs_len, LUA_NOREF, CPO_TO_CPO_FLAGS, mapargs)) { return 1; } @@ -471,7 +471,7 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table, args->orig_rhs = NULL; args->rhs_lua = LUA_NOREF; } - mp->m_keylen = (int)STRLEN(mp->m_keys); + mp->m_keylen = (int)strlen((char *)mp->m_keys); mp->m_noremap = noremap; mp->m_nowait = args->nowait; mp->m_silent = args->silent; @@ -1392,7 +1392,7 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol) int len; int scol; // starting column of the abbr. int j; - char_u *s; + char *s; char_u tb[MB_MAXBYTES + 4]; mapblock_T *mp; mapblock_T *mp2; @@ -1462,7 +1462,7 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol) // Might have K_SPECIAL escaped mp->m_keys. q = xstrdup((char *)mp->m_keys); vim_unescape_ks((char_u *)q); - qlen = (int)STRLEN(q); + qlen = (int)strlen(q); } // find entries with right mode and keys match = (mp->m_mode & State) @@ -1505,9 +1505,9 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol) int newlen = utf_char2bytes(c, (char *)tb + j); tb[j + newlen] = NUL; // Need to escape K_SPECIAL. - char_u *escaped = (char_u *)vim_strsave_escape_ks((char *)tb + j); + char *escaped = vim_strsave_escape_ks((char *)tb + j); if (escaped != NULL) { - newlen = (int)STRLEN(escaped); + newlen = (int)strlen(escaped); memmove(tb + j, escaped, (size_t)newlen); j += newlen; xfree(escaped); @@ -1518,15 +1518,15 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol) (void)ins_typebuf((char *)tb, 1, 0, true, mp->m_silent); } if (mp->m_expr) { - s = (char_u *)eval_map_expr(mp, c); + s = eval_map_expr(mp, c); } else { - s = (char_u *)mp->m_str; + s = mp->m_str; } if (s != NULL) { // insert the to string - (void)ins_typebuf((char *)s, mp->m_noremap, 0, true, mp->m_silent); + (void)ins_typebuf(s, mp->m_noremap, 0, true, mp->m_silent); // no abbrev. for these chars - typebuf.tb_no_abbr_cnt += (int)STRLEN(s) + j + 1; + typebuf.tb_no_abbr_cnt += (int)strlen(s) + j + 1; if (mp->m_expr) { xfree(s); } @@ -1597,7 +1597,7 @@ char *eval_map_expr(mapblock_T *mp, int c) char *res = NULL; if (mp->m_replace_keycodes) { - replace_termcodes(p, STRLEN(p), &res, REPTERM_DO_LT, NULL, CPO_TO_CPO_FLAGS); + replace_termcodes(p, strlen(p), &res, REPTERM_DO_LT, NULL, CPO_TO_CPO_FLAGS); } else { // Escape K_SPECIAL in the result to be able to use the string as typeahead. res = vim_strsave_escape_ks(p); @@ -1926,14 +1926,14 @@ int put_escstr(FILE *fd, char_u *strstart, int what) /// @param abbr do abbreviations /// @param mp_ptr return: pointer to mapblock or NULL /// @param local_ptr return: buffer-local mapping or NULL -char_u *check_map(char_u *keys, int mode, int exact, int ign_mod, int abbr, mapblock_T **mp_ptr, - int *local_ptr, int *rhs_lua) +char *check_map(char *keys, int mode, int exact, int ign_mod, int abbr, mapblock_T **mp_ptr, + int *local_ptr, int *rhs_lua) { int len, minlen; mapblock_T *mp; *rhs_lua = LUA_NOREF; - len = (int)STRLEN(keys); + len = (int)strlen(keys); for (int local = 1; local >= 0; local--) { // loop over all hash lists for (int hash = 0; hash < 256; hash++) { @@ -1970,7 +1970,7 @@ char_u *check_map(char_u *keys, int mode, int exact, int ign_mod, int abbr, mapb *local_ptr = local; } *rhs_lua = mp->m_luaref; - return mp->m_luaref == LUA_NOREF ? (char_u *)mp->m_str : NULL; + return mp->m_luaref == LUA_NOREF ? mp->m_str : NULL; } } } @@ -2104,7 +2104,8 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) mapblock_T *mp = NULL; int buffer_local; LuaRef rhs_lua; - char_u *rhs = check_map(keys_simplified, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); + char *rhs = check_map((char *)keys_simplified, mode, exact, false, abbr, &mp, &buffer_local, + &rhs_lua); if (did_simplify) { // When the lhs is being simplified the not-simplified keys are // preferred for printing, like in do_map(). @@ -2112,7 +2113,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) strlen(keys), &alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL, CPO_TO_CPO_FLAGS); - rhs = check_map((char_u *)alt_keys_buf, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); + rhs = check_map(alt_keys_buf, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); } if (!get_dict) { @@ -2121,7 +2122,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) if (*rhs == NUL) { rettv->vval.v_string = xstrdup("<Nop>"); } else { - rettv->vval.v_string = str2special_save((char *)rhs, false, false); + rettv->vval.v_string = str2special_save(rhs, false, false); } } else if (rhs_lua != LUA_NOREF) { rettv->vval.v_string = nlua_funcref_str(mp->m_luaref); diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 5f21a3dd0e..6e1316d651 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1262,7 +1262,7 @@ int recover_names(char_u *fname, int list, int nr, char **fname_out) names[2] = concat_fnames(dir_name, ".sw?", true); num_names = 3; } else { - int len = (int)STRLEN(dir_name); + int len = (int)strlen(dir_name); p = dir_name + len; if (after_pathsep(dir_name, p) && len > 1 @@ -1745,10 +1745,10 @@ char *ml_get(linenr_T lnum) } /// @return pointer to position "pos". -char_u *ml_get_pos(const pos_T *pos) +char *ml_get_pos(const pos_T *pos) FUNC_ATTR_NONNULL_ALL { - return (char_u *)ml_get_buf(curbuf, pos->lnum, false) + pos->col; + return ml_get_buf(curbuf, pos->lnum, false) + pos->col; } /// @return codepoint at pos. pos must be either valid or have col set to MAXCOL! @@ -1759,7 +1759,7 @@ int gchar_pos(pos_T *pos) if (pos->col == MAXCOL) { return NUL; } - return utf_ptr2char((char *)ml_get_pos(pos)); + return utf_ptr2char(ml_get_pos(pos)); } /// @param will_change true mark the buffer dirty (chars in the line will be changed) @@ -1828,7 +1828,7 @@ errorret: } if (will_change) { buf->b_ml.ml_flags |= (ML_LOCKED_DIRTY | ML_LOCKED_POS); - ml_add_deleted_len_buf(buf, buf->b_ml.ml_line_ptr, -1); + ml_add_deleted_len_buf(buf, (char *)buf->b_ml.ml_line_ptr, -1); } return (char *)buf->b_ml.ml_line_ptr; @@ -2304,10 +2304,10 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b void ml_add_deleted_len(char *ptr, ssize_t len) { - ml_add_deleted_len_buf(curbuf, (char_u *)ptr, len); + ml_add_deleted_len_buf(curbuf, ptr, len); } -void ml_add_deleted_len_buf(buf_T *buf, char_u *ptr, ssize_t len) +void ml_add_deleted_len_buf(buf_T *buf, char *ptr, ssize_t len) { if (inhibit_delete_count) { return; @@ -2319,7 +2319,7 @@ void ml_add_deleted_len_buf(buf_T *buf, char_u *ptr, ssize_t len) curbuf->deleted_bytes += (size_t)len + 1; curbuf->deleted_bytes2 += (size_t)len + 1; if (curbuf->update_need_codepoints) { - mb_utflen(ptr, (size_t)len, &curbuf->deleted_codepoints, + mb_utflen((char_u *)ptr, (size_t)len, &curbuf->deleted_codepoints, &curbuf->deleted_codeunits); curbuf->deleted_codepoints++; // NL char curbuf->deleted_codeunits++; @@ -2362,14 +2362,14 @@ int ml_replace_buf(buf_T *buf, linenr_T lnum, char *line, bool copy) if (buf->b_ml.ml_line_lnum != lnum) { // other line buffered ml_flush_line(buf); // flush it } else if (buf->b_ml.ml_flags & ML_LINE_DIRTY) { // same line allocated - ml_add_deleted_len_buf(buf, buf->b_ml.ml_line_ptr, -1); + ml_add_deleted_len_buf(buf, (char *)buf->b_ml.ml_line_ptr, -1); readlen = false; // already added the length xfree(buf->b_ml.ml_line_ptr); // free it } if (readlen && kv_size(buf->update_callbacks)) { - ml_add_deleted_len_buf(buf, (char_u *)ml_get_buf(buf, lnum, false), -1); + ml_add_deleted_len_buf(buf, ml_get_buf(buf, lnum, false), -1); } buf->b_ml.ml_line_ptr = (char_u *)line; @@ -2446,7 +2446,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message) // Line should always have an NL char internally (represented as NUL), // even if 'noeol' is set. assert(line_size >= 1); - ml_add_deleted_len_buf(buf, (char_u *)dp + line_start, line_size - 1); + ml_add_deleted_len_buf(buf, (char *)dp + line_start, line_size - 1); // special case: If there is only one line in the data block it becomes empty. // Then we have to remove the entry, pointing to this data block, from the @@ -3003,8 +3003,8 @@ int resolve_symlink(const char *fname, char *buf) if (path_is_absolute((char_u *)buf)) { STRCPY(tmp, buf); } else { - char_u *tail = (char_u *)path_tail(tmp); - if (STRLEN(tail) + strlen(buf) >= MAXPATHL) { + char *tail = path_tail(tmp); + if (strlen(tail) + strlen(buf) >= MAXPATHL) { return FAIL; } STRCPY(tail, buf); @@ -3968,7 +3968,7 @@ int inc(pos_T *lp) { // when searching position may be set to end of a line if (lp->col != MAXCOL) { - const char_u *const p = ml_get_pos(lp); + const char *const p = ml_get_pos(lp); if (*p != NUL) { // still within line, move to next char (may be NUL) const int l = utfc_ptr2len((char *)p); diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ed689df91c..5536b7ba08 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1832,11 +1832,11 @@ void clear_showcmd(void) int chars = 0; if (cursor_bot) { - s = ml_get_pos(&VIsual); + s = (char_u *)ml_get_pos(&VIsual); e = (char_u *)get_cursor_pos_ptr(); } else { s = (char_u *)get_cursor_pos_ptr(); - e = ml_get_pos(&VIsual); + e = (char_u *)ml_get_pos(&VIsual); } while ((*p_sel != 'e') ? s <= e : s < e) { l = utfc_ptr2len((char *)s); @@ -2740,7 +2740,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar) len = spell_move_to(curwin, FORWARD, true, true, NULL); emsg_off--; if (len != 0 && curwin->w_cursor.col <= pos.col) { - ptr = (char *)ml_get_pos(&curwin->w_cursor); + ptr = ml_get_pos(&curwin->w_cursor); } curwin->w_cursor = pos; } @@ -3586,10 +3586,10 @@ bool get_visual_text(cmdarg_T *cap, char **pp, size_t *lenp) *lenp = strlen(*pp); } else { if (lt(curwin->w_cursor, VIsual)) { - *pp = (char *)ml_get_pos(&curwin->w_cursor); + *pp = ml_get_pos(&curwin->w_cursor); *lenp = (size_t)VIsual.col - (size_t)curwin->w_cursor.col + 1; } else { - *pp = (char *)ml_get_pos(&VIsual); + *pp = ml_get_pos(&VIsual); *lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1; } if (**pp == NUL) { @@ -4006,7 +4006,7 @@ static int normal_search(cmdarg_T *cap, int dir, char *pat, int opt, int *wrappe curwin->w_set_curswant = true; CLEAR_FIELD(sia); - int i = do_search(cap->oap, dir, dir, (char_u *)pat, cap->count1, + int i = do_search(cap->oap, dir, dir, pat, cap->count1, opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, &sia); if (wrapped != NULL) { *wrapped = sia.sa_wrapped; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index f1814291b8..0cae0e854f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -80,7 +80,7 @@ struct block_def { int startspaces; // 'extra' cols before first char int endspaces; // 'extra' cols after last char int textlen; // chars in block - char_u *textstart; // pointer to 1st char (partially) in block + char *textstart; // pointer to 1st char (partially) in block colnr_T textcol; // index of chars (partially) in block colnr_T start_vcol; // start col of 1st char wholly inside block colnr_T end_vcol; // start col of 1st char wholly after block @@ -90,7 +90,7 @@ struct block_def { int pre_whitesp; // screen cols of ws before block int pre_whitesp_c; // chars of ws before block colnr_T end_char_vcols; // number of vcols of post-block char - colnr_T start_char_vcols; // number of vcols of pre-block char + colnr_T start_char_vcols; // number of vcols of pre-block char }; #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -358,7 +358,7 @@ static void shift_block(oparg_T *oap, int amount) return; // multiplication overflow } - char_u *const oldp = (char_u *)get_cursor_line_ptr(); + char *const oldp = get_cursor_line_ptr(); int startcol, oldlen, newlen; @@ -369,9 +369,9 @@ static void shift_block(oparg_T *oap, int amount) // 4. Construct new string total += bd.pre_whitesp; // all virtual WS up to & incl a split TAB colnr_T ws_vcol = bd.start_vcol - bd.pre_whitesp; - char_u *old_textstart = bd.textstart; + char *old_textstart = bd.textstart; if (bd.startspaces) { - if (utfc_ptr2len((char *)bd.textstart) == 1) { + if (utfc_ptr2len(bd.textstart) == 1) { bd.textstart++; } else { ws_vcol = 0; @@ -382,13 +382,13 @@ static void shift_block(oparg_T *oap, int amount) // TODO(vim): is passing bd.textstart for start of the line OK? chartabsize_T cts; init_chartabsize_arg(&cts, curwin, curwin->w_cursor.lnum, - bd.start_vcol, (char *)bd.textstart, (char *)bd.textstart); + bd.start_vcol, bd.textstart, bd.textstart); while (ascii_iswhite(*cts.cts_ptr)) { incr = lbr_chartabsize_adv(&cts); total += incr; cts.cts_vcol += incr; } - bd.textstart = (char_u *)cts.cts_ptr; + bd.textstart = cts.cts_ptr; bd.start_vcol = cts.cts_vcol; clear_chartabsize_arg(&cts); @@ -403,7 +403,7 @@ static void shift_block(oparg_T *oap, int amount) // if we're splitting a TAB, allow for it int col_pre = bd.pre_whitesp_c - (bd.startspaces != 0); bd.textcol -= col_pre; - const int len = (int)STRLEN(bd.textstart) + 1; + const int len = (int)strlen(bd.textstart) + 1; int col = bd.textcol + i + j + len; assert(col >= 0); newp = (char_u *)xmalloc((size_t)col); @@ -419,14 +419,14 @@ static void shift_block(oparg_T *oap, int amount) } else { // left colnr_T destination_col; // column to which text in block will // be shifted - char_u *verbatim_copy_end; // end of the part of the line which is + char *verbatim_copy_end; // end of the part of the line which is // copied verbatim colnr_T verbatim_copy_width; // the (displayed) width of this part // of line 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 *non_white = (char *)bd.textstart; + char *non_white = 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 @@ -446,7 +446,7 @@ 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, non_white); + non_white_col, bd.textstart, non_white); while (ascii_iswhite(*cts.cts_ptr)) { incr = lbr_chartabsize_adv(&cts); cts.cts_vcol += incr; @@ -475,7 +475,7 @@ static void shift_block(oparg_T *oap, int amount) verbatim_copy_width -= bd.start_char_vcols; } init_chartabsize_arg(&cts, curwin, 0, verbatim_copy_width, - (char *)bd.textstart, (char *)verbatim_copy_end); + bd.textstart, verbatim_copy_end); while (cts.cts_vcol < destination_col) { incr = lbr_chartabsize(&cts); if (cts.cts_vcol + incr > destination_col) { @@ -485,7 +485,7 @@ static void shift_block(oparg_T *oap, int amount) MB_PTR_ADV(cts.cts_ptr); } verbatim_copy_width = cts.cts_vcol; - verbatim_copy_end = (char_u *)cts.cts_ptr; + verbatim_copy_end = cts.cts_ptr; clear_chartabsize_arg(&cts); // If "destination_col" is different from the width of the initial @@ -504,7 +504,7 @@ static void shift_block(oparg_T *oap, int amount) newp = (char_u *)xmalloc(new_line_len); startcol = (int)verbatim_diff; - oldlen = bd.textcol + (int)(non_white - (char *)bd.textstart) - (int)verbatim_diff; + oldlen = bd.textcol + (int)(non_white - bd.textstart) - (int)verbatim_diff; newlen = (int)fill; memmove(newp, oldp, verbatim_diff); memset(newp + verbatim_diff, ' ', fill); @@ -2095,7 +2095,7 @@ void op_tilde(oparg_T *oap) for (;;) { did_change |= swapchars(oap->op_type, &pos, pos.lnum == oap->end.lnum ? oap->end.col + 1 : - (int)STRLEN(ml_get_pos(&pos))); + (int)strlen(ml_get_pos(&pos))); if (ltoreq(oap->end, pos) || inc(&pos) == -1) { break; } @@ -2138,7 +2138,7 @@ static int swapchars(int op_type, pos_T *pos, int length) int did_change = 0; for (int todo = length; todo > 0; todo--) { - const int len = utfc_ptr2len((char *)ml_get_pos(pos)); + const int len = utfc_ptr2len(ml_get_pos(pos)); // we're counting bytes, not characters if (len > 0) { @@ -2727,7 +2727,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 = (char_u *)p + startcol; + bd.textstart = p + startcol; yank_copy_line(reg, &bd, y_idx, false); break; } @@ -2838,7 +2838,7 @@ static void yank_copy_line(yankreg_T *reg, struct block_def *bd, size_t y_idx, int s = bd->textlen + bd->endspaces; while (s > 0 && ascii_iswhite(*(bd->textstart + s - 1))) { - s = s - utf_head_off((char *)bd->textstart, (char *)bd->textstart + s - 1) - 1; + s = s - utf_head_off(bd->textstart, bd->textstart + s - 1) - 1; pnew--; } } @@ -4346,7 +4346,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, bool bdp->textlen = (int)(pend - pstart); } bdp->textcol = (colnr_T)(pstart - line); - bdp->textstart = (char_u *)pstart; + bdp->textstart = pstart; restore_lbr(lbr_saved); } @@ -5403,7 +5403,7 @@ void cursor_pos_info(dict_T *dict) virtual_op = virtual_active(); block_prep(&oparg, &bd, lnum, false); virtual_op = kNone; - s = (char *)bd.textstart; + s = bd.textstart; len = (long)bd.textlen; break; case 'V': @@ -6085,7 +6085,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) // Include the trailing byte of a multi-byte char. if (oap->inclusive) { - const int l = utfc_ptr2len((char *)ml_get_pos(&oap->end)); + const int l = utfc_ptr2len(ml_get_pos(&oap->end)); if (l > 1) { oap->end.col += l - 1; } diff --git a/src/nvim/option.c b/src/nvim/option.c index 80931016a5..b78fc7c27a 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -702,14 +702,14 @@ void set_helplang_default(const char *lang) int idx = findoption("hlg"); if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) { if (options[idx].flags & P_ALLOCED) { - free_string_option((char *)p_hlg); + free_string_option(p_hlg); } - p_hlg = (char_u *)xmemdupz(lang, lang_len); + p_hlg = xmemdupz(lang, lang_len); // zh_CN becomes "cn", zh_TW becomes "tw". - if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) { - p_hlg[0] = (char_u)TOLOWER_ASC(p_hlg[3]); - p_hlg[1] = (char_u)TOLOWER_ASC(p_hlg[4]); - } else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C') { + if (STRNICMP(p_hlg, "zh_", 3) == 0 && strlen(p_hlg) >= 5) { + p_hlg[0] = (char)TOLOWER_ASC(p_hlg[3]); + p_hlg[1] = (char)TOLOWER_ASC(p_hlg[4]); + } else if (strlen(p_hlg) >= 1 && *p_hlg == 'C') { // any C like setting, such as C.UTF-8, becomes "en" p_hlg[0] = 'e'; p_hlg[1] = 'n'; @@ -1686,9 +1686,9 @@ static char *option_expand(int opt_idx, char *val) // Escape spaces when expanding 'tags', they are used to separate file // names. // For 'spellsuggest' expand after "file:". - expand_env_esc((char_u *)val, (char_u *)NameBuff, MAXPATHL, + expand_env_esc(val, NameBuff, MAXPATHL, (char_u **)options[opt_idx].var == &p_tags, false, - (char_u **)options[opt_idx].var == (char_u **)&p_sps ? (char_u *)"file:" : + (char_u **)options[opt_idx].var == (char_u **)&p_sps ? "file:" : NULL); if (strcmp(NameBuff, val) == 0) { // they are the same return NULL; @@ -4565,13 +4565,13 @@ static char_u expand_option_name[5] = { 't', '_', NUL, NUL, NUL }; static int expand_option_flags = 0; /// @param opt_flags OPT_GLOBAL and/or OPT_LOCAL -void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) +void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags) { - char_u nextchar; + char nextchar; uint32_t flags = 0; // init for GCC int opt_idx = 0; // init for GCC - char_u *p; - char_u *s; + char *p; + char *s; int is_term_option = false; int key; @@ -4579,12 +4579,12 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) xp->xp_context = EXPAND_SETTINGS; if (*arg == NUL) { - xp->xp_pattern = (char *)arg; + xp->xp_pattern = arg; return; } - p = arg + STRLEN(arg) - 1; + p = arg + strlen(arg) - 1; if (*p == ' ' && *(p - 1) != '\\') { - xp->xp_pattern = (char *)p + 1; + xp->xp_pattern = p + 1; return; } while (p > arg) { @@ -4610,7 +4610,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) xp->xp_context = EXPAND_BOOL_SETTINGS; p += 3; } - xp->xp_pattern = (char *)p; + xp->xp_pattern = p; arg = p; if (*arg == '<') { while (*p != '>') { @@ -4618,7 +4618,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) return; } } - key = get_special_key_code(arg + 1); + key = get_special_key_code((char_u *)arg + 1); if (key == 0) { // unknown name xp->xp_context = EXPAND_NOTHING; return; @@ -4638,8 +4638,8 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) } nextchar = *++p; is_term_option = true; - expand_option_name[2] = p[-2]; - expand_option_name[3] = p[-1]; + expand_option_name[2] = (char_u)p[-2]; + expand_option_name[3] = (char_u)p[-1]; } else { // Allow * wildcard. while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') { @@ -4678,7 +4678,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) } else { expand_option_idx = opt_idx; } - xp->xp_pattern = (char *)p + 1; + xp->xp_pattern = p + 1; return; } xp->xp_context = EXPAND_NOTHING; @@ -4686,29 +4686,29 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) return; } - xp->xp_pattern = (char *)p + 1; + xp->xp_pattern = p + 1; if (flags & P_EXPAND) { - p = options[opt_idx].var; - if (p == (char_u *)&p_bdir - || p == (char_u *)&p_dir - || p == (char_u *)&p_path - || p == (char_u *)&p_pp - || p == (char_u *)&p_rtp - || p == (char_u *)&p_cdpath - || p == (char_u *)&p_vdir) { + p = (char *)options[opt_idx].var; + if (p == (char *)&p_bdir + || p == (char *)&p_dir + || p == (char *)&p_path + || p == (char *)&p_pp + || p == (char *)&p_rtp + || p == (char *)&p_cdpath + || p == (char *)&p_vdir) { xp->xp_context = EXPAND_DIRECTORIES; - if (p == (char_u *)&p_path || p == (char_u *)&p_cdpath) { + if (p == (char *)&p_path || p == (char *)&p_cdpath) { xp->xp_backslash = XP_BS_THREE; } else { xp->xp_backslash = XP_BS_ONE; } - } else if (p == (char_u *)&p_ft) { + } else if (p == (char *)&p_ft) { xp->xp_context = EXPAND_FILETYPE; } else { xp->xp_context = EXPAND_FILES; // for 'tags' need three backslashes for a space - if (p == (char_u *)&p_tags) { + if (p == (char *)&p_tags) { xp->xp_backslash = XP_BS_THREE; } else { xp->xp_backslash = XP_BS_ONE; @@ -4718,16 +4718,16 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) // For an option that is a list of file names, find the start of the // last file name. - for (p = arg + STRLEN(arg) - 1; p > (char_u *)xp->xp_pattern; p--) { + for (p = arg + strlen(arg) - 1; p > xp->xp_pattern; p--) { // count number of backslashes before ' ' or ',' if (*p == ' ' || *p == ',') { s = p; - while (s > (char_u *)xp->xp_pattern && *(s - 1) == '\\') { + while (s > xp->xp_pattern && *(s - 1) == '\\') { s--; } if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) { - xp->xp_pattern = (char *)p + 1; + xp->xp_pattern = p + 1; break; } } @@ -4735,7 +4735,7 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) // for 'spellsuggest' start at "file:" if (options[opt_idx].var == (char_u *)&p_sps && STRNCMP(p, "file:", 5) == 0) { - xp->xp_pattern = (char *)p + 5; + xp->xp_pattern = p + 5; break; } } diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index c60925d485..40ce022bea 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -545,7 +545,7 @@ EXTERN char_u *p_guifont; // 'guifont' EXTERN char_u *p_guifontwide; // 'guifontwide' EXTERN char *p_hf; // 'helpfile' EXTERN long p_hh; // 'helpheight' -EXTERN char_u *p_hlg; // 'helplang' +EXTERN char *p_hlg; // 'helplang' EXTERN int p_hid; // 'hidden' EXTERN char *p_hl; // 'highlight' EXTERN int p_hls; // 'hlsearch' diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 5022334582..7522745bcb 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -741,9 +741,9 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf } } else if (varp == &curwin->w_p_cc) { // 'colorcolumn' errmsg = check_colorcolumn(curwin); - } else if (varp == (char **)&p_hlg) { // 'helplang' + } else if (varp == &p_hlg) { // 'helplang' // Check for "", "ab", "ab,cd", etc. - for (s = (char *)p_hlg; *s != NUL; s += 3) { + for (s = p_hlg; *s != NUL; s += 3) { if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) { errmsg = e_invarg; break; diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 8f58f5217e..dac3cae199 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -554,7 +554,7 @@ char *expand_env_save(char *src) char_u *expand_env_save_opt(char_u *src, bool one) { char_u *p = xmalloc(MAXPATHL); - expand_env_esc(src, p, MAXPATHL, false, one, NULL); + expand_env_esc((char *)src, (char *)p, MAXPATHL, false, one, NULL); return p; } @@ -568,7 +568,7 @@ char_u *expand_env_save_opt(char_u *src, bool one) /// @param dstlen Maximum length of the result void expand_env(char *src, char *dst, int dstlen) { - expand_env_esc((char_u *)src, (char_u *)dst, dstlen, false, false, NULL); + expand_env_esc(src, dst, dstlen, false, false, NULL); } /// Expand environment variable with path name and escaping. @@ -580,34 +580,34 @@ void expand_env(char *src, char *dst, int dstlen) /// @param esc Escape spaces in expanded variables /// @param one `srcp` is a single filename /// @param prefix Start again after this (can be NULL) -void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, bool esc, bool one, - char_u *prefix) +void expand_env_esc(char *restrict srcp, char *restrict dst, int dstlen, bool esc, bool one, + char *prefix) FUNC_ATTR_NONNULL_ARG(1, 2) { - char_u *tail; - char_u *var; + char *tail; + char *var; bool copy_char; bool mustfree; // var was allocated, need to free it later bool at_start = true; // at start of a name - int prefix_len = (prefix == NULL) ? 0 : (int)STRLEN(prefix); + int prefix_len = (prefix == NULL) ? 0 : (int)strlen(prefix); - char *src = skipwhite((char *)srcp); + char *src = skipwhite(srcp); dstlen--; // leave one char space for "\," while (*src && dstlen > 0) { // Skip over `=expr`. if (src[0] == '`' && src[1] == '=') { - var = (char_u *)src; + var = src; src += 2; (void)skip_expr(&src); if (*src == '`') { src++; } - size_t len = (size_t)(src - (char *)var); + size_t len = (size_t)(src - var); if (len > (size_t)dstlen) { len = (size_t)dstlen; } - memcpy((char *)dst, (char *)var, len); + memcpy(dst, var, len); dst += len; dstlen -= (int)len; continue; @@ -620,7 +620,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo // The variable name is copied into dst temporarily, because it may // be a string in read-only memory and a NUL needs to be appended. if (*src != '~') { // environment var - tail = (char_u *)src + 1; + tail = src + 1; var = dst; int c = dstlen - 1; @@ -649,7 +649,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo } #endif *var = NUL; - var = (char_u *)vim_getenv((char *)dst); + var = vim_getenv(dst); mustfree = true; #if defined(UNIX) } @@ -657,12 +657,12 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo } else if (src[1] == NUL // home directory || vim_ispathsep(src[1]) || vim_strchr(" ,\t\n", src[1]) != NULL) { - var = (char_u *)homedir; - tail = (char_u *)src + 1; + var = homedir; + tail = src + 1; } else { // user directory #if defined(UNIX) // Copy ~user to dst[], so we can put a NUL after it. - tail = (char_u *)src; + tail = src; var = dst; int c = dstlen - 1; while (c-- > 0 @@ -675,15 +675,15 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo // Get the user directory. If this fails the shell is used to expand // ~user, which is slower and may fail on old versions of /bin/sh. var = (*dst == NUL) ? NULL - : (char_u *)os_get_userdir((char *)dst + 1); + : os_get_userdir(dst + 1); mustfree = true; if (var == NULL) { expand_T xpc; ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; - var = (char_u *)ExpandOne(&xpc, (char *)dst, NULL, - WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE); + var = ExpandOne(&xpc, dst, NULL, + WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE); mustfree = true; } #else @@ -710,8 +710,8 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo // If "var" contains white space, escape it with a backslash. // Required for ":e ~/tt" when $HOME includes a space. - if (esc && var != NULL && strpbrk((char *)var, " \t") != NULL) { - char_u *p = vim_strsave_escaped(var, (char_u *)" \t"); + if (esc && var != NULL && strpbrk(var, " \t") != NULL) { + char *p = (char *)vim_strsave_escaped((char_u *)var, (char_u *)" \t"); if (mustfree) { xfree(var); @@ -721,13 +721,13 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo } if (var != NULL && *var != NUL - && (STRLEN(var) + STRLEN(tail) + 1 < (unsigned)dstlen)) { + && (strlen(var) + strlen(tail) + 1 < (unsigned)dstlen)) { STRCPY(dst, var); - dstlen -= (int)STRLEN(var); - int c = (int)STRLEN(var); + dstlen -= (int)strlen(var); + int c = (int)strlen(var); // if var[] ends in a path separator and tail[] starts // with it, skip a character - if (after_pathsep((char *)dst, (char *)dst + c) + if (after_pathsep(dst, dst + c) #if defined(BACKSLASH_IN_FILENAME) && dst[-1] != ':' #endif @@ -735,7 +735,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo tail++; } dst += c; - src = (char *)tail; + src = tail; copy_char = false; } if (mustfree) { @@ -749,17 +749,17 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo // ":edit foo ~ foo". at_start = false; if (src[0] == '\\' && src[1] != NUL) { - *dst++ = (char_u)(*src++); + *dst++ = *src++; dstlen--; } else if ((src[0] == ' ' || src[0] == ',') && !one) { at_start = true; } if (dstlen > 0) { - *dst++ = (char_u)(*src++); + *dst++ = *src++; dstlen--; if (prefix != NULL - && src - prefix_len >= (char *)srcp + && src - prefix_len >= srcp && STRNCMP(src - prefix_len, prefix, prefix_len) == 0) { at_start = true; } diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index b4bee6e550..c1359d6ece 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -120,15 +120,15 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in { int i; size_t len; - char_u *p; + char *p; bool dir; char_u *extra_shell_arg = NULL; ShellOpts shellopts = kShellOptExpand | kShellOptSilent; int j; - char_u *tempname; - char_u *command; + char *tempname; + char *command; FILE *fd; - char_u *buffer; + char *buffer; #define STYLE_ECHO 0 // use "echo", the default #define STYLE_GLOB 1 // use "glob", for csh #define STYLE_VIMGLOB 2 // use "vimglob", for Posix sh @@ -175,7 +175,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in } // get a name for the temp file - if ((tempname = (char_u *)vim_tempname()) == NULL) { + if ((tempname = vim_tempname()) == NULL) { emsg(_(e_notmp)); return FAIL; } @@ -196,7 +196,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in && (len = strlen(pat[0])) > 2 && *(pat[0] + len - 1) == '`') { shell_style = STYLE_BT; - } else if ((len = STRLEN(p_sh)) >= 3) { + } else if ((len = strlen(p_sh)) >= 3) { if (strcmp(p_sh + len - 3, "csh") == 0) { shell_style = STYLE_GLOB; } else if (strcmp(p_sh + len - 3, "zsh") == 0) { @@ -211,7 +211,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in // Compute the length of the command. We need 2 extra bytes: for the // optional '&' and for the NUL. // Worst case: "unset nonomatch; print -N >" plus two is 29 - len = STRLEN(tempname) + 29; + len = strlen(tempname) + 29; if (shell_style == STYLE_VIMGLOB) { len += strlen(sh_vimglob_func); } @@ -248,7 +248,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in STRCPY(command, "("); } STRCAT(command, pat[0] + 1); // exclude first backtick - p = command + STRLEN(command) - 1; + p = command + strlen(command) - 1; if (is_fish_shell) { *p-- = ';'; STRCAT(command, " end"); @@ -294,7 +294,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in // characters, except inside ``. bool intick = false; - p = command + STRLEN(command); + p = command + strlen(command); *p++ = ' '; for (j = 0; pat[i][j] != NUL; j++) { if (pat[i][j] == '`') { @@ -319,7 +319,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in } // Copy one character. - *p++ = (char_u)pat[i][j]; + *p++ = pat[i][j]; } *p = NUL; } @@ -347,7 +347,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in } // execute the shell command - i = call_shell(command, shellopts, extra_shell_arg); + i = call_shell((char_u *)command, shellopts, extra_shell_arg); // When running in the background, give it some time to create the temp // file, but don't wait for it to finish. @@ -358,7 +358,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in xfree(command); if (i) { // os_call_shell() failed - os_remove((char *)tempname); + os_remove(tempname); xfree(tempname); // With interactive completion, the error message is not printed. if (!(flags & EW_SILENT)) { @@ -377,7 +377,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in } // read the names from the file into memory - fd = fopen((char *)tempname, READBIN); + fd = fopen(tempname, READBIN); if (fd == NULL) { // Something went wrong, perhaps a file name with a special char. if (!(flags & EW_SILENT)) { @@ -407,9 +407,9 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in buffer = xmalloc(len + 1); // fread() doesn't terminate buffer with NUL; // appropriate termination (not always NUL) is done below. - size_t readlen = fread((char *)buffer, 1, len, fd); + size_t readlen = fread(buffer, 1, len, fd); fclose(fd); - os_remove((char *)tempname); + os_remove(tempname); if (readlen != len) { // unexpected read error semsg(_(e_notread), tempname); @@ -427,7 +427,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in while (*p != ' ' && *p != '\n') { p++; } - p = (char_u *)skipwhite((char *)p); // skip to next entry + p = skipwhite(p); // skip to next entry } // file names are separated with NL } else if (shell_style == STYLE_BT || shell_style == STYLE_VIMGLOB) { @@ -440,7 +440,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in if (*p != NUL) { p++; } - p = (char_u *)skipwhite((char *)p); // skip leading white space + p = skipwhite(p); // skip leading white space } // file names are separated with NUL } else { @@ -454,7 +454,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in if (shell_style == STYLE_PRINT && !did_find_nul) { // If there is a NUL, set did_find_nul, else set check_spaces buffer[len] = NUL; - if (len && (int)STRLEN(buffer) < (int)len) { + if (len && (int)strlen(buffer) < (int)len) { did_find_nul = true; } else { check_spaces = true; @@ -493,7 +493,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in // Isolate the individual file names. p = buffer; for (i = 0; i < *num_file; i++) { - (*file)[i] = (char *)p; + (*file)[i] = p; // Space or NL separates if (shell_style == STYLE_ECHO || shell_style == STYLE_BT || shell_style == STYLE_VIMGLOB) { @@ -505,7 +505,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in *p = NUL; } else { *p++ = NUL; - p = (char_u *)skipwhite((char *)p); // skip to next entry + p = skipwhite(p); // skip to next entry } } else { // NUL separates while (*p && p < buffer + len) { // skip entry @@ -537,9 +537,9 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in p = xmalloc(strlen((*file)[i]) + 1 + dir); STRCPY(p, (*file)[i]); if (dir) { - add_pathsep((char *)p); // add '/' to a directory name + add_pathsep(p); // add '/' to a directory name } - (*file)[j++] = (char *)p; + (*file)[j++] = p; } xfree(buffer); *num_file = j; diff --git a/src/nvim/path.c b/src/nvim/path.c index 68c4b596d7..49deb821be 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -628,26 +628,26 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in // Make room for file name. When doing encoding conversion the actual // length may be quite a bit longer, thus use the maximum possible length. - char_u *buf = xmalloc(MAXPATHL); + char *buf = xmalloc(MAXPATHL); // Find the first part in the path name that contains a wildcard. // When EW_ICASE is set every letter is considered to be a wildcard. // Copy it into "buf", including the preceding characters. - char_u *p = buf; - char_u *s = buf; - char_u *e = NULL; - const char_u *path_end = (char_u *)path; + char *p = buf; + char *s = buf; + char *e = NULL; + const char *path_end = path; while (*path_end != NUL) { // May ignore a wildcard that has a backslash before it; it will // be removed by rem_backslash() or file_pat_to_reg_pat() below. - if (path_end >= (char_u *)path + wildoff && rem_backslash((char *)path_end)) { + if (path_end >= path + wildoff && rem_backslash((char *)path_end)) { *p++ = *path_end++; } else if (vim_ispathsep_nocolon(*path_end)) { if (e != NULL) { break; } s = p + 1; - } else if (path_end >= (char_u *)path + wildoff + } else if (path_end >= path + wildoff && (vim_strchr("*?[{~$", *path_end) != NULL #ifndef MSWIN || (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char((char *)path_end))) @@ -667,7 +667,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in // Remove backslashes between "wildoff" and the start of the wildcard // component. for (p = buf + wildoff; p < s; p++) { - if (rem_backslash((char *)p)) { + if (rem_backslash(p)) { STRMOVE(p, p + 1); e--; s--; @@ -683,7 +683,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in // convert the file pattern to a regexp pattern int starts_with_dot = *s == '.'; - char *pat = file_pat_to_reg_pat((char *)s, (char *)e, NULL, false); + char *pat = file_pat_to_reg_pat(s, e, NULL, false); if (pat == NULL) { xfree(buf); return 0; @@ -717,13 +717,13 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in && *path_end == '/') { STRCPY(s, path_end + 1); stardepth++; - (void)do_path_expand(gap, (char *)buf, (size_t)(s - buf), flags, true); + (void)do_path_expand(gap, buf, (size_t)(s - buf), flags, true); stardepth--; } *s = NUL; Directory dir; - char *dirpath = (*buf == NUL ? "." : (char *)buf); + char *dirpath = (*buf == NUL ? "." : buf); if (os_file_is_readable(dirpath) && os_scandir(&dir, dirpath)) { // Find all matching entries. char *name; @@ -738,7 +738,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in || ((flags & EW_NOTWILD) && path_fnamencmp(path + (s - buf), name, (size_t)(e - s)) == 0))) { STRCPY(s, name); - len = STRLEN(buf); + len = strlen(buf); if (starstar && stardepth < 100) { // For "**" in the pattern first go deeper in the tree to @@ -746,27 +746,27 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in STRCPY(buf + len, "/**"); // NOLINT STRCPY(buf + len + 3, path_end); stardepth++; - (void)do_path_expand(gap, (char *)buf, len + 1, flags, true); + (void)do_path_expand(gap, buf, len + 1, flags, true); stardepth--; } STRCPY(buf + len, path_end); - if (path_has_exp_wildcard(path_end)) { // handle more wildcards + if (path_has_exp_wildcard((char_u *)path_end)) { // handle more wildcards // need to expand another component of the path // remove backslashes for the remaining components only - (void)do_path_expand(gap, (char *)buf, len + 1, flags, false); + (void)do_path_expand(gap, buf, len + 1, flags, false); } else { FileInfo file_info; // no more wildcards, check if there is a match // remove backslashes for the remaining components only if (*path_end != NUL) { - backslash_halve((char *)buf + len + 1); + backslash_halve(buf + len + 1); } // add existing file or symbolic link if ((flags & EW_ALLLINKS) - ? os_fileinfo_link((char *)buf, &file_info) - : os_path_exists((char *)buf)) { + ? os_fileinfo_link(buf, &file_info) + : os_path_exists(buf)) { addfile(gap, buf, flags); } } @@ -839,7 +839,7 @@ static bool is_unique(char *maybe_unique, garray_T *gap, int i) // // TODO(vim): handle upward search (;) and path limiter (**N) notations by // expanding each into their equivalent path(s). -static void expand_path_option(char_u *curdir, garray_T *gap) +static void expand_path_option(char *curdir, garray_T *gap) { char_u *path_option = *curbuf->b_p_path == NUL ? p_path : (char_u *)curbuf->b_p_path; char *buf = xmalloc(MAXPATHL); @@ -872,7 +872,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap) continue; // URL can't be used here } else if (!path_is_absolute((char_u *)buf)) { // Expand relative path to their full path equivalent - size_t len = STRLEN(curdir); + size_t len = strlen(curdir); if (len + strlen(buf) + 3 > MAXPATHL) { continue; } @@ -927,10 +927,10 @@ static char_u *get_path_cutoff(char_u *fname, garray_T *gap) return cutoff; } -// Sorts, removes duplicates and modifies all the fullpath names in "gap" so -// that they are unique with respect to each other while conserving the part -// that matches the pattern. Beware, this is at least O(n^2) wrt "gap->ga_len". -static void uniquefy_paths(garray_T *gap, char_u *pattern) +/// Sorts, removes duplicates and modifies all the fullpath names in "gap" so +/// that they are unique with respect to each other while conserving the part +/// that matches the pattern. Beware, this is at least O(n^2) wrt "gap->ga_len". +static void uniquefy_paths(garray_T *gap, char *pattern) { char **fnames = gap->ga_data; bool sort_again = false; @@ -945,7 +945,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) // We need to prepend a '*' at the beginning of file_pattern so that the // regex matches anywhere in the path. FIXME: is this valid for all // possible patterns? - size_t len = STRLEN(pattern); + size_t len = strlen(pattern); char *file_pattern = xmalloc(len + 2); file_pattern[0] = '*'; file_pattern[1] = NUL; @@ -965,7 +965,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) char *curdir = xmalloc(MAXPATHL); os_dirname((char_u *)curdir, MAXPATHL); - expand_path_option((char_u *)curdir, &path_ga); + expand_path_option(curdir, &path_ga); in_curdir = xcalloc((size_t)gap->ga_len, sizeof(char_u *)); @@ -976,7 +976,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) char *pathsep_p; char *path_cutoff; - len = STRLEN(path); + len = strlen(path); is_in_curdir = path_fnamencmp(curdir, path, (size_t)(dir_end - path)) == 0 && curdir[dir_end - path] == NUL; if (is_in_curdir) { @@ -1026,7 +1026,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern) if (short_name != NULL && short_name > path + 1) { STRCPY(path, "."); add_pathsep(path); - STRMOVE(path + STRLEN(path), short_name); + STRMOVE(path + strlen(path), short_name); } } os_breakcheck(); @@ -1121,7 +1121,7 @@ static int expand_in_path(garray_T *const gap, char_u *const pattern, const int os_dirname(curdir, MAXPATHL); ga_init(&path_ga, (int)sizeof(char_u *), 1); - expand_path_option(curdir, &path_ga); + expand_path_option((char *)curdir, &path_ga); xfree(curdir); if (GA_EMPTY(&path_ga)) { return 0; @@ -1232,7 +1232,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i // For `=expr` do use the internal function. for (int i = 0; i < num_pat; i++) { if (has_special_wildchar((char_u *)pat[i]) - && !(vim_backtick((char_u *)pat[i]) && pat[i][1] == '=')) { + && !(vim_backtick(pat[i]) && pat[i][1] == '=')) { return os_expand_wildcards(num_pat, pat, num_file, file, flags); } } @@ -1247,7 +1247,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i add_pat = -1; p = (char_u *)pat[i]; - if (vim_backtick(p)) { + if (vim_backtick((char *)p)) { add_pat = expand_backtick(&ga, (char *)p, flags); if (add_pat == -1) { recursive = false; @@ -1311,9 +1311,9 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i // When EW_NOTFOUND is used, always add files and dirs. Makes // "vim c:/" work. if (flags & EW_NOTFOUND) { - addfile(&ga, t, flags | EW_DIR | EW_FILE); + addfile(&ga, (char *)t, flags | EW_DIR | EW_FILE); } else { - addfile(&ga, t, flags); + addfile(&ga, (char *)t, flags); } if (t != p) { @@ -1322,7 +1322,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i } if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & EW_PATH)) { - uniquefy_paths(&ga, p); + uniquefy_paths(&ga, (char *)p); } if (p != (char_u *)pat[i]) { xfree(p); @@ -1349,10 +1349,10 @@ void FreeWild(int count, char **files) xfree(files); } -/// Return true if we can expand this backtick thing here. -static int vim_backtick(char_u *p) +/// @return true if we can expand this backtick thing here. +static int vim_backtick(char *p) { - return *p == '`' && *(p + 1) != NUL && *(p + STRLEN(p) - 1) == '`'; + return *p == '`' && *(p + 1) != NUL && *(p + strlen(p) - 1) == '`'; } /// Expand an item in `backticks` by executing it as a command. @@ -1391,7 +1391,7 @@ static int expand_backtick(garray_T *gap, char *pat, int flags) if (p > cmd) { char i = *p; *p = NUL; - addfile(gap, (char_u *)cmd, flags); + addfile(gap, cmd, flags); *p = i; cnt++; } @@ -1446,7 +1446,7 @@ void slash_adjust(char_u *p) /// EW_ALLLINKS add symlink also when the referred file does not exist /// /// @param f filename -void addfile(garray_T *gap, char_u *f, int flags) +void addfile(garray_T *gap, char *f, int flags) { bool isdir; FileInfo file_info; @@ -1454,8 +1454,8 @@ void addfile(garray_T *gap, char_u *f, int flags) // if the file/dir/link doesn't exist, may not add it if (!(flags & EW_NOTFOUND) && ((flags & EW_ALLLINKS) - ? !os_fileinfo_link((char *)f, &file_info) - : !os_path_exists((char *)f))) { + ? !os_fileinfo_link(f, &file_info) + : !os_path_exists(f))) { return; } @@ -1466,7 +1466,7 @@ void addfile(garray_T *gap, char_u *f, int flags) } #endif - isdir = os_isdir((char *)f); + isdir = os_isdir(f); if ((isdir && !(flags & EW_DIR)) || (!isdir && !(flags & EW_FILE))) { return; } @@ -1474,11 +1474,11 @@ void addfile(garray_T *gap, char_u *f, int flags) // If the file isn't executable, may not add it. Do accept directories. // When invoked from expand_shellcmd() do not use $PATH. if (!isdir && (flags & EW_EXEC) - && !os_can_exe((char *)f, NULL, !(flags & EW_SHELLCMD))) { + && !os_can_exe(f, NULL, !(flags & EW_SHELLCMD))) { return; } - char_u *p = xmalloc(STRLEN(f) + 1 + isdir); + char_u *p = xmalloc(strlen(f) + 1 + isdir); STRCPY(p, f); #ifdef BACKSLASH_IN_FILENAME diff --git a/src/nvim/profile.c b/src/nvim/profile.c index d54deaf983..f3a55696aa 100644 --- a/src/nvim/profile.c +++ b/src/nvim/profile.c @@ -742,7 +742,7 @@ static void script_dump_profile(FILE *fd) // Keep going till the end of file, so that trailing // continuation lines are listed. for (int i = 0;; i++) { - if (vim_fgets((char_u *)IObuff, IOSIZE, sfd)) { + if (vim_fgets(IObuff, IOSIZE, sfd)) { break; } // When a line has been truncated, append NL, taking care diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index cadbab91f4..f0a983b80f 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2784,7 +2784,7 @@ static void qf_jump_goto_line(linenr_T qf_lnum, int qf_col, char qf_viscol, char // Move the cursor to the first line in the buffer pos_T save_cursor = curwin->w_cursor; curwin->w_cursor.lnum = 0; - if (!do_search(NULL, '/', '/', (char_u *)qf_pattern, (long)1, SEARCH_KEEP, NULL)) { + if (!do_search(NULL, '/', '/', qf_pattern, (long)1, SEARCH_KEEP, NULL)) { curwin->w_cursor = save_cursor; } } @@ -6993,7 +6993,7 @@ static void hgr_search_file(qf_list_T *qfl, char *fname, regmatch_T *p_regmatch) } linenr_T lnum = 1; - while (!vim_fgets((char_u *)IObuff, IOSIZE, fd) && !got_int) { + while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) { char *line = (char *)IObuff; if (vim_regexec(p_regmatch, line, (colnr_T)0)) { diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index db8dc04907..8fafe4b6b9 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -2043,7 +2043,7 @@ int do_source(char *fname, int check_other, int is_vimrc) } else { // Read the first line so we can check for a UTF-8 BOM. firstline = (uint8_t *)getsourceline(0, (void *)&cookie, 0, true); - if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef + if (firstline != NULL && strlen((char *)firstline) >= 3 && firstline[0] == 0xef && firstline[1] == 0xbb && firstline[2] == 0xbf) { // Found BOM; setup conversion, skip over BOM and recode the line. convert_setup(&cookie.conv, "utf-8", p_enc); diff --git a/src/nvim/search.c b/src/nvim/search.c index 378306b8d7..cb31da3e87 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -156,7 +156,7 @@ int search_regcomp(char_u *pat, int pat_save, int pat_use, int options, regmmatc rc_did_emsg = true; return FAIL; } - pat = spats[i].pat; + pat = (char_u *)spats[i].pat; magic = spats[i].magic; no_smartcase = spats[i].no_scs; } else if (options & SEARCH_HIS) { // put new pattern in history @@ -205,9 +205,9 @@ char_u *get_search_pat(void) void save_re_pat(int idx, char *pat, int magic) { - if (spats[idx].pat != (char_u *)pat) { + if (spats[idx].pat != pat) { free_spat(&spats[idx]); - spats[idx].pat = (char_u *)xstrdup(pat); + spats[idx].pat = xstrdup(pat); spats[idx].magic = magic; spats[idx].no_scs = no_smartcase; spats[idx].timestamp = os_time(); @@ -230,11 +230,11 @@ void save_search_patterns(void) if (save_level++ == 0) { saved_spats[0] = spats[0]; if (spats[0].pat != NULL) { - saved_spats[0].pat = (char_u *)xstrdup((char *)spats[0].pat); + saved_spats[0].pat = xstrdup(spats[0].pat); } saved_spats[1] = spats[1]; if (spats[1].pat != NULL) { - saved_spats[1].pat = (char_u *)xstrdup((char *)spats[1].pat); + saved_spats[1].pat = xstrdup(spats[1].pat); } saved_spats_last_idx = last_idx; saved_spats_no_hlsearch = no_hlsearch; @@ -301,7 +301,7 @@ void save_last_search_pattern(void) saved_last_search_spat = spats[RE_SEARCH]; if (spats[RE_SEARCH].pat != NULL) { - saved_last_search_spat.pat = (char_u *)xstrdup((char *)spats[RE_SEARCH].pat); + saved_last_search_spat.pat = xstrdup(spats[RE_SEARCH].pat); } saved_last_idx = last_idx; saved_no_hlsearch = no_hlsearch; @@ -344,7 +344,7 @@ static void restore_incsearch_state(void) char_u *last_search_pattern(void) { - return spats[RE_SEARCH].pat; + return (char_u *)spats[RE_SEARCH].pat; } /// Return true when case should be ignored for search pattern "pat". @@ -440,7 +440,7 @@ void set_csearch_until(int t_cmd) char_u *last_search_pat(void) { - return spats[last_idx].pat; + return (char_u *)spats[last_idx].pat; } // Reset search direction to forward. For "gd" and "gD" commands. @@ -459,7 +459,7 @@ void set_last_search_pat(const char_u *s, int idx, int magic, int setlast) if (*s == NUL) { spats[idx].pat = NULL; } else { - spats[idx].pat = (char_u *)xstrdup((char *)s); + spats[idx].pat = xstrdup((char *)s); } spats[idx].timestamp = os_time(); spats[idx].additional_data = NULL; @@ -479,7 +479,7 @@ void set_last_search_pat(const char_u *s, int idx, int magic, int setlast) if (spats[idx].pat == NULL) { saved_spats[idx].pat = NULL; } else { - saved_spats[idx].pat = (char_u *)xstrdup((char *)spats[idx].pat); + saved_spats[idx].pat = xstrdup(spats[idx].pat); } saved_spats_last_idx = last_idx; } @@ -532,7 +532,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, int found; linenr_T lnum; // no init to shut up Apollo cc regmmatch_T regmatch; - char_u *ptr; + char *ptr; colnr_T matchcol; lpos_T endpos; lpos_T matchpos; @@ -576,11 +576,11 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, && pos->lnum <= buf->b_ml.ml_line_count && pos->col < MAXCOL - 2) { // Watch out for the "col" being MAXCOL - 2, used in a closed fold. - ptr = (char_u *)ml_get_buf(buf, pos->lnum, false); - if ((int)STRLEN(ptr) <= pos->col) { + ptr = ml_get_buf(buf, pos->lnum, false); + if ((int)strlen(ptr) <= pos->col) { start_char_len = 1; } else { - start_char_len = utfc_ptr2len((char *)ptr + pos->col); + start_char_len = utfc_ptr2len(ptr + pos->col); } } else { start_char_len = 1; @@ -645,9 +645,9 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, submatch = first_submatch(®match); // "lnum" may be past end of buffer for "\n\zs". if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) { - ptr = (char_u *)""; + ptr = ""; } else { - ptr = (char_u *)ml_get_buf(buf, lnum + matchpos.lnum, false); + ptr = ml_get_buf(buf, lnum + matchpos.lnum, false); } // Forward search in the first line: match should be after @@ -686,7 +686,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, } if (matchcol == matchpos.col && ptr[matchcol] != NUL) { - matchcol += utfc_ptr2len((char *)ptr + matchcol); + matchcol += utfc_ptr2len(ptr + matchcol); } if (matchcol == 0 && (options & SEARCH_START)) { @@ -716,7 +716,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, } // Need to get the line pointer again, a multi-line search may // have made it invalid. - ptr = (char_u *)ml_get_buf(buf, lnum, false); + ptr = ml_get_buf(buf, lnum, false); } if (!match_ok) { continue; @@ -769,7 +769,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, // for empty match: advance one char if (matchcol == matchpos.col && ptr[matchcol] != NUL) { - matchcol += utfc_ptr2len((char *)ptr + matchcol); + matchcol += utfc_ptr2len(ptr + matchcol); } } else { // Stop when the match is in a next line. @@ -778,7 +778,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, } matchcol = matchpos.col; if (ptr[matchcol] != NUL) { - matchcol += utfc_ptr2len((char *)ptr + matchcol); + matchcol += utfc_ptr2len(ptr + matchcol); } } if (ptr[matchcol] == NUL @@ -798,7 +798,7 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, } // Need to get the line pointer again, a // multi-line search may have made it invalid. - ptr = (char_u *)ml_get_buf(buf, lnum + matchpos.lnum, false); + ptr = ml_get_buf(buf, lnum + matchpos.lnum, false); } // If there is only a match after the cursor, skip @@ -826,8 +826,8 @@ int searchit(win_T *win, buf_T *buf, pos_T *pos, pos_T *end_pos, Direction dir, } else { pos->col--; if (pos->lnum <= buf->b_ml.ml_line_count) { - ptr = (char_u *)ml_get_buf(buf, pos->lnum, false); - pos->col -= utf_head_off((char *)ptr, (char *)ptr + pos->col); + ptr = ml_get_buf(buf, pos->lnum, false); + pos->col -= utf_head_off(ptr, ptr + pos->col); } } if (end_pos != NULL) { @@ -1000,19 +1000,19 @@ static int first_submatch(regmmatch_T *rp) /// @param sia optional arguments or NULL /// /// @return 0 for failure, 1 for found, 2 for found and line offset added. -int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, int options, +int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, long count, int options, searchit_arg_T *sia) { pos_T pos; // position of the last match - char_u *searchstr; + char *searchstr; struct soffset old_off; int retval; // Return value - char_u *p; + char *p; long c; - char_u *dircp; + char *dircp; char *strcopy = NULL; char_u *ps; - char_u *msgbuf = NULL; + char *msgbuf = NULL; size_t len; bool has_offset = false; @@ -1078,7 +1078,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, } } else { // make search_regcomp() use spats[RE_SEARCH].pat - searchstr = (char_u *)""; + searchstr = ""; } } @@ -1086,12 +1086,12 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, // Find end of regular expression. // If there is a matching '/' or '?', toss it. ps = (char_u *)strcopy; - p = (char_u *)skip_regexp_ex((char *)pat, search_delim, p_magic, &strcopy, NULL); + p = skip_regexp_ex(pat, search_delim, p_magic, &strcopy, NULL); if (strcopy != (char *)ps) { // made a copy of "pat" to change "\?" to "?" - searchcmdlen += (int)(STRLEN(pat) - strlen(strcopy)); - pat = (char_u *)strcopy; - searchstr = (char_u *)strcopy; + searchcmdlen += (int)(strlen(pat) - strlen(strcopy)); + pat = strcopy; + searchstr = strcopy; } if (*p == search_delim) { dircp = p; // remember where we put the NUL @@ -1116,7 +1116,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, if (ascii_isdigit(*p) || *p == '+' || *p == '-') { // got an offset // 'nr' or '+nr' or '-nr' if (ascii_isdigit(*p) || ascii_isdigit(*(p + 1))) { - spats[0].off.off = atol((char *)p); + spats[0].off.off = atol(p); } else if (*p == '-') { // single '-' spats[0].off.off = -1; } else { // single '+' @@ -1136,8 +1136,8 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, if ((options & SEARCH_ECHO) && messaging() && !msg_silent && (!cmd_silent || !shortmess(SHM_SEARCHCOUNT))) { - char_u *trunc; - char_u off_buf[40]; + char *trunc; + char off_buf[40]; size_t off_len = 0; // Compute msg_row early. @@ -1147,7 +1147,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, if (!cmd_silent && (spats[0].off.line || spats[0].off.end || spats[0].off.off)) { p = off_buf; // -V507 - *p++ = (char_u)dirc; + *p++ = (char)dirc; if (spats[0].off.end) { *p++ = 'e'; } else if (!spats[0].off.line) { @@ -1158,10 +1158,10 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, } *p = NUL; if (spats[0].off.off != 0 || spats[0].off.line) { - snprintf((char *)p, sizeof(off_buf) - 1 - (size_t)(p - off_buf), + snprintf(p, sizeof(off_buf) - 1 - (size_t)(p - off_buf), "%" PRId64, spats[0].off.off); } - off_len = STRLEN(off_buf); + off_len = strlen(off_buf); } if (*searchstr == NUL) { @@ -1184,12 +1184,12 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, // Use up to 'showcmd' column. len = (size_t)((Rows - msg_row - 1) * Columns + sc_col - 1); } - if (len < STRLEN(p) + off_len + SEARCH_STAT_BUF_LEN + 3) { - len = STRLEN(p) + off_len + SEARCH_STAT_BUF_LEN + 3; + if (len < strlen(p) + off_len + SEARCH_STAT_BUF_LEN + 3) { + len = strlen(p) + off_len + SEARCH_STAT_BUF_LEN + 3; } } else { // Reserve enough space for the search pattern + offset. - len = STRLEN(p) + off_len + 3; + len = strlen(p) + off_len + 3; } xfree(msgbuf); @@ -1200,19 +1200,19 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, // do not fill the msgbuf buffer, if cmd_silent is set, leave it // empty for the search_stat feature. if (!cmd_silent) { - msgbuf[0] = (char_u)dirc; - if (utf_iscomposing(utf_ptr2char((char *)p))) { + msgbuf[0] = (char)dirc; + if (utf_iscomposing(utf_ptr2char(p))) { // Use a space to draw the composing char on. msgbuf[1] = ' '; - memmove(msgbuf + 2, p, STRLEN(p)); + memmove(msgbuf + 2, p, strlen(p)); } else { - memmove(msgbuf + 1, p, STRLEN(p)); + memmove(msgbuf + 1, p, strlen(p)); } if (off_len > 0) { - memmove(msgbuf + STRLEN(p) + 1, off_buf, off_len); + memmove(msgbuf + strlen(p) + 1, off_buf, off_len); } - trunc = (char_u *)msg_strtrunc((char *)msgbuf, true); + trunc = msg_strtrunc(msgbuf, true); if (trunc != NULL) { xfree(msgbuf); msgbuf = trunc; @@ -1223,14 +1223,14 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, // it would be blanked out again very soon. Show it on the // left, but do reverse the text. if (curwin->w_p_rl && *curwin->w_p_rlc == 's') { - char_u *r = (char_u *)reverse_text(trunc != NULL ? (char *)trunc : (char *)msgbuf); + char *r = reverse_text(trunc != NULL ? trunc : msgbuf); xfree(msgbuf); msgbuf = r; // move reversed text to beginning of buffer while (*r == ' ') { r++; } - size_t pat_len = (size_t)(msgbuf + STRLEN(msgbuf) - r); + size_t pat_len = (size_t)(msgbuf + strlen(msgbuf) - r); memmove(msgbuf, r, pat_len); // overwrite old text if ((size_t)(r - msgbuf) >= pat_len) { @@ -1239,7 +1239,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, memset(msgbuf + pat_len, ' ', (size_t)(r - msgbuf)); } } - msg_outtrans((char *)msgbuf); + msg_outtrans(msgbuf); msg_clr_eos(); msg_check(); @@ -1279,7 +1279,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, } c = searchit(curwin, curbuf, &pos, NULL, dirc == '/' ? FORWARD : BACKWARD, - searchstr, count, + (char_u *)searchstr, count, (spats[0].off.end * SEARCH_END + (options & (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS + SEARCH_MSG @@ -1288,7 +1288,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, RE_LAST, sia); if (dircp != NULL) { - *dircp = (char_u)search_delim; // restore second '/' or '?' for normal_cmd() + *dircp = (char)search_delim; // restore second '/' or '?' for normal_cmd() } if (!shortmess(SHM_SEARCH) @@ -1375,7 +1375,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count, break; } - dirc = *++pat; + dirc = (uint8_t)(*++pat); search_delim = dirc; if (dirc != '?' && dirc != '/') { retval = 0; @@ -1480,7 +1480,7 @@ int searchc(cmdarg_T *cap, int t_cmd) int dir = cap->arg; // true for searching forward long count = cap->count1; // repeat count int col; - char_u *p; + char *p; int len; bool stop = true; @@ -1526,14 +1526,14 @@ int searchc(cmdarg_T *cap, int t_cmd) cap->oap->inclusive = true; } - p = (char_u *)get_cursor_line_ptr(); + p = get_cursor_line_ptr(); col = curwin->w_cursor.col; - len = (int)STRLEN(p); + len = (int)strlen(p); while (count--) { for (;;) { if (dir > 0) { - col += utfc_ptr2len((char *)p + col); + col += utfc_ptr2len(p + col); if (col >= len) { return FAIL; } @@ -1541,7 +1541,7 @@ int searchc(cmdarg_T *cap, int t_cmd) if (col == 0) { return FAIL; } - col -= utf_head_off((char *)p, (char *)p + col - 1) + 1; + col -= utf_head_off(p, p + col - 1) + 1; } if (lastc_bytelen == 1) { if (p[col] == c && stop) { @@ -1562,7 +1562,7 @@ int searchc(cmdarg_T *cap, int t_cmd) col += lastc_bytelen - 1; } else { // To previous char, which may be multi-byte. - col -= utf_head_off((char *)p, (char *)p + col); + col -= utf_head_off(p, p + col); } } curwin->w_cursor.col = col; @@ -1699,7 +1699,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) bool backwards = false; // init for gcc bool raw_string = false; // search for raw string bool inquote = false; // true when inside quotes - char_u *ptr; + char *ptr; int hash_dir = 0; // Direction searched for # things int comment_dir = 0; // Direction searched for comments int traveled = 0; // how far we've searched so far @@ -1712,7 +1712,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) pos = curwin->w_cursor; pos.coladd = 0; - char_u *linep = (char_u *)ml_get(pos.lnum); // pointer to current line + char *linep = ml_get(pos.lnum); // pointer to current line // vi compatible matching bool cpo_match = (vim_strchr(p_cpo, CPO_MATCH) != NULL); @@ -1759,9 +1759,9 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) // Only check for special things when 'cpo' doesn't have '%'. if (!cpo_match) { // Are we before or at #if, #else etc.? - ptr = (char_u *)skipwhite((char *)linep); + ptr = skipwhite(linep); if (*ptr == '#' && pos.col <= (colnr_T)(ptr - linep)) { - ptr = (char_u *)skipwhite((char *)ptr + 1); + ptr = skipwhite(ptr + 1); if (STRNCMP(ptr, "if", 2) == 0 || STRNCMP(ptr, "endif", 5) == 0 || STRNCMP(ptr, "el", 2) == 0) { @@ -1798,7 +1798,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) pos.col--; } for (;;) { - initc = utf_ptr2char((char *)linep + pos.col); + initc = utf_ptr2char(linep + pos.col); if (initc == NUL) { break; } @@ -1807,11 +1807,11 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) if (findc) { break; } - pos.col += utfc_ptr2len((char *)linep + pos.col); + pos.col += utfc_ptr2len(linep + pos.col); } if (!findc) { // no brace in the line, maybe use " #if" then - if (!cpo_match && *skipwhite((char *)linep) == '#') { + if (!cpo_match && *skipwhite(linep) == '#') { hash_dir = 1; } else { return NULL; @@ -1821,7 +1821,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) // Set "match_escaped" if there are an odd number of // backslashes. - for (col = pos.col; check_prevcol(linep, col, '\\', &col);) { + for (col = pos.col; check_prevcol((char_u *)linep, col, '\\', &col);) { bslcnt++; } match_escaped = (bslcnt & 1); @@ -1834,7 +1834,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) oap->motion_type = kMTLineWise; // Linewise for this case only } if (initc != '#') { - ptr = (char_u *)skipwhite(skipwhite((char *)linep) + 1); + ptr = skipwhite(skipwhite(linep) + 1); if (STRNCMP(ptr, "if", 2) == 0 || STRNCMP(ptr, "el", 2) == 0) { hash_dir = 1; } else if (STRNCMP(ptr, "endif", 5) == 0) { @@ -1853,14 +1853,14 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) break; } pos.lnum += hash_dir; - linep = (char_u *)ml_get(pos.lnum); + linep = ml_get(pos.lnum); line_breakcheck(); // check for CTRL-C typed - ptr = (char_u *)skipwhite((char *)linep); + ptr = skipwhite(linep); if (*ptr != '#') { continue; } pos.col = (colnr_T)(ptr - linep); - ptr = (char_u *)skipwhite((char *)ptr + 1); + ptr = skipwhite(ptr + 1); if (hash_dir > 0) { if (STRNCMP(ptr, "if", 2) == 0) { count++; @@ -1907,7 +1907,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) // backward search: Check if this line contains a single-line comment if ((backwards && comment_dir) || lisp) { - comment_col = check_linecomment((char *)linep); + comment_col = check_linecomment(linep); } if (lisp && comment_col != MAXCOL && pos.col > (colnr_T)comment_col) { lispcomm = true; // find match inside this comment @@ -1931,14 +1931,14 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) break; } - linep = (char_u *)ml_get(pos.lnum); - pos.col = (colnr_T)STRLEN(linep); // pos.col on trailing NUL + linep = ml_get(pos.lnum); + pos.col = (colnr_T)strlen(linep); // pos.col on trailing NUL do_quotes = -1; line_breakcheck(); // Check if this line contains a single-line comment if (comment_dir || lisp) { - comment_col = check_linecomment((char *)linep); + comment_col = check_linecomment(linep); } // skip comment if (lisp && comment_col != MAXCOL) { @@ -1946,7 +1946,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) } } else { pos.col--; - pos.col -= utf_head_off((char *)linep, (char *)linep + pos.col); + pos.col -= utf_head_off(linep, linep + pos.col); } } else { // forward search if (linep[pos.col] == NUL @@ -1966,15 +1966,15 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) break; } - linep = (char_u *)ml_get(pos.lnum); + linep = ml_get(pos.lnum); pos.col = 0; do_quotes = -1; line_breakcheck(); if (lisp) { // find comment pos in new line - comment_col = check_linecomment((char *)linep); + comment_col = check_linecomment(linep); } } else { - pos.col += utfc_ptr2len((char *)linep + pos.col); + pos.col += utfc_ptr2len(linep + pos.col); } } @@ -2003,18 +2003,18 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) } else if (raw_string) { if (linep[pos.col - 1] == 'R' && linep[pos.col] == '"' - && vim_strchr((char *)linep + pos.col + 1, '(') != NULL) { + && vim_strchr(linep + pos.col + 1, '(') != NULL) { // Possible start of raw string. Now that we have the // delimiter we can check if it ends before where we // started searching, or before the previously found // raw string start. - if (!find_rawstring_end((char *)linep, &pos, + if (!find_rawstring_end(linep, &pos, count > 0 ? &match_pos : &curwin->w_cursor)) { count++; match_pos = pos; match_pos.col--; } - linep = (char_u *)ml_get(pos.lnum); // may have been released + linep = ml_get(pos.lnum); // may have been released } } else if (linep[pos.col - 1] == '/' && linep[pos.col] == '*' @@ -2078,8 +2078,8 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) } } if (pos.lnum > 1) { - ptr = (char_u *)ml_get(pos.lnum - 1); - if (*ptr && *(ptr + STRLEN(ptr) - 1) == '\\') { + ptr = ml_get(pos.lnum - 1); + if (*ptr && *(ptr + strlen(ptr) - 1) == '\\') { do_quotes = 1; if (start_in_quotes == kNone) { inquote = at_start; @@ -2092,7 +2092,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) } // ml_get() only keeps one line, need to get linep again - linep = (char_u *)ml_get(pos.lnum); + linep = ml_get(pos.lnum); } } } @@ -2109,7 +2109,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) // we do not know which part to ignore. Therefore we only set // inquote if the number of quotes in a line is even, unless this // line or the previous one ends in a '\'. Complicated, isn't it? - const int c = utf_ptr2char((char *)linep + pos.col); + const int c = utf_ptr2char(linep + pos.col); switch (c) { case NUL: // at end of line without trailing backslash, reset inquote @@ -2174,8 +2174,8 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) if (curbuf->b_p_lisp && vim_strchr("(){}[]", c) != NULL && pos.col > 1 - && check_prevcol(linep, pos.col, '\\', NULL) - && check_prevcol(linep, pos.col - 1, '#', NULL)) { + && check_prevcol((char_u *)linep, pos.col, '\\', NULL) + && check_prevcol((char_u *)linep, pos.col - 1, '#', NULL)) { break; } @@ -2186,7 +2186,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) int col, bslcnt = 0; if (!cpo_bsl) { - for (col = pos.col; check_prevcol(linep, col, '\\', &col);) { + for (col = pos.col; check_prevcol((char_u *)linep, col, '\\', &col);) { bslcnt++; } } @@ -2389,7 +2389,7 @@ int current_search(long count, bool forward) } // Is the pattern is zero-width?, this time, don't care about the direction - int zero_width = is_zero_width(spats[last_idx].pat, true, &curwin->w_cursor, + int zero_width = is_zero_width((char_u *)spats[last_idx].pat, true, &curwin->w_cursor, FORWARD); if (zero_width == -1) { return FAIL; // pattern not found @@ -2423,7 +2423,7 @@ int current_search(long count, bool forward) result = searchit(curwin, curbuf, &pos, &end_pos, (dir ? FORWARD : BACKWARD), - spats[last_idx].pat, i ? count : 1, + (char_u *)spats[last_idx].pat, i ? count : 1, SEARCH_KEEP | flags, RE_SEARCH, NULL); p_ws = old_p_ws; @@ -2507,7 +2507,7 @@ static int is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direct int flag = 0; if (pattern == NULL) { - pattern = spats[last_idx].pat; + pattern = (char_u *)spats[last_idx].pat; } if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH, @@ -2562,10 +2562,10 @@ int linewhite(linenr_T lnum) return *p == NUL; } -// Add the search count "[3/19]" to "msgbuf". -// See update_search_stat() for other arguments. +/// Add the search count "[3/19]" to "msgbuf". +/// See update_search_stat() for other arguments. static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, bool show_top_bot_msg, - char_u *msgbuf, bool recompute, int maxcount, long timeout) + char *msgbuf, bool recompute, int maxcount, long timeout) { searchstat_T stat; @@ -2610,7 +2610,7 @@ static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, bool sh len += 2; } - memmove(msgbuf + STRLEN(msgbuf) - len, t, len); + memmove(msgbuf + strlen(msgbuf) - len, t, len); if (dirc == '?' && stat.cur == maxcount + 1) { stat.cur = -1; } @@ -2618,7 +2618,7 @@ static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, bool sh // keep the message even after redraw, but don't put in history msg_hist_off = true; msg_ext_set_kind("search_count"); - give_warning((char *)msgbuf, false); + give_warning(msgbuf, false); msg_hist_off = false; } } @@ -2642,7 +2642,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst static int incomplete = 0; static int last_maxcount = SEARCH_STAT_DEF_MAX_COUNT; static int chgtick = 0; - static char_u *lastpat = NULL; + static char *lastpat = NULL; static buf_T *lbuf = NULL; proftime_T start; @@ -2666,8 +2666,8 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst // XXX: above comment should be "no MB_STRCMP function" ? if (!(chgtick == buf_get_changedtick(curbuf) && lastpat != NULL // suppress clang/NULL passed as nonnull parameter - && STRNICMP(lastpat, spats[last_idx].pat, STRLEN(lastpat)) == 0 - && STRLEN(lastpat) == STRLEN(spats[last_idx].pat) + && STRNICMP(lastpat, spats[last_idx].pat, strlen(lastpat)) == 0 + && strlen(lastpat) == strlen(spats[last_idx].pat) && equalpos(lastpos, *cursor_pos) && lbuf == curbuf) || wraparound || cur < 0 || (maxcount > 0 && cur > maxcount) @@ -2717,7 +2717,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst } if (done_search) { xfree(lastpat); - lastpat = (char_u *)xstrdup((char *)spats[last_idx].pat); + lastpat = xstrdup(spats[last_idx].pat); chgtick = (int)buf_get_changedtick(curbuf); lbuf = curbuf; lastpos = p; @@ -2827,7 +2827,7 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) goto the_end; } xfree(spats[last_idx].pat); - spats[last_idx].pat = (char_u *)xstrdup((char *)pattern); + spats[last_idx].pat = xstrdup((char *)pattern); } if (spats[last_idx].pat == NULL || *spats[last_idx].pat == NUL) { goto the_end; // the previous pattern was never defined @@ -3433,9 +3433,9 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo int old_files; int already_searched; char_u *file_line; - char_u *line; - char_u *p; - char_u save_char; + char *line; + char *p; + char save_char; bool define_matched; regmatch_T regmatch; regmatch_T incl_regmatch; @@ -3444,8 +3444,8 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo bool did_show = false; bool found = false; int i; - char_u *already = NULL; - char_u *startp = NULL; + char *already = NULL; + char *startp = NULL; win_T *curwin_save = NULL; const int l_g_do_tagpreview = g_do_tagpreview; @@ -3499,11 +3499,11 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo if (lnum > end_lnum) { // do at least one line lnum = end_lnum; } - line = get_line_and_copy(lnum, file_line); + line = (char *)get_line_and_copy(lnum, file_line); for (;;) { if (incl_regmatch.regprog != NULL - && vim_regexec(&incl_regmatch, (char *)line, (colnr_T)0)) { + && vim_regexec(&incl_regmatch, line, (colnr_T)0)) { char_u *p_fname = (curr_fname == (char_u *)curbuf->b_fname) ? (char_u *)curbuf->b_ffname : curr_fname; @@ -3584,20 +3584,20 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo if (inc_opt != NULL && strstr(inc_opt, "\\zs") != NULL) { // pattern contains \zs, use the match - p = (char_u *)incl_regmatch.startp[0]; + p = incl_regmatch.startp[0]; i = (int)(incl_regmatch.endp[0] - incl_regmatch.startp[0]); } else { // find the file name after the end of the match - for (p = (char_u *)incl_regmatch.endp[0]; - *p && !vim_isfilec(*p); p++) {} - for (i = 0; vim_isfilec(p[i]); i++) {} + for (p = incl_regmatch.endp[0]; + *p && !vim_isfilec((uint8_t)(*p)); p++) {} + for (i = 0; vim_isfilec((uint8_t)p[i]); i++) {} } if (i == 0) { // Nothing found, use the rest of the line. - p = (char_u *)incl_regmatch.endp[0]; - i = (int)STRLEN(p); + p = incl_regmatch.endp[0]; + i = (int)strlen(p); } else if (p > line) { // Avoid checking before the start of the line, can // happen if \zs appears in the regexp. @@ -3611,7 +3611,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo } save_char = p[i]; p[i] = NUL; - msg_outtrans_attr((char *)p, HL_ATTR(HLF_D)); + msg_outtrans_attr(p, HL_ATTR(HLF_D)); p[i] = save_char; } @@ -3678,12 +3678,12 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo search_line: define_matched = false; if (def_regmatch.regprog != NULL - && vim_regexec(&def_regmatch, (char *)line, (colnr_T)0)) { + && vim_regexec(&def_regmatch, line, (colnr_T)0)) { // Pattern must be first identifier after 'define', so skip // to that position before checking for match of pattern. Also // don't let it match beyond the end of this identifier. - p = (char_u *)def_regmatch.endp[0]; - while (*p && !vim_iswordc(*p)) { + p = def_regmatch.endp[0]; + while (*p && !vim_iswordc((uint8_t)(*p))) { p++; } define_matched = true; @@ -3694,27 +3694,27 @@ search_line: if (def_regmatch.regprog == NULL || define_matched) { if (define_matched || compl_status_sol()) { // compare the first "len" chars from "ptr" - startp = (char_u *)skipwhite((char *)p); + startp = skipwhite(p); if (p_ic) { - matched = !mb_strnicmp((char *)startp, (char *)ptr, len); + matched = !mb_strnicmp(startp, (char *)ptr, len); } else { matched = !STRNCMP(startp, ptr, len); } if (matched && define_matched && whole - && vim_iswordc(startp[len])) { + && vim_iswordc((uint8_t)startp[len])) { matched = false; } } else if (regmatch.regprog != NULL - && vim_regexec(®match, (char *)line, (colnr_T)(p - line))) { + && vim_regexec(®match, line, (colnr_T)(p - line))) { matched = true; - startp = (char_u *)regmatch.startp[0]; + startp = regmatch.startp[0]; // Check if the line is not a comment line (unless we are // looking for a define). A line starting with "# define" // is not considered to be a comment line. if (skip_comments) { if ((*line != '#' || STRNCMP(skipwhite((char *)line + 1), "define", 6) != 0) - && get_leader_len((char *)line, NULL, false, true)) { + && get_leader_len(line, NULL, false, true)) { matched = false; } @@ -3722,7 +3722,7 @@ search_line: // Skips lines like "int backwards; / * normal index // * /" when looking for "normal". // Note: Doesn't skip "/ *" in comments. - p = (char_u *)skipwhite((char *)line); + p = skipwhite(line); if (matched || (p[0] == '/' && p[1] == '*') || p[0] == '*') { for (p = line; *p && p < startp; p++) { @@ -3754,15 +3754,15 @@ search_line: break; } found = true; - char_u *aux = p = startp; + char *aux = p = startp; if (compl_status_adding()) { p += ins_compl_len(); - if (vim_iswordp(p)) { + if (vim_iswordp((char_u *)p)) { goto exit_matched; } - p = find_word_start(p); + p = (char *)find_word_start((char_u *)p); } - p = find_word_end(p); + p = (char *)find_word_end((char_u *)p); i = (int)(p - aux); if (compl_status_adding() && i == ins_compl_len()) { @@ -3776,8 +3776,8 @@ search_line: if (lnum >= end_lnum) { goto exit_matched; } - line = get_line_and_copy(++lnum, file_line); - } else if (vim_fgets(line = file_line, + line = (char *)get_line_and_copy(++lnum, file_line); + } else if (vim_fgets(line = (char *)file_line, LSIZE, files[depth].fp)) { goto exit_matched; } @@ -3785,9 +3785,9 @@ search_line: // we read a line, set "already" to check this "line" later // if depth >= 0 we'll increase files[depth].lnum far // below -- Acevedo - already = aux = p = (char_u *)skipwhite((char *)line); - p = find_word_start(p); - p = find_word_end(p); + already = aux = p = skipwhite(line); + p = (char *)find_word_start((char_u *)p); + p = (char *)find_word_end((char_u *)p); if (p > aux) { if (*aux != ')' && IObuff[i - 1] != TAB) { if (IObuff[i - 1] != ' ') { @@ -3810,14 +3810,14 @@ search_line: cont_s_ipos = true; } IObuff[i] = NUL; - aux = (char_u *)IObuff; + aux = IObuff; if (i == ins_compl_len()) { goto exit_matched; } } - const int add_r = ins_compl_add_infercase(aux, i, p_ic, + const int add_r = ins_compl_add_infercase((char_u *)aux, i, p_ic, curr_fname == (char_u *)curbuf->b_fname ? NULL : curr_fname, dir, cont_s_ipos); @@ -3924,7 +3924,7 @@ exit_matched: && action == ACTION_EXPAND && !compl_status_sol() && *startp != NUL - && *(p = startp + utfc_ptr2len((char *)startp)) != NUL) { + && *(p = startp + utfc_ptr2len(startp)) != NUL) { goto search_line; } } @@ -3940,7 +3940,7 @@ exit_matched: // end-of-file, close the file and continue in the file that included // it. while (depth >= 0 && !already - && vim_fgets(line = file_line, LSIZE, files[depth].fp)) { + && vim_fgets(line = (char *)file_line, LSIZE, files[depth].fp)) { fclose(files[depth].fp); old_files--; files[old_files].name = files[depth].name; @@ -3955,7 +3955,7 @@ exit_matched: if (depth >= 0) { // we could read the line files[depth].lnum++; // Remove any CR and LF from the line. - i = (int)STRLEN(line); + i = (int)strlen(line); if (i > 0 && line[i - 1] == '\n') { line[--i] = NUL; } @@ -3966,7 +3966,7 @@ exit_matched: if (++lnum > end_lnum) { break; } - line = get_line_and_copy(lnum, file_line); + line = (char *)get_line_and_copy(lnum, file_line); } already = NULL; } @@ -4011,11 +4011,11 @@ fpip_end: vim_regfree(def_regmatch.regprog); } -static void show_pat_in_path(char_u *line, int type, bool did_show, int action, FILE *fp, +static void show_pat_in_path(char *line, int type, bool did_show, int action, FILE *fp, linenr_T *lnum, long count) FUNC_ATTR_NONNULL_ARG(1, 6) { - char_u *p; + char *p; if (did_show) { msg_putchar('\n'); // cursor below last one @@ -4026,7 +4026,7 @@ static void show_pat_in_path(char_u *line, int type, bool did_show, int action, return; } for (;;) { - p = line + STRLEN(line) - 1; + p = line + strlen(line) - 1; if (fp != NULL) { // We used fgets(), so get rid of newline at end if (p >= line && *p == '\n') { @@ -4045,7 +4045,7 @@ static void show_pat_in_path(char_u *line, int type, bool did_show, int action, msg_puts_attr((const char *)IObuff, HL_ATTR(HLF_N)); msg_puts(" "); } - msg_prt_line((char *)line, false); + msg_prt_line(line, false); // Definition continues until line that doesn't end with '\' if (got_int || type != FIND_DEFINE || p < line || *p != '\\') { @@ -4061,7 +4061,7 @@ static void show_pat_in_path(char_u *line, int type, bool did_show, int action, if (++*lnum > curbuf->b_ml.ml_line_count) { break; } - line = (char_u *)ml_get(*lnum); + line = ml_get(*lnum); } msg_putchar('\n'); } diff --git a/src/nvim/search.h b/src/nvim/search.h index cd8431c916..092098d5fd 100644 --- a/src/nvim/search.h +++ b/src/nvim/search.h @@ -73,7 +73,7 @@ typedef struct soffset { /// Structure containing last search pattern and its attributes. typedef struct spat { - char_u *pat; ///< The pattern (in allocated memory) or NULL. + char *pat; ///< The pattern (in allocated memory) or NULL. bool magic; ///< Magicness of the pattern. bool no_scs; ///< No smartcase for this pattern. Timestamp timestamp; ///< Time of the last change. diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 42f5e3456d..0f81217b4a 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1217,7 +1217,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags) .end = cur_entry.data.search_pattern.place_cursor_at_end, .off = cur_entry.data.search_pattern.offset, }, - .pat = (char_u *)cur_entry.data.search_pattern.pat, + .pat = cur_entry.data.search_pattern.pat, .additional_data = cur_entry.data.search_pattern.additional_data, .timestamp = cur_entry.timestamp, }; @@ -2379,7 +2379,7 @@ static inline void add_search_pattern(PossiblyFreedShadaEntry *const ret_pse, .is_substitute_pattern = is_substitute_pattern, .highlighted = ((is_substitute_pattern ^ search_last_used) && search_highlighted), - .pat = (char *)pat.pat, + .pat = pat.pat, .additional_data = pat.additional_data, .search_backward = (!is_substitute_pattern && pat.off.dir == '?'), } diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 8ee28fea34..e6d2eac7c3 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2590,7 +2590,7 @@ void ex_spellrepall(exarg_T *eap) sub_nlines = 0; curwin->w_cursor.lnum = 0; while (!got_int) { - if (do_search(NULL, '/', '/', frompat, 1L, SEARCH_KEEP, NULL) == 0 + if (do_search(NULL, '/', '/', (char *)frompat, 1L, SEARCH_KEEP, NULL) == 0 || u_save_cursor() == FAIL) { break; } diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 395051453a..1b338ef4bf 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -2086,7 +2086,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname) hash_init(&aff->af_comp); // Read all the lines in the file one by one. - while (!vim_fgets(rline, MAXLINELEN, fd) && !got_int) { + while (!vim_fgets((char *)rline, MAXLINELEN, fd) && !got_int) { line_breakcheck(); lnum++; @@ -3146,14 +3146,14 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile) spin->si_msg_count = 999999; // Read and ignore the first line: word count. - if (vim_fgets(line, MAXLINELEN, fd) || !ascii_isdigit(*skipwhite((char *)line))) { + if (vim_fgets((char *)line, MAXLINELEN, fd) || !ascii_isdigit(*skipwhite((char *)line))) { semsg(_("E760: No word count in %s"), fname); } // Read all the lines in the file one by one. // The words are converted to 'encoding' here, before being added to // the hashtable. - while (!vim_fgets(line, MAXLINELEN, fd) && !got_int) { + while (!vim_fgets((char *)line, MAXLINELEN, fd) && !got_int) { line_breakcheck(); lnum++; if (line[0] == '#' || line[0] == '/') { @@ -3696,7 +3696,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname) spell_message(spin, (char *)IObuff); // Read all the lines in the file one by one. - while (!vim_fgets(rline, MAXLINELEN, fd) && !got_int) { + while (!vim_fgets((char *)rline, MAXLINELEN, fd) && !got_int) { line_breakcheck(); lnum++; @@ -5598,7 +5598,7 @@ void spell_add_word(char_u *word, int len, SpellAddType what, int idx, bool undo // since its flags sort before the one with WF_BANNED. fd = os_fopen(fname, "r"); if (fd != NULL) { - while (!vim_fgets(line, MAXWLEN * 2, fd)) { + while (!vim_fgets((char *)line, MAXWLEN * 2, fd)) { fpos = fpos_next; fpos_next = ftell(fd); if (fpos_next < 0) { diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index 355233fc5b..cc5c61b855 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -641,7 +641,7 @@ void spell_suggest(int count) } // Replace the word. - p = xmalloc(STRLEN(line) - (size_t)stp->st_orglen + (size_t)stp->st_wordlen + 1); + p = xmalloc(strlen(line) - (size_t)stp->st_orglen + (size_t)stp->st_wordlen + 1); c = (int)(sug.su_badptr - (char_u *)line); memmove(p, line, (size_t)c); STRCPY(p + c, stp->st_word); @@ -880,7 +880,7 @@ static void spell_suggest_file(suginfo_T *su, char_u *fname) } // Read it line by line. - while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int) { + while (!vim_fgets((char *)line, MAXWLEN * 2, fd) && !got_int) { line_breakcheck(); p = (char_u *)vim_strchr((char *)line, '/'); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 45fe59012e..8be343b055 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1507,7 +1507,7 @@ static bool findtags_in_help_init(findtags_state_T *st) } else { st->help_pri = 1; char *s; - for (s = (char *)p_hlg; *s != NUL; s++) { + for (s = p_hlg; *s != NUL; s++) { if (STRNICMP(s, st->help_lang, 2) == 0) { break; } @@ -1584,7 +1584,7 @@ static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch // Adjust the search file offset to the correct position sinfo_p->curr_offset_used = sinfo_p->curr_offset; vim_ignored = vim_fseek(st->fp, sinfo_p->curr_offset, SEEK_SET); - eof = vim_fgets((char_u *)st->lbuf, st->lbuf_size, st->fp); + eof = vim_fgets(st->lbuf, st->lbuf_size, st->fp); if (!eof && sinfo_p->curr_offset != 0) { sinfo_p->curr_offset = vim_ftell(st->fp); if (sinfo_p->curr_offset == sinfo_p->high_offset) { @@ -1592,12 +1592,12 @@ static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch vim_ignored = vim_fseek(st->fp, sinfo_p->low_offset, SEEK_SET); sinfo_p->curr_offset = sinfo_p->low_offset; } - eof = vim_fgets((char_u *)st->lbuf, st->lbuf_size, st->fp); + eof = vim_fgets(st->lbuf, st->lbuf_size, st->fp); } // skip empty and blank lines while (!eof && vim_isblankline(st->lbuf)) { sinfo_p->curr_offset = vim_ftell(st->fp); - eof = vim_fgets((char_u *)st->lbuf, st->lbuf_size, st->fp); + eof = vim_fgets(st->lbuf, st->lbuf_size, st->fp); } if (eof) { // Hit end of file. Skip backwards. @@ -1611,7 +1611,7 @@ static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch // skip empty and blank lines do { - eof = vim_fgets((char_u *)st->lbuf, st->lbuf_size, st->fp); + eof = vim_fgets(st->lbuf, st->lbuf_size, st->fp); } while (!eof && vim_isblankline(st->lbuf)); if (eof) { @@ -2997,7 +2997,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) // start search before first line curwin->w_cursor.lnum = 0; } - if (do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1, + if (do_search(NULL, pbuf[0], pbuf[0], (char *)pbuf + 1, (long)1, search_options, NULL)) { retval = OK; } else { @@ -3006,7 +3006,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) // try again, ignore case now p_ic = true; - if (!do_search(NULL, pbuf[0], pbuf[0], pbuf + 1, (long)1, + if (!do_search(NULL, pbuf[0], pbuf[0], (char *)pbuf + 1, (long)1, search_options, NULL)) { // Failed to find pattern, take a guess: "^func (" found = 2; @@ -3014,11 +3014,11 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help) cc = *tagp.tagname_end; *tagp.tagname_end = NUL; snprintf((char *)pbuf, LSIZE, "^%s\\s\\*(", tagp.tagname); - if (!do_search(NULL, '/', '/', pbuf, (long)1, search_options, NULL)) { + if (!do_search(NULL, '/', '/', (char *)pbuf, (long)1, search_options, NULL)) { // Guess again: "^char * \<func (" snprintf((char *)pbuf, LSIZE, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(", tagp.tagname); - if (!do_search(NULL, '/', '/', pbuf, (long)1, + if (!do_search(NULL, '/', '/', (char *)pbuf, (long)1, search_options, NULL)) { found = 0; } |