mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 13:58:18 +00:00
refactor: replace char_u variables and functions with char
Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
@@ -116,7 +116,7 @@ static va_list dummy_ap;
|
||||
|
||||
/// Function given to ExpandGeneric() to obtain the list of internal
|
||||
/// or user defined function names.
|
||||
char_u *get_function_name(expand_T *xp, int idx)
|
||||
char *get_function_name(expand_T *xp, int idx)
|
||||
{
|
||||
static int intidx = -1;
|
||||
char_u *name;
|
||||
@@ -125,13 +125,13 @@ char_u *get_function_name(expand_T *xp, int idx)
|
||||
intidx = -1;
|
||||
}
|
||||
if (intidx < 0) {
|
||||
name = get_user_func_name(xp, idx);
|
||||
name = (char_u *)get_user_func_name(xp, idx);
|
||||
if (name != NULL) {
|
||||
if (*name != NUL && *name != '<'
|
||||
&& STRNCMP("g:", xp->xp_pattern, 2) == 0) {
|
||||
return (char_u *)cat_prefix_varname('g', (char *)name);
|
||||
return cat_prefix_varname('g', (char *)name);
|
||||
}
|
||||
return name;
|
||||
return (char *)name;
|
||||
}
|
||||
}
|
||||
while ((size_t)++intidx < ARRAY_SIZE(functions)
|
||||
@@ -151,12 +151,12 @@ char_u *get_function_name(expand_T *xp, int idx)
|
||||
} else {
|
||||
IObuff[key_len + 1] = NUL;
|
||||
}
|
||||
return IObuff;
|
||||
return (char *)IObuff;
|
||||
}
|
||||
|
||||
/// Function given to ExpandGeneric() to obtain the list of internal or
|
||||
/// user defined variable or function names.
|
||||
char_u *get_expr_name(expand_T *xp, int idx)
|
||||
char *get_expr_name(expand_T *xp, int idx)
|
||||
{
|
||||
static int intidx = -1;
|
||||
char_u *name;
|
||||
@@ -165,9 +165,9 @@ char_u *get_expr_name(expand_T *xp, int idx)
|
||||
intidx = -1;
|
||||
}
|
||||
if (intidx < 0) {
|
||||
name = get_function_name(xp, idx);
|
||||
name = (char_u *)get_function_name(xp, idx);
|
||||
if (name != NULL) {
|
||||
return name;
|
||||
return (char *)name;
|
||||
}
|
||||
}
|
||||
return get_user_var_name(xp, ++intidx);
|
||||
@@ -1931,7 +1931,7 @@ typedef struct {
|
||||
const listitem_T *li;
|
||||
} GetListLineCookie;
|
||||
|
||||
static char_u *get_list_line(int c, void *cookie, int indent, bool do_concat)
|
||||
static char *get_list_line(int c, void *cookie, int indent, bool do_concat)
|
||||
{
|
||||
GetListLineCookie *const p = (GetListLineCookie *)cookie;
|
||||
|
||||
@@ -1942,7 +1942,7 @@ static char_u *get_list_line(int c, void *cookie, int indent, bool do_concat)
|
||||
char buf[NUMBUFLEN];
|
||||
const char *const s = tv_get_string_buf_chk(TV_LIST_ITEM_TV(item), buf);
|
||||
p->li = TV_LIST_ITEM_NEXT(p->l, item);
|
||||
return (char_u *)(s == NULL ? NULL : xstrdup(s));
|
||||
return s == NULL ? NULL : xstrdup(s);
|
||||
}
|
||||
|
||||
static void execute_common(typval_T *argvars, typval_T *rettv, FunPtr fptr, int arg_off)
|
||||
@@ -2562,7 +2562,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
foldstart = (linenr_T)get_vim_var_nr(VV_FOLDSTART);
|
||||
foldend = (linenr_T)get_vim_var_nr(VV_FOLDEND);
|
||||
dashes = get_vim_var_str(VV_FOLDDASHES);
|
||||
dashes = (char_u *)get_vim_var_str(VV_FOLDDASHES);
|
||||
if (foldstart > 0 && foldend <= curbuf->b_ml.ml_line_count) {
|
||||
// Find first non-empty line in the fold.
|
||||
for (lnum = foldstart; lnum < foldend; lnum++) {
|
||||
@@ -3082,7 +3082,7 @@ static void f_getcharstr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
getchar_common(argvars, rettv);
|
||||
|
||||
if (rettv->v_type == VAR_NUMBER) {
|
||||
char_u temp[7]; // mbyte-char: 6, NUL: 1
|
||||
char temp[7]; // mbyte-char: 6, NUL: 1
|
||||
const varnumber_T n = rettv->vval.v_number;
|
||||
int i = 0;
|
||||
|
||||
@@ -3092,7 +3092,7 @@ static void f_getcharstr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
assert(i < 7);
|
||||
temp[i++] = NUL;
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = (char *)vim_strsave(temp);
|
||||
rettv->vval.v_string = xstrdup(temp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3677,7 +3677,7 @@ static int getreg_get_regname(typval_T *argvars)
|
||||
}
|
||||
} else {
|
||||
// Default to v:register
|
||||
strregname = get_vim_var_str(VV_REG);
|
||||
strregname = (char_u *)get_vim_var_str(VV_REG);
|
||||
}
|
||||
|
||||
return *strregname == 0 ? '"' : *strregname;
|
||||
@@ -5101,7 +5101,7 @@ static dict_T *create_environment(const dictitem_T *job_env, const bool clear_en
|
||||
}
|
||||
|
||||
// Set $NVIM (in the child process) to v:servername. #3118
|
||||
char *nvim_addr = (char *)get_vim_var_str(VV_SEND_SERVER);
|
||||
char *nvim_addr = get_vim_var_str(VV_SEND_SERVER);
|
||||
if (nvim_addr[0] != '\0') {
|
||||
dictitem_T *dv = tv_dict_find(env, S_LEN("NVIM"));
|
||||
if (dv) {
|
||||
@@ -5646,7 +5646,7 @@ static void f_list2str(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
|
||||
ga_init(&ga, 1, 80);
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
char buf[MB_MAXBYTES + 1];
|
||||
|
||||
TV_LIST_ITER_CONST(l, li, {
|
||||
buf[utf_char2bytes(tv_get_number(TV_LIST_ITEM_TV(li)), (char *)buf)] = NUL;
|
||||
@@ -5666,7 +5666,7 @@ static void f_localtime(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
|
||||
{
|
||||
char_u *keys_buf = NULL;
|
||||
char *keys_buf = NULL;
|
||||
char_u *alt_keys_buf = NULL;
|
||||
bool did_simplify = false;
|
||||
char_u *rhs;
|
||||
@@ -5682,7 +5682,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
char_u *keys = (char_u *)tv_get_string(&argvars[0]);
|
||||
char *keys = (char *)tv_get_string(&argvars[0]);
|
||||
if (*keys == NUL) {
|
||||
return;
|
||||
}
|
||||
@@ -5707,14 +5707,14 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
|
||||
mode = get_map_mode((char **)&which, 0);
|
||||
|
||||
char_u *keys_simplified
|
||||
= (char_u *)replace_termcodes((char *)keys,
|
||||
STRLEN(keys), (char **)&keys_buf, flags, &did_simplify,
|
||||
= (char_u *)replace_termcodes(keys,
|
||||
STRLEN(keys), &keys_buf, flags, &did_simplify,
|
||||
CPO_TO_CPO_FLAGS);
|
||||
rhs = check_map(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().
|
||||
(void)replace_termcodes((char *)keys,
|
||||
(void)replace_termcodes(keys,
|
||||
STRLEN(keys),
|
||||
(char **)&alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL,
|
||||
CPO_TO_CPO_FLAGS);
|
||||
@@ -6100,7 +6100,7 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (*path_tail((char_u *)dir) == NUL) {
|
||||
if (*path_tail(dir) == NUL) {
|
||||
// Remove trailing slashes.
|
||||
*path_tail_with_sep((char_u *)dir) = NUL;
|
||||
}
|
||||
@@ -7402,11 +7402,11 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
q[-1] = NUL;
|
||||
}
|
||||
|
||||
q = (char *)path_tail((char_u *)p);
|
||||
q = path_tail(p);
|
||||
if (q > p && *q == NUL) {
|
||||
// Ignore trailing path separator.
|
||||
q[-1] = NUL;
|
||||
q = (char *)path_tail((char_u *)p);
|
||||
q = path_tail(p);
|
||||
}
|
||||
if (q > p && !path_is_absolute((const char_u *)buf)) {
|
||||
// Symlink is relative to directory of argument. Replace the
|
||||
@@ -7414,7 +7414,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
const size_t p_len = strlen(p);
|
||||
const size_t buf_len = strlen(buf);
|
||||
p = xrealloc(p, p_len + buf_len + 1);
|
||||
memcpy(path_tail((char_u *)p), buf, buf_len + 1);
|
||||
memcpy(path_tail(p), buf, buf_len + 1);
|
||||
} else {
|
||||
xfree(p);
|
||||
p = xstrdup(buf);
|
||||
@@ -7524,15 +7524,15 @@ static void f_reduce(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
return;
|
||||
}
|
||||
|
||||
const char_u *func_name;
|
||||
const char *func_name;
|
||||
partial_T *partial = NULL;
|
||||
if (argvars[1].v_type == VAR_FUNC) {
|
||||
func_name = (char_u *)argvars[1].vval.v_string;
|
||||
func_name = argvars[1].vval.v_string;
|
||||
} else if (argvars[1].v_type == VAR_PARTIAL) {
|
||||
partial = argvars[1].vval.v_partial;
|
||||
func_name = (char_u *)partial_name(partial);
|
||||
func_name = partial_name(partial);
|
||||
} else {
|
||||
func_name = (const char_u *)tv_get_string(&argvars[1]);
|
||||
func_name = tv_get_string(&argvars[1]);
|
||||
}
|
||||
if (*func_name == NUL) {
|
||||
return; // type error or empty name
|
||||
@@ -7881,7 +7881,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
|
||||
sctx_T save_current_sctx;
|
||||
uint8_t *save_sourcing_name, *save_autocmd_fname, *save_autocmd_match;
|
||||
char *save_sourcing_name, *save_autocmd_fname, *save_autocmd_match;
|
||||
linenr_T save_sourcing_lnum;
|
||||
int save_autocmd_bufnr;
|
||||
funccal_entry_T funccal_entry;
|
||||
@@ -9854,13 +9854,13 @@ static void f_stdpath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
/// "str2float()" function
|
||||
static void f_str2float(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
char_u *p = (char_u *)skipwhite(tv_get_string(&argvars[0]));
|
||||
char *p = skipwhite(tv_get_string(&argvars[0]));
|
||||
bool isneg = (*p == '-');
|
||||
|
||||
if (*p == '+' || *p == '-') {
|
||||
p = (char_u *)skipwhite((char *)p + 1);
|
||||
p = skipwhite(p + 1);
|
||||
}
|
||||
(void)string2float((char *)p, &rettv->vval.v_float);
|
||||
(void)string2float(p, &rettv->vval.v_float);
|
||||
if (isneg) {
|
||||
rettv->vval.v_float *= -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user