refactor: replace char_u with char 19 (#21241)

* refactor: replace char_u with char

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
dundargoc
2023-01-10 03:28:01 +01:00
committed by GitHub
parent f62da7381e
commit ef67503320
14 changed files with 499 additions and 505 deletions

View File

@@ -215,22 +215,22 @@ static int ses_do_win(win_T *wp)
/// @returns FAIL if writing fails.
static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigned *flagp)
{
char_u *buf = NULL;
char_u *s;
char *buf = NULL;
char *s;
if (fprintf(fd, "%s\n%s\n", cmd, "%argdel") < 0) {
return FAIL;
}
for (int i = 0; i < gap->ga_len; i++) {
// NULL file names are skipped (only happens when out of memory).
s = (char_u *)alist_name(&((aentry_T *)gap->ga_data)[i]);
s = alist_name(&((aentry_T *)gap->ga_data)[i]);
if (s != NULL) {
if (fullname) {
buf = xmalloc(MAXPATHL);
(void)vim_FullName((char *)s, (char *)buf, MAXPATHL, false);
(void)vim_FullName(s, buf, MAXPATHL, false);
s = buf;
}
char *fname_esc = ses_escape_fname((char *)s, flagp);
char *fname_esc = ses_escape_fname(s, flagp);
if (fprintf(fd, "$argadd %s\n", fname_esc) < 0) {
xfree(fname_esc);
xfree(buf);
@@ -268,7 +268,7 @@ static char *ses_get_fname(buf_T *buf, const unsigned *flagp)
static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol)
{
char *name = ses_get_fname(buf, flagp);
if (ses_put_fname(fd, (char_u *)name, flagp) == FAIL
if (ses_put_fname(fd, name, flagp) == FAIL
|| (add_eol && fprintf(fd, "\n") < 0)) {
return FAIL;
}
@@ -303,9 +303,9 @@ static char *ses_escape_fname(char *name, unsigned *flagp)
/// characters.
///
/// @return FAIL if writing fails.
static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp)
static int ses_put_fname(FILE *fd, char *name, unsigned *flagp)
{
char *p = ses_escape_fname((char *)name, flagp);
char *p = ses_escape_fname(name, flagp);
bool retval = fputs(p, fd) < 0 ? FAIL : OK;
xfree(p);
return retval;
@@ -527,7 +527,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
if (wp->w_localdir != NULL
&& (flagp != &vop_flags || (*flagp & SSOP_CURDIR))) {
if (fputs("lcd ", fd) < 0
|| ses_put_fname(fd, (char_u *)wp->w_localdir, flagp) == FAIL
|| ses_put_fname(fd, wp->w_localdir, flagp) == FAIL
|| fprintf(fd, "\n") < 0) {
return FAIL;
}
@@ -546,7 +546,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
/// @param fd File descriptor to write to
///
/// @return FAIL on error, OK otherwise.
static int makeopens(FILE *fd, char_u *dirnow)
static int makeopens(FILE *fd, char *dirnow)
{
int only_save_windows = true;
int nr;
@@ -585,7 +585,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
if (ssop_flags & SSOP_SESDIR) {
PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')");
} else if (ssop_flags & SSOP_CURDIR) {
sname = home_replace_save(NULL, globaldir != NULL ? globaldir : (char *)dirnow);
sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow);
char *fname_esc = ses_escape_fname(sname, &ssop_flags);
if (fprintf(fd, "cd %s\n", fname_esc) < 0) {
xfree(fname_esc);
@@ -832,7 +832,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
// Take care of tab-local working directories if applicable
if (tp->tp_localdir) {
if (fputs("if exists(':tcd') == 2 | tcd ", fd) < 0
|| ses_put_fname(fd, (char_u *)tp->tp_localdir, &ssop_flags) == FAIL
|| ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL
|| fputs(" | endif\n", fd) < 0) {
return FAIL;
}
@@ -1001,14 +1001,14 @@ void ex_mkrc(exarg_T *eap)
failed = true;
}
if (eap->cmdidx == CMD_mksession) {
char_u *dirnow; // current directory
char *dirnow; // current directory
dirnow = xmalloc(MAXPATHL);
//
// Change to session file's dir.
//
if (os_dirname((char *)dirnow, MAXPATHL) == FAIL
|| os_chdir((char *)dirnow) != 0) {
if (os_dirname(dirnow, MAXPATHL) == FAIL
|| os_chdir(dirnow) != 0) {
*dirnow = NUL;
}
if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) {
@@ -1028,7 +1028,7 @@ void ex_mkrc(exarg_T *eap)
if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR)
|| ((ssop_flags & SSOP_CURDIR) && globaldir !=
NULL))) {
if (os_chdir((char *)dirnow) != 0) {
if (os_chdir(dirnow) != 0) {
emsg(_(e_prev_dir));
}
shorten_fnames(true);