mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +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:
@@ -292,7 +292,7 @@ static void init_incsearch_state(incsearch_state_T *s)
|
||||
/// Given to ExpandGeneric() to obtain all available heathcheck names.
|
||||
/// @param[in] idx Index of the healthcheck item.
|
||||
/// @param[in] xp Not used.
|
||||
static char_u *get_healthcheck_names(expand_T *xp, int idx)
|
||||
static char *get_healthcheck_names(expand_T *xp, int idx)
|
||||
{
|
||||
// Generate the first time or on new prompt.
|
||||
if (healthchecks.last_gen == 0 || healthchecks.last_gen != last_prompt_id) {
|
||||
@@ -310,8 +310,8 @@ static char_u *get_healthcheck_names(expand_T *xp, int idx)
|
||||
// Tracked to regenerate items on next prompt.
|
||||
healthchecks.last_gen = last_prompt_id;
|
||||
}
|
||||
return idx <
|
||||
healthchecks.names.ga_len ? ((char_u **)(healthchecks.names.ga_data))[idx] : NULL;
|
||||
return idx < healthchecks.names.ga_len
|
||||
? ((char **)(healthchecks.names.ga_data))[idx] : NULL;
|
||||
}
|
||||
|
||||
/// Transform healthcheck file path into it's name.
|
||||
@@ -325,7 +325,7 @@ static void get_healthcheck_cb(char *path, void *cookie)
|
||||
struct healthchecks_cookie *hcookie = (struct healthchecks_cookie *)cookie;
|
||||
char *pattern;
|
||||
char *sub = "\\1";
|
||||
char_u *res;
|
||||
char *res;
|
||||
|
||||
if (hcookie->is_lua) {
|
||||
// Lua: transform "../lua/vim/lsp/health.lua" into "vim.lsp"
|
||||
@@ -335,16 +335,16 @@ static void get_healthcheck_cb(char *path, void *cookie)
|
||||
pattern = ".*[\\/]\\([^\\/]*\\)\\.vim$";
|
||||
}
|
||||
|
||||
res = (char_u *)do_string_sub(path, pattern, sub, NULL, "g");
|
||||
res = do_string_sub(path, pattern, sub, NULL, "g");
|
||||
if (hcookie->is_lua && res != NULL) {
|
||||
// Replace slashes with dots as represented by the healthcheck plugin.
|
||||
char_u *ares = (char_u *)do_string_sub((char *)res, "[\\/]", ".", NULL, "g");
|
||||
char *ares = do_string_sub(res, "[\\/]", ".", NULL, "g");
|
||||
xfree(res);
|
||||
res = ares;
|
||||
}
|
||||
|
||||
if (res != NULL) {
|
||||
GA_APPEND(char_u *, hcookie->names, res);
|
||||
GA_APPEND(char *, hcookie->names, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,12 +355,12 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
int *skiplen, int *patlen)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char_u *cmd;
|
||||
char *cmd;
|
||||
cmdmod_T save_cmdmod = cmdmod;
|
||||
char_u *p;
|
||||
char *p;
|
||||
bool delim_optional = false;
|
||||
int delim;
|
||||
char_u *end;
|
||||
char *end;
|
||||
char *dummy;
|
||||
exarg_T ea;
|
||||
pos_T save_cursor;
|
||||
@@ -396,14 +396,14 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
parse_command_modifiers(&ea, &dummy, true);
|
||||
cmdmod = save_cmdmod;
|
||||
|
||||
cmd = (char_u *)skip_range(ea.cmd, NULL);
|
||||
cmd = skip_range(ea.cmd, NULL);
|
||||
if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) {
|
||||
goto theend;
|
||||
}
|
||||
|
||||
// Skip over "substitute" to find the pattern separator.
|
||||
for (p = cmd; ASCII_ISALPHA(*p); p++) {}
|
||||
if (*skipwhite((char *)p) == NUL) {
|
||||
if (*skipwhite(p) == NUL) {
|
||||
goto theend;
|
||||
}
|
||||
|
||||
@@ -419,9 +419,9 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
} else if (STRNCMP(cmd, "sort", MAX(p - cmd, 3)) == 0) {
|
||||
// skip over ! and flags
|
||||
if (*p == '!') {
|
||||
p = (char_u *)skipwhite((char *)p + 1);
|
||||
p = skipwhite(p + 1);
|
||||
}
|
||||
while (ASCII_ISALPHA(*(p = (char_u *)skipwhite((char *)p)))) {
|
||||
while (ASCII_ISALPHA(*(p = skipwhite((char *)p)))) {
|
||||
p++;
|
||||
}
|
||||
if (*p == NUL) {
|
||||
@@ -435,7 +435,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
// skip over "!/".
|
||||
if (*p == '!') {
|
||||
p++;
|
||||
if (*skipwhite((char *)p) == NUL) {
|
||||
if (*skipwhite(p) == NUL) {
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
@@ -446,10 +446,10 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
goto theend;
|
||||
}
|
||||
|
||||
p = (char_u *)skipwhite((char *)p);
|
||||
p = skipwhite(p);
|
||||
delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++;
|
||||
*search_delim = delim;
|
||||
end = skip_regexp(p, delim, p_magic, NULL);
|
||||
end = (char *)skip_regexp((char_u *)p, delim, p_magic, NULL);
|
||||
|
||||
use_last_pat = end == p && *end == delim;
|
||||
if (end == p && !use_last_pat) {
|
||||
@@ -458,11 +458,11 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
|
||||
// Don't do 'hlsearch' highlighting if the pattern matches everything.
|
||||
if (!use_last_pat) {
|
||||
char_u c = *end;
|
||||
char c = *end;
|
||||
int empty;
|
||||
|
||||
*end = NUL;
|
||||
empty = empty_pattern(p);
|
||||
empty = empty_pattern((char_u *)p);
|
||||
*end = c;
|
||||
if (empty) {
|
||||
goto theend;
|
||||
@@ -470,7 +470,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
||||
}
|
||||
|
||||
// found a non-empty pattern or //
|
||||
*skiplen = (int)(p - ccline.cmdbuff);
|
||||
*skiplen = (int)((char_u *)p - ccline.cmdbuff);
|
||||
*patlen = (int)(end - p);
|
||||
|
||||
// parse the address range
|
||||
@@ -2601,14 +2601,14 @@ static void correct_screencol(int idx, int cells, int *col)
|
||||
///
|
||||
/// @param c normally ':', NUL for ":append"
|
||||
/// @param indent indent for inside conditionals
|
||||
char_u *getexline(int c, void *cookie, int indent, bool do_concat)
|
||||
char *getexline(int c, void *cookie, int indent, bool do_concat)
|
||||
{
|
||||
// When executing a register, remove ':' that's in front of each line.
|
||||
if (exec_from_reg && vpeekc() == ':') {
|
||||
(void)vgetc();
|
||||
}
|
||||
|
||||
return getcmdline(c, 1L, indent, do_concat);
|
||||
return (char *)getcmdline(c, 1L, indent, do_concat);
|
||||
}
|
||||
|
||||
bool cmdline_overstrike(void)
|
||||
@@ -2675,7 +2675,7 @@ static void realloc_cmdbuff(int len)
|
||||
}
|
||||
}
|
||||
|
||||
static char_u *arshape_buf = NULL;
|
||||
static char *arshape_buf = NULL;
|
||||
|
||||
#if defined(EXITFREE)
|
||||
void free_arshape_buf(void)
|
||||
@@ -3073,11 +3073,11 @@ static void draw_cmdline(int start, int len)
|
||||
|
||||
u8c = arabic_shape(u8c, NULL, &u8cc[0], pc, pc1, nc);
|
||||
|
||||
newlen += utf_char2bytes(u8c, (char *)arshape_buf + newlen);
|
||||
newlen += utf_char2bytes(u8c, arshape_buf + newlen);
|
||||
if (u8cc[0] != 0) {
|
||||
newlen += utf_char2bytes(u8cc[0], (char *)arshape_buf + newlen);
|
||||
newlen += utf_char2bytes(u8cc[0], arshape_buf + newlen);
|
||||
if (u8cc[1] != 0) {
|
||||
newlen += utf_char2bytes(u8cc[1], (char *)arshape_buf + newlen);
|
||||
newlen += utf_char2bytes(u8cc[1], arshape_buf + newlen);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -3087,7 +3087,7 @@ static void draw_cmdline(int start, int len)
|
||||
}
|
||||
}
|
||||
|
||||
msg_outtrans_len(arshape_buf, newlen);
|
||||
msg_outtrans_len((char_u *)arshape_buf, newlen);
|
||||
} else {
|
||||
draw_cmdline_no_arabicshape:
|
||||
if (kv_size(ccline.last_colors.colors)) {
|
||||
@@ -4490,7 +4490,7 @@ static int expand_showtail(expand_T *xp)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
end = path_tail((char_u *)xp->xp_pattern);
|
||||
end = (char_u *)path_tail(xp->xp_pattern);
|
||||
if (end == (char_u *)xp->xp_pattern) { // there is no path separator
|
||||
return false;
|
||||
}
|
||||
@@ -4617,7 +4617,7 @@ char_u *addstar(char_u *fname, size_t len, int context)
|
||||
* ` could be anywhere in the file name.
|
||||
* When the name ends in '$' don't add a star, remove the '$'.
|
||||
*/
|
||||
tail = path_tail(retval);
|
||||
tail = (char_u *)path_tail((char *)retval);
|
||||
ends_in_star = (len > 0 && retval[len - 1] == '*');
|
||||
#ifndef BACKSLASH_IN_FILENAME
|
||||
for (ssize_t k = (ssize_t)len - 2; k >= 0; k--) {
|
||||
@@ -4833,7 +4833,7 @@ static void cleanup_help_tags(int num_file, char_u **file)
|
||||
}
|
||||
}
|
||||
|
||||
typedef char_u *(*ExpandFunc)(expand_T *, int);
|
||||
typedef char *(*ExpandFunc)(expand_T *, int);
|
||||
|
||||
/// Do the expansion based on xp->xp_context and "pat".
|
||||
///
|
||||
@@ -5098,8 +5098,8 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha
|
||||
char_u *str;
|
||||
|
||||
// count the number of matching names
|
||||
for (i = 0;; ++i) {
|
||||
str = (*func)(xp, i);
|
||||
for (i = 0;; i++) {
|
||||
str = (char_u *)(*func)(xp, i);
|
||||
if (str == NULL) { // end of list
|
||||
break;
|
||||
}
|
||||
@@ -5120,7 +5120,7 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha
|
||||
// copy the matching names into allocated memory
|
||||
count = 0;
|
||||
for (i = 0;; i++) {
|
||||
str = (*func)(xp, i);
|
||||
str = (char_u *)(*func)(xp, i);
|
||||
if (str == NULL) { // End of list.
|
||||
break;
|
||||
}
|
||||
@@ -5570,7 +5570,7 @@ static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file)
|
||||
|
||||
for (int i = 0; i < ga.ga_len; i++) {
|
||||
char_u *match = ((char_u **)ga.ga_data)[i];
|
||||
s = path_tail(match);
|
||||
s = (char_u *)path_tail((char *)match);
|
||||
memmove(match, s, STRLEN(s) + 1);
|
||||
}
|
||||
|
||||
@@ -5677,7 +5677,7 @@ static char *(history_names[]) =
|
||||
* Function given to ExpandGeneric() to obtain the possible first
|
||||
* arguments of the ":history command.
|
||||
*/
|
||||
static char_u *get_history_arg(expand_T *xp, int idx)
|
||||
static char *get_history_arg(expand_T *xp, int idx)
|
||||
{
|
||||
static char_u compl[2] = { NUL, NUL };
|
||||
char *short_names = ":=@>?/";
|
||||
@@ -5686,13 +5686,13 @@ static char_u *get_history_arg(expand_T *xp, int idx)
|
||||
|
||||
if (idx < short_names_count) {
|
||||
compl[0] = (char_u)short_names[idx];
|
||||
return compl;
|
||||
return (char *)compl;
|
||||
}
|
||||
if (idx < short_names_count + history_name_count) {
|
||||
return (char_u *)history_names[idx - short_names_count];
|
||||
return history_names[idx - short_names_count];
|
||||
}
|
||||
if (idx == short_names_count + history_name_count) {
|
||||
return (char_u *)"all";
|
||||
return "all";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -5959,9 +5959,9 @@ char_u *get_cmdline_completion(void)
|
||||
|
||||
if (p != NULL && p->xpc != NULL) {
|
||||
set_expand_context(p->xpc);
|
||||
char_u *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context);
|
||||
char *cmd_compl = get_user_cmd_complete(p->xpc, p->xpc->xp_context);
|
||||
if (cmd_compl != NULL) {
|
||||
return vim_strsave(cmd_compl);
|
||||
return vim_strsave((char_u *)cmd_compl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6641,8 +6641,8 @@ char *script_get(exarg_T *const eap, size_t *const lenp)
|
||||
|
||||
const char *const end_pattern = (cmd[2] != NUL ? (const char *)skipwhite(cmd + 2) : ".");
|
||||
for (;;) {
|
||||
char *const theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 :
|
||||
NUL, eap->cookie, 0, true);
|
||||
char *const theline = (char *)eap->getline(eap->cstack->cs_looplevel > 0 ? -1 : NUL,
|
||||
eap->cookie, 0, true);
|
||||
|
||||
if (theline == NULL || strcmp(end_pattern, theline) == 0) {
|
||||
xfree(theline);
|
||||
|
Reference in New Issue
Block a user