diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-07-02 17:13:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-02 17:13:25 +0200 |
commit | c1b591dc8f99577c419192c7b34e3999758ed69f (patch) | |
tree | b8d61ff93b47fdec47982f0452d76975226322ae /src/nvim/eval | |
parent | ed429c00d76414d07d7c7129f65ddf9be68e24f4 (diff) | |
parent | 3b8804571c565a91c9ce729bb487c7ba21b659e0 (diff) | |
download | rneovim-c1b591dc8f99577c419192c7b34e3999758ed69f.tar.gz rneovim-c1b591dc8f99577c419192c7b34e3999758ed69f.tar.bz2 rneovim-c1b591dc8f99577c419192c7b34e3999758ed69f.zip |
Merge pull request #19137 from dundargoc/refactor/char_u-to-char
refactor: replace char_u
Diffstat (limited to 'src/nvim/eval')
-rw-r--r-- | src/nvim/eval/funcs.c | 37 | ||||
-rw-r--r-- | src/nvim/eval/typval.c | 4 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 14 |
3 files changed, 25 insertions, 30 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 96c6a4704c..8d267f6a9e 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -476,7 +476,7 @@ static buf_T *find_buffer(typval_T *avar) if (avar->v_type == VAR_NUMBER) { buf = buflist_findnr((int)avar->vval.v_number); } else if (avar->v_type == VAR_STRING && avar->vval.v_string != NULL) { - buf = buflist_findname_exp((char_u *)avar->vval.v_string); + buf = buflist_findname_exp(avar->vval.v_string); if (buf == NULL) { /* No full path name match, try a match with a URL or a "nofile" * buffer, these don't use the full path. */ @@ -498,7 +498,7 @@ static void f_bufadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) { char_u *name = (char_u *)tv_get_string(&argvars[0]); - rettv->vval.v_number = buflist_add(*name == NUL ? NULL : name, 0); + rettv->vval.v_number = buflist_add(*name == NUL ? NULL : (char *)name, 0); } /// "bufexists(expr)" function @@ -586,7 +586,7 @@ static void f_bufnr(typval_T *argvars, typval_T *rettv, FunPtr fptr) && tv_get_number_chk(&argvars[1], &error) != 0 && !error && (name = tv_get_string_chk(&argvars[0])) != NULL) { - buf = buflist_new((char_u *)name, NULL, 1, 0); + buf = buflist_new((char *)name, NULL, 1, 0); } if (buf != NULL) { @@ -655,7 +655,7 @@ buf_T *tv_get_buf(typval_T *tv, int curtab_only) save_cpo = p_cpo; p_cpo = ""; - buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name), + buf = buflist_findnr(buflist_findpat((char *)name, (char *)name + STRLEN(name), true, false, curtab_only)); p_magic = save_magic; @@ -2396,7 +2396,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) fresult = find_file_in_path_option(first ? (char_u *)fname : NULL, first ? strlen(fname) : 0, 0, first, path, - find_what, curbuf->b_ffname, + find_what, (char_u *)curbuf->b_ffname, (find_what == FINDFILE_DIR ? (char_u *)"" : curbuf->b_p_sua)); @@ -2574,7 +2574,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } } - unsigned long count = (unsigned long)(foldend - foldstart + 1); + unsigned long count = (unsigned long)foldend - foldstart + 1; txt = NGETTEXT("+-%s%3ld line: ", "+-%s%3ld lines: ", count); r = xmalloc(STRLEN(txt) + STRLEN(dashes) // for %s @@ -3308,8 +3308,8 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr) [kCdScopeTabpage] = 0, // Number of tab to look at. }; - char_u *cwd = NULL; // Current working directory to print - char_u *from = NULL; // The original string to copy + char *cwd = NULL; // Current working directory to print + char *from = NULL; // The original string to copy tabpage_T *tp = curtab; // The tabpage to look at. win_T *win = curwin; // The window to look at. @@ -3386,13 +3386,13 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr) FALLTHROUGH; case kCdScopeGlobal: if (globaldir) { // `globaldir` is not always set. - from = (char_u *)globaldir; + from = globaldir; break; } FALLTHROUGH; // In global directory, just need to get OS CWD. case kCdScopeInvalid: // If called without any arguments, get OS CWD. - if (os_dirname(cwd, MAXPATHL) == FAIL) { - from = (char_u *)""; // Return empty string on failure. + if (os_dirname((char_u *)cwd, MAXPATHL) == FAIL) { + from = ""; // Return empty string on failure. } } @@ -3400,7 +3400,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv, FunPtr fptr) STRLCPY(cwd, from, MAXPATHL); } - rettv->vval.v_string = (char *)vim_strsave(cwd); + rettv->vval.v_string = xstrdup(cwd); #ifdef BACKSLASH_IN_FILENAME slash_adjust(rettv->vval.v_string); #endif @@ -5968,7 +5968,7 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (*path_tail(dir) == NUL) { // Remove trailing slashes. - *path_tail_with_sep((char_u *)dir) = NUL; + *path_tail_with_sep((char *)dir) = NUL; } if (argvars[1].v_type != VAR_UNKNOWN) { @@ -6366,20 +6366,17 @@ static void f_prompt_getprompt(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "prompt_setprompt({buffer}, {text})" function static void f_prompt_setprompt(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - buf_T *buf; - const char_u *text; - if (check_secure()) { return; } - buf = tv_get_buf(&argvars[0], false); + buf_T *buf = tv_get_buf(&argvars[0], false); if (buf == NULL) { return; } - text = (const char_u *)tv_get_string(&argvars[1]); + const char *text = tv_get_string(&argvars[1]); xfree(buf->b_prompt_text); - buf->b_prompt_text = vim_strsave(text); + buf->b_prompt_text = xstrdup(text); } /// "pum_getpos()" function @@ -7341,7 +7338,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (!has_trailing_pathsep) { q = p + strlen(p); if (after_pathsep(p, q)) { - *path_tail_with_sep((char_u *)p) = NUL; + *path_tail_with_sep(p) = NUL; } } diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 97726da5f4..e19cf411c0 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1434,7 +1434,7 @@ dictitem_T *tv_dict_item_copy(dictitem_T *const di) void tv_dict_item_remove(dict_T *const dict, dictitem_T *const item) FUNC_ATTR_NONNULL_ALL { - hashitem_T *const hi = hash_find(&dict->dv_hashtab, item->di_key); + hashitem_T *const hi = hash_find(&dict->dv_hashtab, (char *)item->di_key); if (HASHITEM_EMPTY(hi)) { semsg(_(e_intern2), "tv_dict_item_remove()"); } else { @@ -1567,7 +1567,7 @@ dictitem_T *tv_dict_find(const dict_T *const d, const char *const key, const ptr return NULL; } hashitem_T *const hi = (len < 0 - ? hash_find(&d->dv_hashtab, (const char_u *)key) + ? hash_find(&d->dv_hashtab, key) : hash_find_len(&d->dv_hashtab, key, (size_t)len)); if (HASHITEM_EMPTY(hi)) { return NULL; diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 8646520ec3..c2579944e4 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -547,9 +547,7 @@ static char_u *fname_trans_sid(const char_u *const name, char_u *const fname_buf /// @return NULL for unknown function. ufunc_T *find_func(const char_u *name) { - hashitem_T *hi; - - hi = hash_find(&func_hashtab, name); + hashitem_T *hi = hash_find(&func_hashtab, (char *)name); if (!HASHITEM_EMPTY(hi)) { return HI2UF(hi); } @@ -724,7 +722,7 @@ static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force) /// @return true if the entry was deleted, false if it wasn't found. static bool func_remove(ufunc_T *fp) { - hashitem_T *hi = hash_find(&func_hashtab, UF2HIKEY(fp)); + hashitem_T *hi = hash_find(&func_hashtab, (char *)UF2HIKEY(fp)); if (!HASHITEM_EMPTY(hi)) { hash_remove(&func_hashtab, hi); @@ -1045,7 +1043,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett char *s = tofree; char buf[MSG_BUF_LEN]; if (vim_strsize(s) > MSG_BUF_CLEN) { - trunc_string((char_u *)s, (char_u *)buf, MSG_BUF_CLEN, sizeof(buf)); + trunc_string(s, buf, MSG_BUF_CLEN, sizeof(buf)); s = buf; } msg_puts(s); @@ -1159,7 +1157,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett emsg_off--; if (s != NULL) { if (vim_strsize(s) > MSG_BUF_CLEN) { - trunc_string((char_u *)s, (char_u *)buf, MSG_BUF_CLEN, MSG_BUF_LEN); + trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN); s = buf; } smsg(_("%s returning %s"), sourcing_name, s); @@ -1976,7 +1974,7 @@ void ex_function(exarg_T *eap) --todo; fp = HI2UF(hi); if (!isdigit(*fp->uf_name) - && vim_regexec(®match, fp->uf_name, 0)) { + && vim_regexec(®match, (char *)fp->uf_name, 0)) { list_func_head(fp, false, false); } } @@ -2537,7 +2535,7 @@ void ex_function(exarg_T *eap) // insert the new function in the function list STRCPY(fp->uf_name, name); if (overwrite) { - hi = hash_find(&func_hashtab, name); + hi = hash_find(&func_hashtab, (char *)name); hi->hi_key = UF2HIKEY(fp); } else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) { xfree(fp); |