diff options
author | Dundar Göc <gocdundar@gmail.com> | 2022-08-26 23:11:25 +0200 |
---|---|---|
committer | dundargoc <gocdundar@gmail.com> | 2022-11-26 15:52:21 +0100 |
commit | bd22585061b66d7f71d4832b4a81e950b3c9d19d (patch) | |
tree | 8c677ace61ab212cef87bc5abbd83c56e50f800d /src/nvim/eval | |
parent | 29b80f6f2e9391b5d78390f65d09f00f73829310 (diff) | |
download | rneovim-bd22585061b66d7f71d4832b4a81e950b3c9d19d.tar.gz rneovim-bd22585061b66d7f71d4832b4a81e950b3c9d19d.tar.bz2 rneovim-bd22585061b66d7f71d4832b4a81e950b3c9d19d.zip |
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src/nvim/eval')
-rw-r--r-- | src/nvim/eval/encode.c | 6 | ||||
-rw-r--r-- | src/nvim/eval/encode.h | 2 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 3 | ||||
-rw-r--r-- | src/nvim/eval/typval.c | 6 | ||||
-rw-r--r-- | src/nvim/eval/typval_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 32 | ||||
-rw-r--r-- | src/nvim/eval/vars.c | 4 |
7 files changed, 27 insertions, 28 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 3e002ef52c..b7ef109f06 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -136,9 +136,9 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, typval_T key_tv = { .v_type = VAR_STRING, .vval = { .v_string = - (char *)(v.data.d.hi == - NULL ? v.data.d.dict->dv_hashtab.ht_array : (v.data.d.hi - - 1))->hi_key }, + (v.data.d.hi == + NULL ? v.data.d.dict->dv_hashtab.ht_array : (v.data.d.hi - + 1))->hi_key }, }; char *const key = encode_tv2string(&key_tv, NULL); vim_snprintf((char *)IObuff, IOSIZE, key_msg, key); diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h index 5c217abb5a..e66dab1cff 100644 --- a/src/nvim/eval/encode.h +++ b/src/nvim/eval/encode.h @@ -47,7 +47,7 @@ static inline ListReaderState encode_init_lrstate(const list_T *const list) .offset = 0, .li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL ? 0 - : STRLEN(TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string)), + : strlen(TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string)), }; } diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 96c483ea75..67da5803d9 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -7996,8 +7996,7 @@ static void f_shellescape(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) const bool do_special = non_zero_arg(&argvars[1]); rettv->vval.v_string = - (char *)vim_strsave_shellescape((const char_u *)tv_get_string(&argvars[0]), do_special, - do_special); + vim_strsave_shellescape(tv_get_string(&argvars[0]), do_special, do_special); rettv->v_type = VAR_STRING; } diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 25b2a20bac..1de268a9d8 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -2098,7 +2098,7 @@ char **tv_dict_to_env(dict_T *denv) TV_DICT_ITER(denv, var, { const char *str = tv_get_string(&var->di_tv); assert(str); - size_t len = STRLEN(var->di_key) + strlen(str) + strlen("=") + 1; + size_t len = strlen((char *)var->di_key) + strlen(str) + strlen("=") + 1; env[i] = xmalloc(len); snprintf(env[i], len, "%s=%s", (char *)var->di_key, str); i++; @@ -2230,7 +2230,7 @@ int tv_dict_add(dict_T *const d, dictitem_T *const item) if (tv_dict_wrong_func_name(d, &item->di_tv, (const char *)item->di_key)) { return FAIL; } - return hash_add(&d->dv_hashtab, item->di_key); + return hash_add(&d->dv_hashtab, (char *)item->di_key); } /// Add a list entry to dictionary @@ -2586,7 +2586,7 @@ dict_T *tv_dict_copy(const vimconv_T *const conv, dict_T *const orig, const bool if (conv == NULL || conv->vc_type == CONV_NONE) { new_di = tv_dict_item_alloc((const char *)di->di_key); } else { - size_t len = STRLEN(di->di_key); + size_t len = strlen((char *)di->di_key); char *const key = (char *)string_convert(conv, (char *)di->di_key, &len); if (key == NULL) { new_di = tv_dict_item_alloc_len((const char *)di->di_key, len); diff --git a/src/nvim/eval/typval_defs.h b/src/nvim/eval/typval_defs.h index 1c0a438751..f025f21cf7 100644 --- a/src/nvim/eval/typval_defs.h +++ b/src/nvim/eval/typval_defs.h @@ -339,7 +339,7 @@ struct ufunc { funccall_T *uf_scoped; ///< l: local variables for closure char_u *uf_name_exp; ///< if "uf_name[]" starts with SNR the name with ///< "<SNR>" as a string, otherwise NULL - char_u uf_name[]; ///< Name of function (actual size equals name); + char uf_name[]; ///< Name of function (actual size equals name); ///< can start with <SNR>123_ ///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR) }; diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 42f78422cb..7f0ac06f60 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -595,7 +595,7 @@ ufunc_T *find_func(const char_u *name) /// Takes care of script-local function names. static void cat_func_name(char_u *buf, ufunc_T *fp) { - if (fp->uf_name[0] == K_SPECIAL) { + if ((uint8_t)fp->uf_name[0] == K_SPECIAL) { STRCPY(buf, "<SNR>"); STRCAT(buf, fp->uf_name + 3); } else { @@ -610,7 +610,7 @@ static void add_nr_var(dict_T *dp, dictitem_T *v, char *name, varnumber_T nr) STRCPY(v->di_key, name); #endif v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; - hash_add(&dp->dv_hashtab, v->di_key); + hash_add(&dp->dv_hashtab, (char *)v->di_key); v->di_tv.v_type = VAR_NUMBER; v->di_tv.v_lock = VAR_FIXED; v->di_tv.vval.v_number = nr; @@ -906,7 +906,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett STRCPY(name, "self"); #endif v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; - hash_add(&fc->l_vars.dv_hashtab, v->di_key); + hash_add(&fc->l_vars.dv_hashtab, (char *)v->di_key); v->di_tv.v_type = VAR_DICT; v->di_tv.v_lock = VAR_UNLOCKED; v->di_tv.vval.v_dict = selfdict; @@ -932,7 +932,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett STRCPY(name, "000"); #endif v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; - hash_add(&fc->l_avars.dv_hashtab, v->di_key); + hash_add(&fc->l_avars.dv_hashtab, (char *)v->di_key); v->di_tv.v_type = VAR_LIST; v->di_tv.v_lock = VAR_FIXED; v->di_tv.vval.v_list = &fc->l_varlist; @@ -1010,9 +1010,9 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett // Named arguments can be accessed without the "a:" prefix in lambda // expressions. Add to the l: dict. tv_copy(&v->di_tv, &v->di_tv); - hash_add(&fc->l_vars.dv_hashtab, v->di_key); + hash_add(&fc->l_vars.dv_hashtab, (char *)v->di_key); } else { - hash_add(&fc->l_avars.dv_hashtab, v->di_key); + hash_add(&fc->l_avars.dv_hashtab, (char *)v->di_key); } if (ai >= 0 && ai < MAX_FUNC_ARGS) { @@ -1318,7 +1318,7 @@ void free_all_functions(void) // Only free functions that are not refcounted, those are // supposed to be freed when no longer referenced. fp = HI2UF(hi); - if (func_name_refcount(fp->uf_name)) { + if (func_name_refcount((char_u *)fp->uf_name)) { skipped++; } else { used = func_hashtab.ht_used; @@ -1344,7 +1344,7 @@ void free_all_functions(void) // Only free functions that are not refcounted, those are // supposed to be freed when no longer referenced. fp = HI2UF(hi); - if (func_name_refcount(fp->uf_name)) { + if (func_name_refcount((char_u *)fp->uf_name)) { skipped++; } else { func_free(fp); @@ -1654,7 +1654,7 @@ theend: char_u *printable_func_name(ufunc_T *fp) { - return fp->uf_name_exp != NULL ? fp->uf_name_exp : fp->uf_name; + return fp->uf_name_exp != NULL ? fp->uf_name_exp : (char_u *)fp->uf_name; } /// List the head of the function: "name(arg1, arg2)". @@ -1970,7 +1970,7 @@ static void list_functions(regmatch_T *regmatch) if ((fp->uf_flags & FC_DEAD) == 0 && (regmatch == NULL ? (!message_filtered((char *)fp->uf_name) - && !func_name_refcount(fp->uf_name)) + && !func_name_refcount((char_u *)fp->uf_name)) : (!isdigit(*fp->uf_name) && vim_regexec(regmatch, (char *)fp->uf_name, 0)))) { list_func_head(fp, false, false); @@ -2590,7 +2590,7 @@ void ex_function(exarg_T *eap) set_ufunc_name(fp, name); if (overwrite) { hi = hash_find(&func_hashtab, name); - hi->hi_key = UF2HIKEY(fp); + hi->hi_key = (char *)UF2HIKEY(fp); } else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) { xfree(fp); goto erret; @@ -2718,7 +2718,7 @@ char *get_user_func_name(expand_T *xp, int idx) return ""; // don't show dict and lambda functions } - if (STRLEN(fp->uf_name) + 4 >= IOSIZE) { + if (strlen(fp->uf_name) + 4 >= IOSIZE) { return (char *)fp->uf_name; // Prevent overflow. } @@ -2802,7 +2802,7 @@ void ex_delfunction(exarg_T *eap) // it and the refcount is more than one, it should be kept. // A numbered function or lambda should be kept if the refcount is // one or more. - if (fp->uf_refcount > (func_name_refcount(fp->uf_name) ? 0 : 1)) { + if (fp->uf_refcount > (func_name_refcount((char_u *)fp->uf_name) ? 0 : 1)) { // Function is still referenced somewhere. Don't free it but // do remove it from the hashtable. if (func_remove(fp)) { @@ -3320,7 +3320,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv) /// @return the name of the executed function. char_u *func_name(void *cookie) { - return ((funccall_T *)cookie)->func->uf_name; + return (char_u *)((funccall_T *)cookie)->func->uf_name; } /// @return the address holding the next breakpoint line for a funccall cookie. @@ -3579,7 +3579,7 @@ bool set_ref_in_functions(int copyID) if (!HASHITEM_EMPTY(hi)) { todo--; fp = HI2UF(hi); - if (!func_name_refcount(fp->uf_name) + if (!func_name_refcount((char_u *)fp->uf_name) && set_ref_in_func(NULL, fp, copyID)) { return true; } @@ -3648,5 +3648,5 @@ char_u *register_luafunc(LuaRef ref) hash_add(&func_hashtab, UF2HIKEY(fp)); // coverity[leaked_storage] - return fp->uf_name; + return (char_u *)fp->uf_name; } diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 733bc3ac2d..2d7df6fde9 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1174,7 +1174,7 @@ void delete_var(hashtab_T *ht, hashitem_T *hi) static void list_one_var(dictitem_T *v, const char *prefix, int *first) { char *const s = encode_tv2echo(&v->di_tv, NULL); - list_one_var_a(prefix, (const char *)v->di_key, (ptrdiff_t)STRLEN(v->di_key), + list_one_var_a(prefix, (const char *)v->di_key, (ptrdiff_t)strlen((char *)v->di_key), v->di_tv.v_type, (s == NULL ? "" : s), first); xfree(s); } @@ -1342,7 +1342,7 @@ void set_var_const(const char *name, const size_t name_len, typval_T *const tv, v = xmalloc(sizeof(dictitem_T) + strlen(varname)); STRCPY(v->di_key, varname); - if (hash_add(ht, v->di_key) == FAIL) { + if (hash_add(ht, (char *)v->di_key) == FAIL) { xfree(v); return; } |