aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDundar Goc <gocdundar@gmail.com>2022-04-30 20:28:04 +0200
committerDundar Goc <gocdundar@gmail.com>2022-04-30 23:39:17 +0200
commitaf782a630633ffe0cb082bda974b24d4f577313e (patch)
tree7a65343a9d6cdd926aa46db55dd263c2d9eda793 /src
parent0344736aa698dc205f8f9f80609b7033308d39ca (diff)
downloadrneovim-af782a630633ffe0cb082bda974b24d4f577313e.tar.gz
rneovim-af782a630633ffe0cb082bda974b24d4f577313e.tar.bz2
rneovim-af782a630633ffe0cb082bda974b24d4f577313e.zip
refactor: replace char_u variables and functions with char
Work on https://github.com/neovim/neovim/issues/459
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c2
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/ex_cmds.c697
-rw-r--r--src/nvim/ex_cmds2.c10
-rw-r--r--src/nvim/ex_docmd.c14
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--src/nvim/main.c4
-rw-r--r--src/nvim/normal.c2
-rw-r--r--src/nvim/os/shell.c2
-rw-r--r--src/nvim/quickfix.c6
-rw-r--r--src/nvim/search.c2
-rw-r--r--src/nvim/tag.c6
-rw-r--r--src/nvim/window.c2
13 files changed, 374 insertions, 379 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 9b21608ce9..b4d4265a37 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -1113,7 +1113,7 @@ void nvim_buf_set_name(Buffer buffer, String name, Error *err)
// Using aucmd_*: autocommands will be executed by rename_buffer
aco_save_T aco;
aucmd_prepbuf(&aco, buf);
- int ren_ret = rename_buffer((char_u *)name.data);
+ int ren_ret = rename_buffer(name.data);
aucmd_restbuf(&aco);
if (try_end(err)) {
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 5786a73f43..c70d845c42 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -4870,7 +4870,7 @@ void do_arg_all(int count, int forceit, int keep_tabs)
new_curwin = curwin;
new_curtab = curtab;
}
- (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL, ECMD_ONE,
+ (void)do_ecmd(0, (char *)alist_name(&AARGLIST(alist)[i]), NULL, NULL, ECMD_ONE,
((buf_hide(curwin->w_buffer)
|| bufIsChanged(curwin->w_buffer))
? ECMD_HIDE : 0) + ECMD_OLDBUF,
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 7be8bbcaac..5cd3e7f968 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -117,7 +117,7 @@ static int preview_bufnr = 0;
/// ":ascii" and "ga" implementation
void do_ascii(const exarg_T *const eap)
{
- char_u *dig;
+ char *dig;
int cc[MAX_MCO];
int c = utfc_ptr2char(get_cursor_pos_ptr(), cc);
if (c == NUL) {
@@ -137,8 +137,8 @@ void do_ascii(const exarg_T *const eap)
: c);
char buf1[20];
if (vim_isprintc_strict(c) && (c < ' ' || c > '~')) {
- char_u buf3[7];
- transchar_nonprint(curbuf, buf3, c);
+ char buf3[7];
+ transchar_nonprint(curbuf, (char_u *)buf3, c);
vim_snprintf(buf1, sizeof(buf1), " <%s>", (char *)buf3);
} else {
buf1[0] = NUL;
@@ -146,7 +146,7 @@ void do_ascii(const exarg_T *const eap)
char buf2[20];
buf2[0] = NUL;
- dig = get_digraph_for_char(cval);
+ dig = (char *)get_digraph_for_char(cval);
if (dig != NULL) {
iobuff_len += (
vim_snprintf((char *)IObuff + iobuff_len,
@@ -196,7 +196,7 @@ void do_ascii(const exarg_T *const eap)
}
iobuff_len += utf_char2bytes(c, IObuff + iobuff_len);
- dig = get_digraph_for_char(c);
+ dig = (char *)get_digraph_for_char(c);
if (dig != NULL) {
iobuff_len += (
vim_snprintf((char *)IObuff + iobuff_len,
@@ -326,31 +326,31 @@ void ex_align(exarg_T *eap)
/// @return the length of the current line, excluding trailing white space.
static int linelen(int *has_tab)
{
- char_u *line;
- char_u *first;
- char_u *last;
+ char *line;
+ char *first;
+ char *last;
int save;
int len;
// Get the line. If it's empty bail out early (could be the empty string
// for an unloaded buffer).
- line = get_cursor_line_ptr();
+ line = (char *)get_cursor_line_ptr();
if (*line == NUL) {
return 0;
}
// find the first non-blank character
- first = skipwhite(line);
+ first = (char *)skipwhite((char_u *)line);
// find the character after the last non-blank character
for (last = first + STRLEN(first);
last > first && ascii_iswhite(last[-1]); last--) {}
- save = *last;
+ save = (char_u)(*last);
*last = NUL;
// Get line length.
- len = linetabsize(line);
+ len = linetabsize((char_u *)line);
// Check for embedded TAB.
if (has_tab != NULL) {
- *has_tab = vim_strchr(first, TAB) != NULL;
+ *has_tab = vim_strchr((char_u *)first, TAB) != NULL;
}
*last = save;
@@ -359,8 +359,8 @@ static int linelen(int *has_tab)
// Buffer for two lines used during sorting. They are allocated to
// contain the longest line being sorted.
-static char_u *sortbuf1;
-static char_u *sortbuf2;
+static char *sortbuf1;
+static char *sortbuf2;
static int sort_lc; ///< sort using locale
static int sort_ic; ///< ignore case
@@ -457,10 +457,10 @@ void ex_sort(exarg_T *eap)
long maxlen = 0;
size_t count = (size_t)(eap->line2 - eap->line1 + 1);
size_t i;
- char_u *p;
- char_u *s;
- char_u *s2;
- char_u c; // temporary character storage
+ char *p;
+ char *s;
+ char *s2;
+ char c; // temporary character storage
bool unique = false;
long deleted;
colnr_T start_col;
@@ -484,7 +484,7 @@ void ex_sort(exarg_T *eap)
size_t format_found = 0;
bool change_occurred = false; // Buffer contents changed.
- for (p = eap->arg; *p != NUL; ++p) {
+ for (p = (char *)eap->arg; *p != NUL; p++) {
if (ascii_iswhite(*p)) {
// Skip
} else if (*p == 'i') {
@@ -513,11 +513,11 @@ void ex_sort(exarg_T *eap)
} else if (*p == '"') {
// comment start
break;
- } else if (check_nextcmd(p) != NULL) {
- eap->nextcmd = check_nextcmd(p);
+ } else if (check_nextcmd((char_u *)p) != NULL) {
+ eap->nextcmd = check_nextcmd((char_u *)p);
break;
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
- s = skip_regexp(p + 1, *p, true, NULL);
+ s = (char *)skip_regexp((char_u *)p + 1, *p, true, NULL);
if (*s != *p) {
emsg(_(e_invalpat));
goto sortend;
@@ -531,7 +531,7 @@ void ex_sort(exarg_T *eap)
}
regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
} else {
- regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC);
+ regmatch.regprog = vim_regcomp((char_u *)p + 1, RE_MAGIC);
}
if (regmatch.regprog == NULL) {
goto sortend;
@@ -560,8 +560,8 @@ void ex_sort(exarg_T *eap)
// numbers sorting it's the number to sort on. This means the pattern
// matching and number conversion only has to be done once per line.
// Also get the longest line length for allocating "sortbuf".
- for (lnum = eap->line1; lnum <= eap->line2; ++lnum) {
- s = ml_get(lnum);
+ for (lnum = eap->line1; lnum <= eap->line2; lnum++) {
+ s = (char *)ml_get(lnum);
len = (int)STRLEN(s);
if (maxlen < len) {
maxlen = len;
@@ -569,12 +569,12 @@ void ex_sort(exarg_T *eap)
start_col = 0;
end_col = len;
- if (regmatch.regprog != NULL && vim_regexec(&regmatch, s, 0)) {
+ if (regmatch.regprog != NULL && vim_regexec(&regmatch, (char_u *)s, 0)) {
if (sort_rx) {
- start_col = (colnr_T)(regmatch.startp[0] - s);
- end_col = (colnr_T)(regmatch.endp[0] - s);
+ start_col = (colnr_T)(regmatch.startp[0] - (char_u *)s);
+ end_col = (colnr_T)(regmatch.endp[0] - (char_u *)s);
} else {
- start_col = (colnr_T)(regmatch.endp[0] - s);
+ start_col = (colnr_T)(regmatch.endp[0] - (char_u *)s);
}
} else if (regmatch.regprog != NULL) {
end_col = 0;
@@ -590,11 +590,11 @@ void ex_sort(exarg_T *eap)
p = s + start_col;
if (sort_nr) {
if (sort_what & STR2NR_HEX) {
- s = skiptohex(p);
+ s = (char *)skiptohex((char_u *)p);
} else if (sort_what & STR2NR_BIN) {
- s = (char_u *)skiptobin((char *)p);
+ s = (char *)skiptobin(p);
} else {
- s = skiptodigit(p);
+ s = (char *)skiptodigit((char_u *)p);
}
if (s > p && s[-1] == '-') {
s--; // include preceding negative sign
@@ -605,20 +605,20 @@ void ex_sort(exarg_T *eap)
nrs[lnum - eap->line1].st_u.num.value = 0;
} else {
nrs[lnum - eap->line1].st_u.num.is_number = true;
- vim_str2nr(s, NULL, NULL, sort_what,
+ vim_str2nr((char_u *)s, NULL, NULL, sort_what,
&nrs[lnum - eap->line1].st_u.num.value, NULL, 0, false);
}
} else {
- s = skipwhite(p);
+ s = (char *)skipwhite((char_u *)p);
if (*s == '+') {
- s = skipwhite(s + 1);
+ s = (char *)skipwhite((char_u *)s + 1);
}
if (*s == NUL) {
// empty line should sort before any number
nrs[lnum - eap->line1].st_u.value_flt = -DBL_MAX;
} else {
- nrs[lnum - eap->line1].st_u.value_flt = strtod((char *)s, NULL);
+ nrs[lnum - eap->line1].st_u.value_flt = strtod(s, NULL);
}
}
*s2 = c;
@@ -662,14 +662,14 @@ void ex_sort(exarg_T *eap)
change_occurred = true;
}
- s = ml_get(get_lnum);
+ s = (char *)ml_get(get_lnum);
size_t bytelen = STRLEN(s) + 1; // include EOL in bytelen
old_count += bytelen;
if (!unique || i == 0 || string_compare(s, sortbuf1) != 0) {
// Copy the line into a buffer, it may become invalid in
// ml_append(). And it's needed for "unique".
STRCPY(sortbuf1, s);
- if (ml_append(lnum++, sortbuf1, (colnr_T)0, false) == FAIL) {
+ if (ml_append(lnum++, (char_u *)sortbuf1, (colnr_T)0, false) == FAIL) {
break;
}
new_count += bytelen;
@@ -733,11 +733,11 @@ void ex_retab(exarg_T *eap)
long start_col = 0; // For start of white-space string
long start_vcol = 0; // For start of white-space string
long old_len;
- char_u *ptr;
- char_u *new_line = (char_u *)1; // init to non-NULL
+ char *ptr;
+ char *new_line = (char *)1; // init to non-NULL
bool did_undo; // called u_save for current line
long *new_vts_array = NULL;
- char_u *new_ts_str; // string value of tab argument
+ char *new_ts_str; // string value of tab argument
int save_list;
linenr_T first_line = 0; // first changed line
@@ -746,7 +746,7 @@ void ex_retab(exarg_T *eap)
save_list = curwin->w_p_list;
curwin->w_p_list = 0; // don't want list mode here
- new_ts_str = eap->arg;
+ new_ts_str = (char *)eap->arg;
if (!tabstop_set(eap->arg, &new_vts_array)) {
return;
}
@@ -761,10 +761,10 @@ void ex_retab(exarg_T *eap)
new_vts_array = curbuf->b_p_vts_array;
new_ts_str = NULL;
} else {
- new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
+ new_ts_str = xstrnsave(new_ts_str, eap->arg - (char_u *)new_ts_str);
}
for (lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) {
- ptr = ml_get(lnum);
+ ptr = (char *)ml_get(lnum);
col = 0;
vcol = 0;
did_undo = false;
@@ -825,9 +825,9 @@ void ex_retab(exarg_T *eap)
for (col = 0; col < len; col++) {
ptr[col] = (col < num_tabs) ? '\t' : ' ';
}
- if (ml_replace(lnum, new_line, false) == OK) {
+ if (ml_replace(lnum, (char_u *)new_line, false) == OK) {
// "new_line" may have been copied
- new_line = curbuf->b_ml.ml_line_ptr;
+ new_line = (char *)curbuf->b_ml.ml_line_ptr;
extmark_splice_cols(curbuf, lnum - 1, 0, (colnr_T)old_len,
(colnr_T)new_len - 1, kExtmarkUndo);
}
@@ -845,12 +845,12 @@ void ex_retab(exarg_T *eap)
if (ptr[col] == NUL) {
break;
}
- vcol += win_chartabsize(curwin, ptr + col, (colnr_T)vcol);
+ vcol += win_chartabsize(curwin, (char_u *)ptr + col, (colnr_T)vcol);
if (vcol >= MAXCOL) {
emsg(_(e_resulting_text_too_long));
break;
}
- col += utfc_ptr2len(ptr + col);
+ col += utfc_ptr2len((char_u *)ptr + col);
}
if (new_line == NULL) { // out of memory
break;
@@ -885,7 +885,7 @@ void ex_retab(exarg_T *eap)
long *old_vts_ary = curbuf->b_p_vts_array;
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) {
- set_string_option_direct("vts", -1, new_ts_str,
+ set_string_option_direct("vts", -1, (char_u *)new_ts_str,
OPT_FREE | OPT_LOCAL, 0);
curbuf->b_p_vts_array = new_vts_array;
xfree(old_vts_ary);
@@ -907,7 +907,7 @@ void ex_retab(exarg_T *eap)
/// @return FAIL for failure, OK otherwise
int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
{
- char_u *str;
+ char *str;
linenr_T l;
linenr_T extra; // Num lines added before line1
linenr_T num_lines; // Num lines moved
@@ -946,8 +946,8 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
return FAIL;
}
for (extra = 0, l = line1; l <= line2; l++) {
- str = vim_strsave(ml_get(l + extra));
- ml_append(dest + l - line1, str, (colnr_T)0, false);
+ str = (char *)vim_strsave(ml_get(l + extra));
+ ml_append(dest + l - line1, (char_u *)str, (colnr_T)0, false);
xfree(str);
if (dest < line1) {
extra++;
@@ -1059,7 +1059,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
{
linenr_T count;
- char_u *p;
+ char *p;
count = line2 - line1 + 1;
if (!cmdmod.lockmarks) {
@@ -1087,8 +1087,8 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
while (line1 <= line2) {
// need to use vim_strsave() because the line will be unlocked within
// ml_append()
- p = vim_strsave(ml_get(line1));
- ml_append(curwin->w_cursor.lnum, p, (colnr_T)0, false);
+ p = (char *)vim_strsave(ml_get(line1));
+ ml_append(curwin->w_cursor.lnum, (char_u *)p, (colnr_T)0, false);
xfree(p);
// situation 2: skip already copied lines
@@ -1113,7 +1113,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
msgmore((long)count);
}
-static char_u *prevcmd = NULL; // the previous command
+static char *prevcmd = NULL; // the previous command
#if defined(EXITFREE)
void free_prev_shellcmd(void)
@@ -1129,14 +1129,14 @@ void free_prev_shellcmd(void)
void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out)
FUNC_ATTR_NONNULL_ALL
{
- char_u *arg = eap->arg; // command
+ char *arg = (char *)eap->arg; // command
linenr_T line1 = eap->line1; // start of range
linenr_T line2 = eap->line2; // end of range
- char_u *newcmd = NULL; // the new command
+ char *newcmd = NULL; // the new command
bool free_newcmd = false; // need to free() newcmd
- char_u *t;
- char_u *p;
- char_u *trailarg;
+ char *t;
+ char *p;
+ char *trailarg;
int len;
int scroll_save = msg_scroll;
@@ -1213,9 +1213,9 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
// If % or # appears in the command, it must have been escaped.
// Reescape them, so that redoing them does not substitute them by the
// buffername.
- char_u *cmd = vim_strsave_escaped(prevcmd, (char_u *)"%#");
+ char *cmd = (char *)vim_strsave_escaped((char_u *)prevcmd, (char_u *)"%#");
- AppendToRedobuffLit(cmd, -1);
+ AppendToRedobuffLit((char_u *)cmd, -1);
xfree(cmd);
AppendToRedobuff("\n");
bangredo = false;
@@ -1235,7 +1235,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
msg_start();
msg_putchar(':');
msg_putchar('!');
- msg_outtrans(newcmd);
+ msg_outtrans((char_u *)newcmd);
msg_clr_eos();
ui_cursor_goto(msg_row, msg_col);
@@ -1266,15 +1266,15 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
/// We use output redirection if do_out is true.
///
/// @param eap for forced 'ff' and 'fenc'
-static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, bool do_in,
+static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, bool do_in,
bool do_out)
{
- char_u *itmp = NULL;
- char_u *otmp = NULL;
+ char *itmp = NULL;
+ char *otmp = NULL;
linenr_T linecount;
linenr_T read_linecount;
pos_T cursor_save;
- char_u *cmd_buf;
+ char *cmd_buf;
buf_T *old_curbuf = curbuf;
int shell_flags = 0;
const pos_T orig_start = curbuf->b_op_start;
@@ -1330,8 +1330,8 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
curbuf->b_op_start.lnum = line1;
curbuf->b_op_end.lnum = line2;
curwin->w_cursor.lnum = line2;
- } else if ((do_in && (itmp = vim_tempname()) == NULL)
- || (do_out && (otmp = vim_tempname()) == NULL)) {
+ } else if ((do_in && (itmp = (char *)vim_tempname()) == NULL)
+ || (do_out && (otmp = (char *)vim_tempname()) == NULL)) {
emsg(_(e_notmp));
goto filterend;
}
@@ -1340,8 +1340,8 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
* The writing and reading of temp files will not be shown.
* Vi also doesn't do this and the messages are not very informative.
*/
- ++no_wait_return; // don't call wait_return() while busy
- if (itmp != NULL && buf_write(curbuf, itmp, NULL, line1, line2, eap,
+ no_wait_return++; // don't call wait_return() while busy
+ if (itmp != NULL && buf_write(curbuf, (char_u *)itmp, NULL, line1, line2, eap,
false, false, false, true) == FAIL) {
msg_putchar('\n'); // Keep message from buf_write().
no_wait_return--;
@@ -1372,7 +1372,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
read_linecount = curbuf->b_ml.ml_line_count;
// Pass on the kShellOptDoOut flag when the output is being redirected.
- call_shell(cmd_buf, kShellOptFilter | shell_flags, NULL);
+ call_shell((char_u *)cmd_buf, kShellOptFilter | shell_flags, NULL);
xfree(cmd_buf);
did_check_timestamps = FALSE;
@@ -1386,7 +1386,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
if (do_out) {
if (otmp != NULL) {
- if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap,
+ if (readfile((char_u *)otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap,
READ_FILTER, false) != OK) {
if (!aborting()) {
msg_putchar('\n');
@@ -1479,10 +1479,10 @@ filterend:
}
if (itmp != NULL) {
- os_remove((char *)itmp);
+ os_remove(itmp);
}
if (otmp != NULL) {
- os_remove((char *)otmp);
+ os_remove(otmp);
}
xfree(itmp);
xfree(otmp);
@@ -1492,7 +1492,7 @@ filterend:
/// When "cmd" is NULL start an interactive shell.
///
/// @param flags may be SHELL_DOOUT when output is redirected
-void do_shell(char_u *cmd, int flags)
+void do_shell(char *cmd, int flags)
{
// Disallow shell commands from .exrc and .vimrc in current directory for
// security reasons.
@@ -1524,7 +1524,7 @@ void do_shell(char_u *cmd, int flags)
// This ui_cursor_goto is required for when the '\n' resulted in a "delete line
// 1" command to the terminal.
ui_cursor_goto(msg_row, msg_col);
- (void)call_shell(cmd, flags, NULL);
+ (void)call_shell((char_u *)cmd, flags, NULL);
msg_didout = true;
did_check_timestamps = false;
need_check_timestamps = true;
@@ -1563,7 +1563,7 @@ static char *find_pipe(const char *cmd)
/// @param itmp NULL or the input file.
/// @param otmp NULL or the output file.
/// @returns an allocated string with the shell command.
-char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
+char *make_filter_cmd(char *cmd, char *itmp, char *otmp)
{
bool is_fish_shell =
#if defined(UNIX)
@@ -1591,9 +1591,9 @@ char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
if (itmp != NULL || otmp != NULL) {
char *fmt = is_fish_shell ? "begin; %s; end"
: "(%s)";
- vim_snprintf(buf, len, fmt, (char *)cmd);
+ vim_snprintf(buf, len, fmt, cmd);
} else {
- xstrlcpy(buf, (char *)cmd, len);
+ xstrlcpy(buf, cmd, len);
}
if (itmp != NULL) {
@@ -1626,9 +1626,9 @@ char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
}
#endif
if (otmp != NULL) {
- append_redir(buf, len, (char *)p_srr, (char *)otmp);
+ append_redir(buf, len, (char *)p_srr, otmp);
}
- return (char_u *)buf;
+ return buf;
}
/// Append output redirection for the given file to the end of the buffer
@@ -1695,9 +1695,9 @@ void print_line(linenr_T lnum, int use_number, int list)
info_message = false;
}
-int rename_buffer(char_u *new_fname)
+int rename_buffer(char *new_fname)
{
- char_u *fname, *sfname, *xfname;
+ char *fname, *sfname, *xfname;
buf_T *buf;
buf = curbuf;
@@ -1716,19 +1716,19 @@ int rename_buffer(char_u *new_fname)
* But don't set the alternate file name if the buffer didn't have a
* name.
*/
- fname = curbuf->b_ffname;
- sfname = curbuf->b_sfname;
- xfname = curbuf->b_fname;
+ fname = (char *)curbuf->b_ffname;
+ sfname = (char *)curbuf->b_sfname;
+ xfname = (char *)curbuf->b_fname;
curbuf->b_ffname = NULL;
curbuf->b_sfname = NULL;
- if (setfname(curbuf, new_fname, NULL, true) == FAIL) {
- curbuf->b_ffname = fname;
- curbuf->b_sfname = sfname;
+ if (setfname(curbuf, (char_u *)new_fname, NULL, true) == FAIL) {
+ curbuf->b_ffname = (char_u *)fname;
+ curbuf->b_sfname = (char_u *)sfname;
return FAIL;
}
curbuf->b_flags |= BF_NOTEDITED;
if (xfname != NULL && *xfname != NUL) {
- buf = buflist_new(fname, xfname, curwin->w_cursor.lnum, 0);
+ buf = buflist_new((char_u *)fname, (char_u *)xfname, curwin->w_cursor.lnum, 0);
if (buf != NULL && !cmdmod.keepalt) {
curwin->w_alt_fnum = buf->b_fnum;
}
@@ -1755,7 +1755,7 @@ void ex_file(exarg_T *eap)
}
if (*eap->arg != NUL || eap->addr_count == 1) {
- if (rename_buffer(eap->arg) == FAIL) {
+ if (rename_buffer((char *)eap->arg) == FAIL) {
return;
}
redraw_tabline = true;
@@ -1800,10 +1800,10 @@ void ex_write(exarg_T *eap)
int do_write(exarg_T *eap)
{
int other;
- char_u *fname = NULL; // init to shut up gcc
- char_u *ffname;
+ char *fname = NULL; // init to shut up gcc
+ char *ffname;
int retval = FAIL;
- char_u *free_fname = NULL;
+ char *free_fname = NULL;
buf_T *alt_buf = NULL;
int name_was_missing;
@@ -1811,7 +1811,7 @@ int do_write(exarg_T *eap)
return FAIL;
}
- ffname = eap->arg;
+ ffname = (char *)eap->arg;
if (*ffname == NUL) {
if (eap->cmdidx == CMD_saveas) {
emsg(_(e_argreq));
@@ -1820,15 +1820,13 @@ int do_write(exarg_T *eap)
other = FALSE;
} else {
fname = ffname;
- free_fname = (char_u *)fix_fname((char *)ffname);
- /*
- * When out-of-memory, keep unexpanded file name, because we MUST be
- * able to write the file in this situation.
- */
+ free_fname = fix_fname(ffname);
+ // When out-of-memory, keep unexpanded file name, because we MUST be
+ // able to write the file in this situation.
if (free_fname != NULL) {
ffname = free_fname;
}
- other = otherfile(ffname);
+ other = otherfile((char_u *)ffname);
}
/*
@@ -1837,9 +1835,9 @@ int do_write(exarg_T *eap)
if (other) {
if (vim_strchr(p_cpo, CPO_ALTWRITE) != NULL
|| eap->cmdidx == CMD_saveas) {
- alt_buf = setaltfname(ffname, fname, (linenr_T)1);
+ alt_buf = setaltfname((char_u *)ffname, (char_u *)fname, (linenr_T)1);
} else {
- alt_buf = buflist_findname(ffname);
+ alt_buf = buflist_findname((char_u *)ffname);
}
if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL) {
// Overwriting a file that is loaded in another buffer is not a
@@ -1859,11 +1857,9 @@ int do_write(exarg_T *eap)
}
if (!other) {
- ffname = curbuf->b_ffname;
- fname = curbuf->b_fname;
- /*
- * Not writing the whole file is only allowed with '!'.
- */
+ ffname = (char *)curbuf->b_ffname;
+ fname = (char *)curbuf->b_fname;
+ // Not writing the whole file is only allowed with '!'.
if ((eap->line1 != 1
|| eap->line2 != curbuf->b_ml.ml_line_count)
&& !eap->forceit
@@ -1898,15 +1894,15 @@ int do_write(exarg_T *eap)
// under the new name. Must be done before buf_write(), because
// if there is no file name and 'cpo' contains 'F', it will set
// the file name.
- fname = alt_buf->b_fname;
+ fname = (char *)alt_buf->b_fname;
alt_buf->b_fname = curbuf->b_fname;
- curbuf->b_fname = fname;
- fname = alt_buf->b_ffname;
+ curbuf->b_fname = (char_u *)fname;
+ fname = (char *)alt_buf->b_ffname;
alt_buf->b_ffname = curbuf->b_ffname;
- curbuf->b_ffname = fname;
- fname = alt_buf->b_sfname;
+ curbuf->b_ffname = (char_u *)fname;
+ fname = (char *)alt_buf->b_sfname;
alt_buf->b_sfname = curbuf->b_sfname;
- curbuf->b_sfname = fname;
+ curbuf->b_sfname = (char_u *)fname;
buf_name_changed(curbuf);
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf);
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, alt_buf);
@@ -1930,12 +1926,12 @@ int do_write(exarg_T *eap)
// Autocommands may have changed buffer names, esp. when
// 'autochdir' is set.
- fname = curbuf->b_sfname;
+ fname = (char *)curbuf->b_sfname;
}
name_was_missing = curbuf->b_ffname == NULL;
- retval = buf_write(curbuf, ffname, fname, eap->line1, eap->line2,
- eap, eap->append, eap->forceit, TRUE, FALSE);
+ retval = buf_write(curbuf, (char_u *)ffname, (char_u *)fname, eap->line1, eap->line2,
+ eap, eap->append, eap->forceit, true, false);
// After ":saveas fname" reset 'readonly'.
if (eap->cmdidx == CMD_saveas) {
@@ -1966,7 +1962,7 @@ theend:
/// @param other writing under other name
///
/// @return OK if it's OK, FAIL if it is not.
-int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other)
+int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int other)
{
/*
* write to other file or b_flags set or not writing the whole file:
@@ -1979,20 +1975,20 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int
|| (buf->b_flags & BF_READERR))
&& !p_wa
&& !bt_nofile(buf)
- && os_path_exists(ffname)) {
+ && os_path_exists((char_u *)ffname)) {
if (!eap->forceit && !eap->append) {
#ifdef UNIX
// It is possible to open a directory on Unix.
- if (os_isdir(ffname)) {
+ if (os_isdir((char_u *)ffname)) {
semsg(_(e_isadir2), ffname);
return FAIL;
}
#endif
if (p_confirm || cmdmod.confirm) {
- char_u buff[DIALOG_MSG_SIZE];
+ char buff[DIALOG_MSG_SIZE];
- dialog_msg((char *)buff, _("Overwrite existing file \"%s\"?"), (char *)fname);
- if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) {
+ dialog_msg((char *)buff, _("Overwrite existing file \"%s\"?"), fname);
+ if (vim_dialog_yesno(VIM_QUESTION, NULL, (char_u *)buff, 2) != VIM_YES) {
return FAIL;
}
eap->forceit = TRUE;
@@ -2004,9 +2000,9 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int
// For ":w! filename" check that no swap file exists for "filename".
if (other && !emsg_silent) {
- char_u *dir;
- char_u *p;
- char_u *swapname;
+ char *dir;
+ char *p;
+ char *swapname;
// We only try the first entry in 'directory', without checking if
// it's writable. If the "." directory is not writable the write
@@ -2018,19 +2014,19 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int
STRCPY(dir, ".");
} else {
dir = xmalloc(MAXPATHL);
- p = p_dir;
- copy_option_part(&p, dir, MAXPATHL, ",");
+ p = (char *)p_dir;
+ copy_option_part((char_u **)&p, (char_u *)dir, MAXPATHL, ",");
}
- swapname = makeswapname(fname, ffname, curbuf, dir);
+ swapname = (char *)makeswapname((char_u *)fname, (char_u *)ffname, curbuf, (char_u *)dir);
xfree(dir);
- if (os_path_exists(swapname)) {
+ if (os_path_exists((char_u *)swapname)) {
if (p_confirm || cmdmod.confirm) {
- char_u buff[DIALOG_MSG_SIZE];
+ char buff[DIALOG_MSG_SIZE];
dialog_msg((char *)buff,
_("Swap file \"%s\" exists, overwrite anyway?"),
- (char *)swapname);
- if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2)
+ swapname);
+ if (vim_dialog_yesno(VIM_QUESTION, NULL, (char_u *)buff, 2)
!= VIM_YES) {
xfree(swapname);
return FAIL;
@@ -2100,9 +2096,9 @@ void do_wqall(exarg_T *eap)
semsg(_("E141: No file name for buffer %" PRId64), (int64_t)buf->b_fnum);
error++;
} else if (check_readonly(&eap->forceit, buf)
- || check_overwrite(eap, buf, buf->b_fname, buf->b_ffname,
- FALSE) == FAIL) {
- ++error;
+ || check_overwrite(eap, buf, (char *)buf->b_fname, (char *)buf->b_ffname,
+ false) == FAIL) {
+ error++;
} else {
bufref_T bufref;
set_bufref(&bufref, buf);
@@ -2147,7 +2143,7 @@ static int check_readonly(int *forceit, buf_T *buf)
|| (os_path_exists(buf->b_ffname)
&& !os_file_is_writable((char *)buf->b_ffname)))) {
if ((p_confirm || cmdmod.confirm) && buf->b_fname != NULL) {
- char_u buff[DIALOG_MSG_SIZE];
+ char buff[DIALOG_MSG_SIZE];
if (buf->b_p_ro) {
dialog_msg((char *)buff,
@@ -2160,7 +2156,7 @@ static int check_readonly(int *forceit, buf_T *buf)
(char *)buf->b_fname);
}
- if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) == VIM_YES) {
+ if (vim_dialog_yesno(VIM_QUESTION, NULL, (char_u *)buff, 2) == VIM_YES) {
// Set forceit, to force the writing of a readonly file
*forceit = TRUE;
return FALSE;
@@ -2189,13 +2185,13 @@ static int check_readonly(int *forceit, buf_T *buf)
/// GETFILE_NOT_WRITTEN for "not written" error,
/// GETFILE_SAME_FILE for success
/// GETFILE_OPEN_OTHER for successfully opening another file.
-int getfile(int fnum, char_u *ffname_arg, char_u *sfname_arg, int setpm, linenr_T lnum, int forceit)
+int getfile(int fnum, char *ffname_arg, char *sfname_arg, int setpm, linenr_T lnum, int forceit)
{
- char_u *ffname = ffname_arg;
- char_u *sfname = sfname_arg;
+ char *ffname = ffname_arg;
+ char *sfname = sfname_arg;
int other;
int retval;
- char_u *free_me = NULL;
+ char *free_me = NULL;
if (text_locked()) {
return GETFILE_ERROR;
@@ -2206,8 +2202,8 @@ int getfile(int fnum, char_u *ffname_arg, char_u *sfname_arg, int setpm, linenr_
if (fnum == 0) {
// make ffname full path, set sfname
- fname_expand(curbuf, &ffname, &sfname);
- other = otherfile(ffname);
+ fname_expand(curbuf, (char_u **)&ffname, (char_u **)&sfname);
+ other = otherfile((char_u *)ffname);
free_me = ffname; // has been allocated, free() later
} else {
other = (fnum != curbuf->b_fnum);
@@ -2284,19 +2280,19 @@ theend:
/// info of the previous buffer for "oldwin" is stored.
///
/// @return FAIL for failure, OK otherwise
-int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags,
+int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum, int flags,
win_T *oldwin)
{
bool other_file; // true if editing another file
int oldbuf; // TRUE if using existing buffer
bool auto_buf = false; // true if autocommands brought us
// into the buffer unexpectedly
- char_u *new_name = NULL;
+ char *new_name = NULL;
bool did_set_swapcommand = false;
buf_T *buf;
bufref_T bufref;
bufref_T old_curbuf;
- char_u *free_fname = NULL;
+ char *free_fname = NULL;
int retval = FAIL;
long n;
pos_T orig_pos;
@@ -2304,14 +2300,14 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
int newcol = -1;
int solcol = -1;
pos_T *pos;
- char_u *command = NULL;
+ char *command = NULL;
bool did_get_winopts = false;
int readfile_flags = 0;
bool did_inc_redrawing_disabled = false;
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
if (eap != NULL) {
- command = eap->do_ecmd_cmd;
+ command = (char *)eap->do_ecmd_cmd;
}
set_bufref(&old_curbuf, curbuf);
@@ -2328,7 +2324,7 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
}
#ifdef USE_FNAME_CASE
if (sfname != NULL) {