refactor: replace char_u with char 4 (#19987)

* refactor: replace char_u with char

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
dundargoc 2022-08-30 14:52:09 +02:00 committed by GitHub
parent 9397e70b9e
commit 2828aae7b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 499 additions and 509 deletions

View File

@ -653,9 +653,9 @@ void ins_char_bytes(char *buf, size_t charlen)
// cells. May result in adding spaces to fill a gap. // cells. May result in adding spaces to fill a gap.
colnr_T vcol; colnr_T vcol;
getvcol(curwin, &curwin->w_cursor, NULL, &vcol, NULL); getvcol(curwin, &curwin->w_cursor, NULL, &vcol, NULL);
colnr_T new_vcol = vcol + win_chartabsize(curwin, (char *)buf, vcol); colnr_T new_vcol = vcol + win_chartabsize(curwin, buf, vcol);
while (oldp[col + oldlen] != NUL && vcol < new_vcol) { while (oldp[col + oldlen] != NUL && vcol < new_vcol) {
vcol += win_chartabsize(curwin, (char *)oldp + col + oldlen, vcol); vcol += win_chartabsize(curwin, oldp + col + oldlen, vcol);
// Don't need to remove a TAB that takes us to the right // Don't need to remove a TAB that takes us to the right
// position. // position.
if (vcol > new_vcol && oldp[col + oldlen] == TAB) { if (vcol > new_vcol && oldp[col + oldlen] == TAB) {

View File

@ -1157,7 +1157,7 @@ char *skipwhite(const char *const p)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_RET
{ {
return (char *)skipwhite_len((char_u *)p, STRLEN(p)); return skipwhite_len(p, STRLEN(p));
} }
/// Like `skipwhite`, but skip up to `len` characters. /// Like `skipwhite`, but skip up to `len` characters.
@ -1168,27 +1168,27 @@ char *skipwhite(const char *const p)
/// ///
/// @return Pointer to character after the skipped whitespace, or the `len`-th /// @return Pointer to character after the skipped whitespace, or the `len`-th
/// character in the string. /// character in the string.
char_u *skipwhite_len(const char_u *p, size_t len) char *skipwhite_len(const char *p, size_t len)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_RET
{ {
for (; len > 0 && ascii_iswhite(*p); len--) { for (; len > 0 && ascii_iswhite(*p); len--) {
p++; p++;
} }
return (char_u *)p; return (char *)p;
} }
// getwhitecols: return the number of whitespace // getwhitecols: return the number of whitespace
// columns (bytes) at the start of a given line // columns (bytes) at the start of a given line
intptr_t getwhitecols_curline(void) intptr_t getwhitecols_curline(void)
{ {
return getwhitecols(get_cursor_line_ptr()); return getwhitecols((char *)get_cursor_line_ptr());
} }
intptr_t getwhitecols(const char_u *p) intptr_t getwhitecols(const char *p)
FUNC_ATTR_PURE FUNC_ATTR_PURE
{ {
return (char_u *)skipwhite((char *)p) - p; return skipwhite(p) - p;
} }
/// Skip over digits /// Skip over digits
@ -1232,10 +1232,10 @@ const char *skipbin(const char *q)
/// ///
/// @return Pointer to the character after the skipped digits and hex /// @return Pointer to the character after the skipped digits and hex
/// characters. /// characters.
char_u *skiphex(char_u *q) char *skiphex(char *q)
FUNC_ATTR_PURE FUNC_ATTR_PURE
{ {
char_u *p = q; char *p = q;
while (ascii_isxdigit(*p)) { while (ascii_isxdigit(*p)) {
// skip to next non-digit // skip to next non-digit
p++; p++;
@ -1248,10 +1248,10 @@ char_u *skiphex(char_u *q)
/// @param q /// @param q
/// ///
/// @return Pointer to the digit or (NUL after the string). /// @return Pointer to the digit or (NUL after the string).
char_u *skiptodigit(char_u *q) char *skiptodigit(char *q)
FUNC_ATTR_PURE FUNC_ATTR_PURE
{ {
char_u *p = q; char *p = q;
while (*p != NUL && !ascii_isdigit(*p)) { while (*p != NUL && !ascii_isdigit(*p)) {
// skip to next digit // skip to next digit
p++; p++;
@ -1282,10 +1282,10 @@ const char *skiptobin(const char *q)
/// @param q /// @param q
/// ///
/// @return Pointer to the hex character or (NUL after the string). /// @return Pointer to the hex character or (NUL after the string).
char_u *skiptohex(char_u *q) char *skiptohex(char *q)
FUNC_ATTR_PURE FUNC_ATTR_PURE
{ {
char_u *p = q; char *p = q;
while (*p != NUL && !ascii_isxdigit(*p)) { while (*p != NUL && !ascii_isxdigit(*p)) {
// skip to next digit // skip to next digit
p++; p++;
@ -1298,13 +1298,13 @@ char_u *skiptohex(char_u *q)
/// @param[in] p Text to skip over. /// @param[in] p Text to skip over.
/// ///
/// @return Pointer to the next whitespace or NUL character. /// @return Pointer to the next whitespace or NUL character.
char_u *skiptowhite(const char_u *p) char *skiptowhite(const char *p)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
{ {
while (*p != ' ' && *p != '\t' && *p != NUL) { while (*p != ' ' && *p != '\t' && *p != NUL) {
p++; p++;
} }
return (char_u *)p; return (char *)p;
} }
/// skiptowhite_esc: Like skiptowhite(), but also skip escaped chars /// skiptowhite_esc: Like skiptowhite(), but also skip escaped chars
@ -1329,11 +1329,11 @@ char *skiptowhite_esc(char *p)
/// @param[in] p Text to skip over. /// @param[in] p Text to skip over.
/// ///
/// @return Pointer to the next '\n' or NUL character. /// @return Pointer to the next '\n' or NUL character.
char_u *skip_to_newline(const char_u *const p) char *skip_to_newline(const char *const p)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_RET
{ {
return (char_u *)xstrchrnul((const char *)p, NL); return xstrchrnul(p, NL);
} }
/// Gets a number from a string and skips over it, signalling overflow. /// Gets a number from a string and skips over it, signalling overflow.
@ -1422,10 +1422,10 @@ int32_t getdigits_int32(char **pp, bool strict, long def)
/// Check that "lbuf" is empty or only contains blanks. /// Check that "lbuf" is empty or only contains blanks.
/// ///
/// @param lbuf line buffer to check /// @param lbuf line buffer to check
bool vim_isblankline(char_u *lbuf) bool vim_isblankline(char *lbuf)
FUNC_ATTR_PURE FUNC_ATTR_PURE
{ {
char_u *p = (char_u *)skipwhite((char *)lbuf); char *p = skipwhite(lbuf);
return *p == NUL || *p == '\r' || *p == '\n'; return *p == NUL || *p == '\r' || *p == '\n';
} }
@ -1664,8 +1664,9 @@ int hex2nr(int c)
} }
/// Convert two hex characters to a byte. /// Convert two hex characters to a byte.
/// Return -1 if one of the characters is not hex. ///
int hexhex2nr(const char_u *p) /// @return -1 if one of the characters is not hex.
int hexhex2nr(const char *p)
FUNC_ATTR_PURE FUNC_ATTR_PURE
{ {
if (!ascii_isxdigit(p[0]) || !ascii_isxdigit(p[1])) { if (!ascii_isxdigit(p[0]) || !ascii_isxdigit(p[1])) {
@ -1707,10 +1708,10 @@ bool rem_backslash(const char *str)
/// Halve the number of backslashes in a file name argument. /// Halve the number of backslashes in a file name argument.
/// ///
/// @param p /// @param p
void backslash_halve(char_u *p) void backslash_halve(char *p)
{ {
for (; *p; p++) { for (; *p; p++) {
if (rem_backslash((char *)p)) { if (rem_backslash(p)) {
STRMOVE(p, p + 1); STRMOVE(p, p + 1);
} }
} }
@ -1721,11 +1722,11 @@ void backslash_halve(char_u *p)
/// @param p /// @param p
/// ///
/// @return String with the number of backslashes halved. /// @return String with the number of backslashes halved.
char_u *backslash_halve_save(const char_u *p) char *backslash_halve_save(const char *p)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
{ {
// TODO(philix): simplify and improve backslash_halve_save algorithm // TODO(philix): simplify and improve backslash_halve_save algorithm
char_u *res = vim_strsave(p); char *res = xstrdup(p);
backslash_halve(res); backslash_halve(res);
return res; return res;
} }

View File

@ -387,7 +387,7 @@ static char_u *ExpandOne_start(int mode, expand_T *xp, char_u *str, int options)
} }
/// Return the longest common part in the list of cmdline completion matches. /// Return the longest common part in the list of cmdline completion matches.
static char_u *find_longest_match(expand_T *xp, int options) static char *find_longest_match(expand_T *xp, int options)
{ {
size_t len = 0; size_t len = 0;
@ -417,7 +417,7 @@ static char_u *find_longest_match(expand_T *xp, int options)
} }
} }
return (char_u *)xstrndup(xp->xp_files[0], len); return xstrndup(xp->xp_files[0], len);
} }
/// Do wildcard expansion on the string 'str'. /// Do wildcard expansion on the string 'str'.
@ -500,7 +500,7 @@ char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode
// Find longest common part // Find longest common part
if (mode == WILD_LONGEST && xp->xp_numfiles > 0) { if (mode == WILD_LONGEST && xp->xp_numfiles > 0) {
ss = find_longest_match(xp, options); ss = (char_u *)find_longest_match(xp, options);
findex = -1; // next p_wc gets first one findex = -1; // next p_wc gets first one
} }
@ -670,7 +670,7 @@ int showmatches(expand_T *xp, int wildmenu)
lastlen = 999; lastlen = 999;
for (k = i; k < num_files; k += lines) { for (k = i; k < num_files; k += lines) {
if (xp->xp_context == EXPAND_TAGS_LISTFILES) { if (xp->xp_context == EXPAND_TAGS_LISTFILES) {
msg_outtrans_attr((char_u *)files_found[k], HL_ATTR(HLF_D)); msg_outtrans_attr(files_found[k], HL_ATTR(HLF_D));
p = (char_u *)files_found[k] + STRLEN(files_found[k]) + 1; p = (char_u *)files_found[k] + STRLEN(files_found[k]) + 1;
msg_advance(maxlen + 1); msg_advance(maxlen + 1);
msg_puts((const char *)p); msg_puts((const char *)p);
@ -691,15 +691,15 @@ int showmatches(expand_T *xp, int wildmenu)
// $HOME has been replaced with ~/. // $HOME has been replaced with ~/.
char_u *exp_path = expand_env_save_opt((char_u *)files_found[k], true); char_u *exp_path = expand_env_save_opt((char_u *)files_found[k], true);
char_u *path = exp_path != NULL ? exp_path : (char_u *)files_found[k]; char_u *path = exp_path != NULL ? exp_path : (char_u *)files_found[k];
char_u *halved_slash = backslash_halve_save(path); char_u *halved_slash = (char_u *)backslash_halve_save((char *)path);
j = os_isdir(halved_slash); j = os_isdir((char *)halved_slash);
xfree(exp_path); xfree(exp_path);
if (halved_slash != path) { if (halved_slash != path) {
xfree(halved_slash); xfree(halved_slash);
} }
} else { } else {
// Expansion was done here, file names are literal. // Expansion was done here, file names are literal.
j = os_isdir((char_u *)files_found[k]); j = os_isdir(files_found[k]);
} }
if (showtail) { if (showtail) {
p = (char_u *)L_SHOWFILE(k); p = (char_u *)L_SHOWFILE(k);
@ -711,7 +711,7 @@ int showmatches(expand_T *xp, int wildmenu)
j = false; j = false;
p = (char_u *)L_SHOWFILE(k); p = (char_u *)L_SHOWFILE(k);
} }
lastlen = msg_outtrans_attr(p, j ? attr : 0); lastlen = msg_outtrans_attr((char *)p, j ? attr : 0);
} }
if (msg_col > 0) { // when not wrapped around if (msg_col > 0) { // when not wrapped around
msg_clr_eos(); msg_clr_eos();
@ -1239,7 +1239,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons
if (*arg == NUL || !ends_excmd(*arg)) { if (*arg == NUL || !ends_excmd(*arg)) {
// also complete "None" // also complete "None"
set_context_in_echohl_cmd(xp, arg); set_context_in_echohl_cmd(xp, arg);
arg = (const char *)skipwhite((char *)skiptowhite((const char_u *)arg)); arg = (const char *)skipwhite(skiptowhite(arg));
if (*arg != NUL) { if (*arg != NUL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
arg = (const char *)skip_regexp((char *)arg + 1, (uint8_t)(*arg), p_magic, NULL); arg = (const char *)skip_regexp((char *)arg + 1, (uint8_t)(*arg), p_magic, NULL);
@ -1592,7 +1592,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons
#ifdef HAVE_WORKING_LIBINTL #ifdef HAVE_WORKING_LIBINTL
case CMD_language: case CMD_language:
p = (const char *)skiptowhite((const char_u *)arg); p = (const char *)skiptowhite(arg);
if (*p == NUL) { if (*p == NUL) {
xp->xp_context = EXPAND_LANGUAGE; xp->xp_context = EXPAND_LANGUAGE;
xp->xp_pattern = (char *)arg; xp->xp_pattern = (char *)arg;
@ -2161,19 +2161,19 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***f
} }
if (xp->xp_context == EXPAND_COLORS) { if (xp->xp_context == EXPAND_COLORS) {
char *directories[] = { "colors", NULL }; char *directories[] = { "colors", NULL };
return ExpandRTDir(pat, DIP_START + DIP_OPT + DIP_LUA, num_file, file, directories); return ExpandRTDir((char *)pat, DIP_START + DIP_OPT + DIP_LUA, num_file, file, directories);
} }
if (xp->xp_context == EXPAND_COMPILER) { if (xp->xp_context == EXPAND_COMPILER) {
char *directories[] = { "compiler", NULL }; char *directories[] = { "compiler", NULL };
return ExpandRTDir(pat, DIP_LUA, num_file, file, directories); return ExpandRTDir((char *)pat, DIP_LUA, num_file, file, directories);
} }
if (xp->xp_context == EXPAND_OWNSYNTAX) { if (xp->xp_context == EXPAND_OWNSYNTAX) {
char *directories[] = { "syntax", NULL }; char *directories[] = { "syntax", NULL };
return ExpandRTDir(pat, 0, num_file, file, directories); return ExpandRTDir((char *)pat, 0, num_file, file, directories);
} }
if (xp->xp_context == EXPAND_FILETYPE) { if (xp->xp_context == EXPAND_FILETYPE) {
char *directories[] = { "syntax", "indent", "ftplugin", NULL }; char *directories[] = { "syntax", "indent", "ftplugin", NULL };
return ExpandRTDir(pat, DIP_LUA, num_file, file, directories); return ExpandRTDir((char *)pat, DIP_LUA, num_file, file, directories);
} }
if (xp->xp_context == EXPAND_USER_LIST) { if (xp->xp_context == EXPAND_USER_LIST) {
return ExpandUserList(xp, num_file, file); return ExpandUserList(xp, num_file, file);
@ -2182,7 +2182,7 @@ static int ExpandFromContext(expand_T *xp, char_u *pat, int *num_file, char ***f
return ExpandUserLua(xp, num_file, file); return ExpandUserLua(xp, num_file, file);
} }
if (xp->xp_context == EXPAND_PACKADD) { if (xp->xp_context == EXPAND_PACKADD) {
return ExpandPackAddDir(pat, num_file, file); return ExpandPackAddDir((char *)pat, num_file, file);
} }
// When expanding a function name starting with s:, match the <SNR>nr_ // When expanding a function name starting with s:, match the <SNR>nr_
@ -2573,7 +2573,7 @@ static int ExpandUserLua(expand_T *xp, int *num_file, char ***file)
/// Expand `file` for all comma-separated directories in `path`. /// Expand `file` for all comma-separated directories in `path`.
/// Adds matches to `ga`. /// Adds matches to `ga`.
void globpath(char *path, char_u *file, garray_T *ga, int expand_options) void globpath(char *path, char *file, garray_T *ga, int expand_options)
{ {
expand_T xpc; expand_T xpc;
ExpandInit(&xpc); ExpandInit(&xpc);

View File

@ -718,9 +718,9 @@ void ex_breaklist(exarg_T *eap)
/// @param file true for a file, false for a function /// @param file true for a file, false for a function
/// @param fname file or function name /// @param fname file or function name
/// @param after after this line number /// @param after after this line number
linenr_T dbg_find_breakpoint(bool file, char_u *fname, linenr_T after) linenr_T dbg_find_breakpoint(bool file, char *fname, linenr_T after)
{ {
return debuggy_find(file, fname, after, &dbg_breakp, NULL); return debuggy_find(file, (char_u *)fname, after, &dbg_breakp, NULL);
} }
/// @param file true for a file, false for a function /// @param file true for a file, false for a function
@ -728,9 +728,9 @@ linenr_T dbg_find_breakpoint(bool file, char_u *fname, linenr_T after)
/// @param fp[out] forceit /// @param fp[out] forceit
/// ///
/// @returns true if profiling is on for a function or sourced file. /// @returns true if profiling is on for a function or sourced file.
bool has_profiling(bool file, char_u *fname, bool *fp) bool has_profiling(bool file, char *fname, bool *fp)
{ {
return debuggy_find(file, fname, (linenr_T)0, &prof_ga, fp) return debuggy_find(file, (char_u *)fname, (linenr_T)0, &prof_ga, fp)
!= (linenr_T)0; != (linenr_T)0;
} }
@ -825,9 +825,9 @@ static linenr_T debuggy_find(bool file, char_u *fname, linenr_T after, garray_T
} }
/// Called when a breakpoint was encountered. /// Called when a breakpoint was encountered.
void dbg_breakpoint(char_u *name, linenr_T lnum) void dbg_breakpoint(char *name, linenr_T lnum)
{ {
// We need to check if this line is actually executed in do_one_cmd() // We need to check if this line is actually executed in do_one_cmd()
debug_breakpoint_name = name; debug_breakpoint_name = (char_u *)name;
debug_breakpoint_lnum = lnum; debug_breakpoint_lnum = lnum;
} }

View File

@ -1695,7 +1695,7 @@ static void digraph_header(const char *msg)
if (msg_col > 0) { if (msg_col > 0) {
msg_putchar('\n'); msg_putchar('\n');
} }
msg_outtrans_attr((const char_u *)msg, HL_ATTR(HLF_CM)); msg_outtrans_attr(msg, HL_ATTR(HLF_CM));
msg_putchar('\n'); msg_putchar('\n');
} }
@ -1856,7 +1856,7 @@ static void printdigraph(const digr_T *dp, result_T *previous)
p += utf_char2bytes(dp->result, (char *)p); p += utf_char2bytes(dp->result, (char *)p);
*p = NUL; *p = NUL;
msg_outtrans_attr(buf, HL_ATTR(HLF_8)); msg_outtrans_attr((char *)buf, HL_ATTR(HLF_8));
p = buf; p = buf;
if (char2cells(dp->result) == 1) { if (char2cells(dp->result) == 1) {
*p++ = ' '; *p++ = ' ';
@ -2096,10 +2096,10 @@ void ex_loadkeymap(exarg_T *eap)
if ((*p != '"') && (*p != NUL)) { if ((*p != '"') && (*p != NUL)) {
kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga); kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga);
s = skiptowhite(p); s = (char_u *)skiptowhite((char *)p);
kp->from = vim_strnsave(p, (size_t)(s - p)); kp->from = vim_strnsave(p, (size_t)(s - p));
p = (char_u *)skipwhite((char *)s); p = (char_u *)skipwhite((char *)s);
s = skiptowhite(p); s = (char_u *)skiptowhite((char *)p);
kp->to = vim_strnsave(p, (size_t)(s - p)); kp->to = vim_strnsave(p, (size_t)(s - p));
if ((STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN) if ((STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN)

View File

@ -870,7 +870,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
if (has_spell && !number_only) { if (has_spell && !number_only) {
// For checking first word with a capital skip white space. // For checking first word with a capital skip white space.
if (cap_col == 0) { if (cap_col == 0) {
cap_col = (int)getwhitecols(line); cap_col = (int)getwhitecols((char *)line);
} }
// To be able to spell-check over line boundaries copy the end of the // To be able to spell-check over line boundaries copy the end of the
@ -1171,7 +1171,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
if (wp->w_p_rl) { // reverse line numbers if (wp->w_p_rl) { // reverse line numbers
// like rl_mirror(), but keep the space at the end // like rl_mirror(), but keep the space at the end
char_u *p2 = (char_u *)skipwhite((char *)extra); char_u *p2 = (char_u *)skipwhite((char *)extra);
p2 = skiptowhite(p2) - 1; p2 = (char_u *)skiptowhite((char *)p2) - 1;
for (char_u *p1 = (char_u *)skipwhite((char *)extra); p1 < p2; p1++, p2--) { for (char_u *p1 = (char_u *)skipwhite((char *)extra); p1 < p2; p1++, p2--) {
const char_u t = *p1; const char_u t = *p1;
*p1 = *p2; *p1 = *p2;

View File

@ -2698,12 +2698,12 @@ int cursor_down(long n, int upd_topline)
/// @param no_esc Don't add an ESC at the end /// @param no_esc Don't add an ESC at the end
int stuff_inserted(int c, long count, int no_esc) int stuff_inserted(int c, long count, int no_esc)
{ {
char_u *esc_ptr; char *esc_ptr;
char_u *ptr; char *ptr;
char_u *last_ptr; char *last_ptr;
char_u last = NUL; char last = NUL;
ptr = get_last_insert(); ptr = (char *)get_last_insert();
if (ptr == NULL) { if (ptr == NULL) {
emsg(_(e_noinstext)); emsg(_(e_noinstext));
return FAIL; return FAIL;
@ -2713,7 +2713,7 @@ int stuff_inserted(int c, long count, int no_esc)
if (c != NUL) { if (c != NUL) {
stuffcharReadbuff(c); stuffcharReadbuff(c);
} }
if ((esc_ptr = STRRCHR(ptr, ESC)) != NULL) { if ((esc_ptr = strrchr(ptr, ESC)) != NULL) {
// remove the ESC. // remove the ESC.
*esc_ptr = NUL; *esc_ptr = NUL;
} }

View File

@ -2042,7 +2042,7 @@ void set_context_for_expression(expand_T *xp, char *arg, cmdidx_T cmdidx)
|| cmdidx == CMD_echomsg) || cmdidx == CMD_echomsg)
&& xp->xp_context == EXPAND_EXPRESSION) { && xp->xp_context == EXPAND_EXPRESSION) {
for (;;) { for (;;) {
char *const n = (char *)skiptowhite((char_u *)arg); char *const n = skiptowhite(arg);
if (n == arg || ascii_iswhite_or_nul(*skipwhite(n))) { if (n == arg || ascii_iswhite_or_nul(*skipwhite(n))) {
break; break;
@ -2658,7 +2658,7 @@ static int eval5(char **arg, typval_T *rettv, int evaluate)
tv_clear(&var2); tv_clear(&var2);
return FAIL; return FAIL;
} }
p = (char *)concat_str((const char_u *)s1, (const char_u *)s2); p = concat_str(s1, s2);
tv_clear(rettv); tv_clear(rettv);
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = p; rettv->vval.v_string = p;
@ -7400,7 +7400,7 @@ hashtab_T *find_var_ht_dict(const char *name, const size_t name_len, const char
bool should_free; bool should_free;
// should_free is ignored as script_sctx will be resolved to a fnmae // should_free is ignored as script_sctx will be resolved to a fnmae
// & new_script_item will consume it. // & new_script_item will consume it.
char *sc_name = (char *)get_scriptname(last_set, &should_free); char *sc_name = get_scriptname(last_set, &should_free);
new_script_item(sc_name, &current_sctx.sc_sid); new_script_item(sc_name, &current_sctx.sc_sid);
} }
} }
@ -7527,9 +7527,9 @@ int var_item_copy(const vimconv_T *const conv, typval_T *const from, typval_T *c
} else { } else {
to->v_type = VAR_STRING; to->v_type = VAR_STRING;
to->v_lock = VAR_UNLOCKED; to->v_lock = VAR_UNLOCKED;
if ((to->vval.v_string = (char *)string_convert((vimconv_T *)conv, if ((to->vval.v_string = string_convert((vimconv_T *)conv,
(char_u *)from->vval.v_string, from->vval.v_string,
NULL)) NULL))
== NULL) { == NULL) {
to->vval.v_string = xstrdup(from->vval.v_string); to->vval.v_string = xstrdup(from->vval.v_string);
} }
@ -7980,7 +7980,7 @@ void option_last_set_msg(LastSet last_set)
{ {
if (last_set.script_ctx.sc_sid != 0) { if (last_set.script_ctx.sc_sid != 0) {
bool should_free; bool should_free;
char *p = (char *)get_scriptname(last_set, &should_free); char *p = get_scriptname(last_set, &should_free);
verbose_enter(); verbose_enter();
msg_puts(_("\n\tLast set from ")); msg_puts(_("\n\tLast set from "));
msg_puts(p); msg_puts(p);
@ -8077,7 +8077,7 @@ repeat:
} }
// Append a path separator to a directory. // Append a path separator to a directory.
if (os_isdir((char_u *)(*fnamep))) { if (os_isdir(*fnamep)) {
// Make room for one or two extra characters. // Make room for one or two extra characters.
*fnamep = xstrnsave(*fnamep, STRLEN(*fnamep) + 2); *fnamep = xstrnsave(*fnamep, STRLEN(*fnamep) + 2);
xfree(*bufp); // free any allocated file name xfree(*bufp); // free any allocated file name

View File

@ -108,8 +108,7 @@ int eexe_mod_op(typval_T *const tv1, const typval_T *const tv2, const char *cons
const char *tvs = tv_get_string(tv1); const char *tvs = tv_get_string(tv1);
char numbuf[NUMBUFLEN]; char numbuf[NUMBUFLEN];
char *const s = char *const s =
(char *)concat_str((const char_u *)tvs, (const char_u *)tv_get_string_buf(tv2, concat_str(tvs, tv_get_string_buf(tv2, numbuf));
numbuf));
tv_clear(tv1); tv_clear(tv1);
tv1->v_type = VAR_STRING; tv1->v_type = VAR_STRING;
tv1->vval.v_string = s; tv1->vval.v_string = s;

View File

@ -2210,7 +2210,7 @@ static void f_filereadable(typval_T *argvars, typval_T *rettv, EvalFuncData fptr
{ {
const char *const p = tv_get_string(&argvars[0]); const char *const p = tv_get_string(&argvars[0]);
rettv->vval.v_number = rettv->vval.v_number =
(*p && !os_isdir((const char_u *)p) && os_file_is_readable(p)); (*p && !os_isdir(p) && os_file_is_readable(p));
} }
/// @return 0 for not writable /// @return 0 for not writable
@ -2888,7 +2888,7 @@ static void f_getfsize(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
FileInfo file_info; FileInfo file_info;
if (os_fileinfo(fname, &file_info)) { if (os_fileinfo(fname, &file_info)) {
uint64_t filesize = os_fileinfo_size(&file_info); uint64_t filesize = os_fileinfo_size(&file_info);
if (os_isdir((const char_u *)fname)) { if (os_isdir(fname)) {
rettv->vval.v_number = 0; rettv->vval.v_number = 0;
} else { } else {
rettv->vval.v_number = (varnumber_T)filesize; rettv->vval.v_number = (varnumber_T)filesize;
@ -3491,7 +3491,7 @@ static void f_globpath(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (file != NULL && !error) { if (file != NULL && !error) {
garray_T ga; garray_T ga;
ga_init(&ga, (int)sizeof(char_u *), 10); ga_init(&ga, (int)sizeof(char_u *), 10);
globpath((char *)tv_get_string(&argvars[0]), (char_u *)file, &ga, flags); globpath((char *)tv_get_string(&argvars[0]), (char *)file, &ga, flags);
if (rettv->v_type == VAR_STRING) { if (rettv->v_type == VAR_STRING) {
rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n"); rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n");
@ -3874,7 +3874,7 @@ static void f_iconv(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (vimconv.vc_type == CONV_NONE) { if (vimconv.vc_type == CONV_NONE) {
rettv->vval.v_string = xstrdup(str); rettv->vval.v_string = xstrdup(str);
} else { } else {
rettv->vval.v_string = (char *)string_convert(&vimconv, (char_u *)str, NULL); rettv->vval.v_string = string_convert(&vimconv, (char *)str, NULL);
} }
convert_setup(&vimconv, NULL, NULL); convert_setup(&vimconv, NULL, NULL);
@ -4131,7 +4131,7 @@ static void f_invert(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
/// "isdirectory()" function /// "isdirectory()" function
static void f_isdirectory(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) static void f_isdirectory(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{ {
rettv->vval.v_number = os_isdir((const char_u *)tv_get_string(&argvars[0])); rettv->vval.v_number = os_isdir(tv_get_string(&argvars[0]));
} }
/// "islocked()" function /// "islocked()" function
@ -4458,7 +4458,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (new_cwd && *new_cwd != NUL) { if (new_cwd && *new_cwd != NUL) {
cwd = new_cwd; cwd = new_cwd;
// The new cwd must be a directory. // The new cwd must be a directory.
if (!os_isdir((const char_u *)cwd)) { if (!os_isdir(cwd)) {
semsg(_(e_invarg2), "expected valid directory"); semsg(_(e_invarg2), "expected valid directory");
shell_free_argv(argv); shell_free_argv(argv);
return; return;
@ -5891,7 +5891,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
// their own about CR-LF conversion. // their own about CR-LF conversion.
const char *const fname = tv_get_string(&argvars[0]); const char *const fname = tv_get_string(&argvars[0]);
if (os_isdir((const char_u *)fname)) { if (os_isdir(fname)) {
semsg(_(e_isadir2), fname); semsg(_(e_isadir2), fname);
return; return;
} }
@ -6343,7 +6343,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (*q != NUL) { if (*q != NUL) {
cpy = remain; cpy = remain;
remain = (remain remain = (remain
? (char *)concat_str((char_u *)q - 1, (char_u *)remain) ? concat_str(q - 1, remain)
: xstrdup(q - 1)); : xstrdup(q - 1));
xfree(cpy); xfree(cpy);
q[-1] = NUL; q[-1] = NUL;
@ -6402,7 +6402,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
&& (p[2] == NUL && (p[2] == NUL
|| vim_ispathsep(p[2])))))) { || vim_ispathsep(p[2])))))) {
// Prepend "./". // Prepend "./".
cpy = (char *)concat_str((const char_u *)"./", (const char_u *)p); cpy = concat_str("./", p);
xfree(p); xfree(p);
p = cpy; p = cpy;
} else if (!is_relative_to_current) { } else if (!is_relative_to_current) {
@ -8339,7 +8339,7 @@ static void f_strftime(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
char *enc = (char *)enc_locale(); char *enc = (char *)enc_locale();
convert_setup(&conv, p_enc, enc); convert_setup(&conv, p_enc, enc);
if (conv.vc_type != CONV_NONE) { if (conv.vc_type != CONV_NONE) {
p = (char *)string_convert(&conv, (char_u *)p, NULL); p = string_convert(&conv, p, NULL);
} }
char result_buf[256]; char result_buf[256];
if (p != NULL) { if (p != NULL) {
@ -8353,7 +8353,7 @@ static void f_strftime(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
} }
convert_setup(&conv, enc, p_enc); convert_setup(&conv, enc, p_enc);
if (conv.vc_type != CONV_NONE) { if (conv.vc_type != CONV_NONE) {
rettv->vval.v_string = (char *)string_convert(&conv, (char_u *)result_buf, NULL); rettv->vval.v_string = string_convert(&conv, result_buf, NULL);
} else { } else {
rettv->vval.v_string = xstrdup(result_buf); rettv->vval.v_string = xstrdup(result_buf);
} }
@ -8599,7 +8599,7 @@ static void f_strptime(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
char *enc = (char *)enc_locale(); char *enc = (char *)enc_locale();
convert_setup(&conv, p_enc, enc); convert_setup(&conv, p_enc, enc);
if (conv.vc_type != CONV_NONE) { if (conv.vc_type != CONV_NONE) {
fmt = (char *)string_convert(&conv, (char_u *)fmt, NULL); fmt = string_convert(&conv, fmt, NULL);
} }
if (fmt == NULL if (fmt == NULL
|| os_strptime(str, fmt, &tmval) == NULL || os_strptime(str, fmt, &tmval) == NULL
@ -9070,7 +9070,7 @@ static void f_tagfiles(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
bool first = true; bool first = true;
tagname_T tn; tagname_T tn;
while (get_tagfname(&tn, first, (char_u *)fname) == OK) { while (get_tagfname(&tn, first, fname) == OK) {
tv_list_append_string(rettv->vval.v_list, fname, -1); tv_list_append_string(rettv->vval.v_list, fname, -1);
first = false; first = false;
} }
@ -9148,7 +9148,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (new_cwd && *new_cwd != NUL) { if (new_cwd && *new_cwd != NUL) {
cwd = new_cwd; cwd = new_cwd;
// The new cwd must be a directory. // The new cwd must be a directory.
if (!os_isdir((const char_u *)cwd)) { if (!os_isdir(cwd)) {
semsg(_(e_invarg2), "expected valid directory"); semsg(_(e_invarg2), "expected valid directory");
shell_free_argv(argv); shell_free_argv(argv);
return; return;

View File

@ -2533,7 +2533,7 @@ dict_T *tv_dict_copy(const vimconv_T *const conv, dict_T *const orig, const bool
new_di = tv_dict_item_alloc((const char *)di->di_key); new_di = tv_dict_item_alloc((const char *)di->di_key);
} else { } else {
size_t len = STRLEN(di->di_key); size_t len = STRLEN(di->di_key);
char *const key = (char *)string_convert(conv, di->di_key, &len); char *const key = (char *)string_convert(conv, (char *)di->di_key, &len);
if (key == NULL) { if (key == NULL) {
new_di = tv_dict_item_alloc_len((const char *)di->di_key, len); new_di = tv_dict_item_alloc_len((const char *)di->di_key, len);
} else { } else {

View File

@ -409,7 +409,7 @@ void emsg_funcname(char *ermsg, const char_u *name)
char_u *p; char_u *p;
if (*name == K_SPECIAL) { if (*name == K_SPECIAL) {
p = concat_str((char_u *)"<SNR>", name + 3); p = (char_u *)concat_str("<SNR>", (char *)name + 3);
} else { } else {
p = (char_u *)name; p = (char_u *)name;
} }
@ -863,7 +863,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
fc->rettv = rettv; fc->rettv = rettv;
fc->level = ex_nesting_level; fc->level = ex_nesting_level;
// Check if this function has a breakpoint. // Check if this function has a breakpoint.
fc->breakpoint = dbg_find_breakpoint(false, fp->uf_name, (linenr_T)0); fc->breakpoint = dbg_find_breakpoint(false, (char *)fp->uf_name, (linenr_T)0);
fc->dbg_tick = debug_tick; fc->dbg_tick = debug_tick;
// Set up fields for closure. // Set up fields for closure.
@ -1058,7 +1058,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
bool func_not_yet_profiling_but_should = bool func_not_yet_profiling_but_should =
do_profiling_yes do_profiling_yes
&& !fp->uf_profiling && has_profiling(false, fp->uf_name, NULL); && !fp->uf_profiling && has_profiling(false, (char *)fp->uf_name, NULL);
if (func_not_yet_profiling_but_should) { if (func_not_yet_profiling_but_should) {
started_profiling = true; started_profiling = true;
@ -2332,7 +2332,7 @@ void ex_function(exarg_T *eap)
} }
// heredoc: Check for ":python <<EOF", ":lua <<EOF", etc. // heredoc: Check for ":python <<EOF", ":lua <<EOF", etc.
arg = (char_u *)skipwhite((char *)skiptowhite(p)); arg = (char_u *)skipwhite(skiptowhite((char *)p));
if (arg[0] == '<' && arg[1] == '<' if (arg[0] == '<' && arg[1] == '<'
&& ((p[0] == 'p' && p[1] == 'y' && ((p[0] == 'p' && p[1] == 'y'
&& (!ASCII_ISALNUM(p[2]) || p[2] == 't' && (!ASCII_ISALNUM(p[2]) || p[2] == 't'
@ -2359,12 +2359,12 @@ void ex_function(exarg_T *eap)
// Check for ":let v =<< [trim] EOF" // Check for ":let v =<< [trim] EOF"
// and ":let [a, b] =<< [trim] EOF" // and ":let [a, b] =<< [trim] EOF"
arg = (char_u *)skipwhite((char *)skiptowhite(p)); arg = (char_u *)skipwhite(skiptowhite((char *)p));
if (*arg == '[') { if (*arg == '[') {
arg = (char_u *)vim_strchr((char *)arg, ']'); arg = (char_u *)vim_strchr((char *)arg, ']');
} }
if (arg != NULL) { if (arg != NULL) {
arg = (char_u *)skipwhite((char *)skiptowhite(arg)); arg = (char_u *)skipwhite(skiptowhite((char *)arg));
if (arg[0] == '=' if (arg[0] == '='
&& arg[1] == '<' && arg[1] == '<'
&& arg[2] == '<' && arg[2] == '<'
@ -2379,7 +2379,7 @@ void ex_function(exarg_T *eap)
heredoc_trimmed = heredoc_trimmed =
vim_strnsave(theline, (size_t)((char_u *)skipwhite((char *)theline) - theline)); vim_strnsave(theline, (size_t)((char_u *)skipwhite((char *)theline) - theline));
} }
skip_until = vim_strnsave(p, (size_t)(skiptowhite(p) - p)); skip_until = vim_strnsave(p, (size_t)((char_u *)skiptowhite((char *)p) - p));
do_concat = false; do_concat = false;
is_heredoc = true; is_heredoc = true;
} }
@ -3105,16 +3105,17 @@ int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv)
/// Generate a return command for producing the value of "rettv". The result /// Generate a return command for producing the value of "rettv". The result
/// is an allocated string. Used by report_pending() for verbose messages. /// is an allocated string. Used by report_pending() for verbose messages.
char_u *get_return_cmd(void *rettv) char *get_return_cmd(void *rettv)
{ {
char_u *s = NULL; char *s = NULL;
char_u *tofree = NULL; char *tofree = NULL;
if (rettv != NULL) { if (rettv != NULL) {
tofree = s = (char_u *)encode_tv2echo((typval_T *)rettv, NULL); tofree = encode_tv2echo((typval_T *)rettv, NULL);
s = encode_tv2echo((typval_T *)rettv, NULL);
} }
if (s == NULL) { if (s == NULL) {
s = (char_u *)""; s = "";
} }
STRCPY(IObuff, ":return "); STRCPY(IObuff, ":return ");
@ -3123,7 +3124,7 @@ char_u *get_return_cmd(void *rettv)
STRCPY(IObuff + IOSIZE - 4, "..."); STRCPY(IObuff + IOSIZE - 4, "...");
} }
xfree(tofree); xfree(tofree);
return vim_strsave(IObuff); return (char *)vim_strsave(IObuff);
} }
/// Get next function line. /// Get next function line.
@ -3134,12 +3135,12 @@ char *get_func_line(int c, void *cookie, int indent, bool do_concat)
{ {
funccall_T *fcp = (funccall_T *)cookie; funccall_T *fcp = (funccall_T *)cookie;
ufunc_T *fp = fcp->func; ufunc_T *fp = fcp->func;
char_u *retval; char *retval;
garray_T *gap; // growarray with function lines garray_T *gap; // growarray with function lines
// If breakpoints have been added/deleted need to check for it. // If breakpoints have been added/deleted need to check for it.
if (fcp->dbg_tick != debug_tick) { if (fcp->dbg_tick != debug_tick) {
fcp->breakpoint = dbg_find_breakpoint(false, fp->uf_name, SOURCING_LNUM); fcp->breakpoint = dbg_find_breakpoint(false, (char *)fp->uf_name, SOURCING_LNUM);
fcp->dbg_tick = debug_tick; fcp->dbg_tick = debug_tick;
} }
if (do_profiling == PROF_YES) { if (do_profiling == PROF_YES) {
@ -3159,7 +3160,7 @@ char *get_func_line(int c, void *cookie, int indent, bool do_concat)
if (fcp->linenr >= gap->ga_len) { if (fcp->linenr >= gap->ga_len) {
retval = NULL; retval = NULL;
} else { } else {
retval = (char_u *)xstrdup(((char **)(gap->ga_data))[fcp->linenr++]); retval = xstrdup(((char **)(gap->ga_data))[fcp->linenr++]);
SOURCING_LNUM = fcp->linenr; SOURCING_LNUM = fcp->linenr;
if (do_profiling == PROF_YES) { if (do_profiling == PROF_YES) {
func_line_start(cookie); func_line_start(cookie);
@ -3169,13 +3170,13 @@ char *get_func_line(int c, void *cookie, int indent, bool do_concat)
// Did we encounter a breakpoint? // Did we encounter a breakpoint?
if (fcp->breakpoint != 0 && fcp->breakpoint <= SOURCING_LNUM) { if (fcp->breakpoint != 0 && fcp->breakpoint <= SOURCING_LNUM) {
dbg_breakpoint(fp->uf_name, SOURCING_LNUM); dbg_breakpoint((char *)fp->uf_name, SOURCING_LNUM);
// Find next breakpoint. // Find next breakpoint.
fcp->breakpoint = dbg_find_breakpoint(false, fp->uf_name, SOURCING_LNUM); fcp->breakpoint = dbg_find_breakpoint(false, (char *)fp->uf_name, SOURCING_LNUM);
fcp->dbg_tick = debug_tick; fcp->dbg_tick = debug_tick;
} }
return (char *)retval; return retval;
} }
/// @return true if the currently active function should be ended, because a /// @return true if the currently active function should be ended, because a

View File

@ -81,7 +81,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd)
// The marker is the next word. // The marker is the next word.
if (*cmd != NUL && *cmd != '"') { if (*cmd != NUL && *cmd != '"') {
marker = skipwhite(cmd); marker = skipwhite(cmd);
p = (char *)skiptowhite((char_u *)marker); p = skiptowhite(marker);
if (*skipwhite(p) != NUL && *skipwhite(p) != '"') { if (*skipwhite(p) != NUL && *skipwhite(p) != '"') {
semsg(_(e_trailing_arg), p); semsg(_(e_trailing_arg), p);
return NULL; return NULL;
@ -587,7 +587,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
char *s = vim_getenv(name); char *s = vim_getenv(name);
if (s != NULL) { if (s != NULL) {
tofree = (char *)concat_str((const char_u *)s, (const char_u *)p); tofree = concat_str(s, p);
p = (const char *)tofree; p = (const char *)tofree;
xfree(s); xfree(s);
} }
@ -663,8 +663,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
} else if (opt_type == gov_string && stringval != NULL && s != NULL) { } else if (opt_type == gov_string && stringval != NULL && s != NULL) {
// string // string
char *const oldstringval = stringval; char *const oldstringval = stringval;
stringval = (char *)concat_str((const char_u *)stringval, stringval = concat_str(stringval, s);
(const char_u *)s);
xfree(oldstringval); xfree(oldstringval);
s = stringval; s = stringval;
} }
@ -705,7 +704,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
if (p != NULL && op != NULL && *op == '.') { if (p != NULL && op != NULL && *op == '.') {
s = get_reg_contents(*arg == '@' ? '"' : *arg, kGRegExprSrc); s = get_reg_contents(*arg == '@' ? '"' : *arg, kGRegExprSrc);
if (s != NULL) { if (s != NULL) {
ptofree = (char *)concat_str((char_u *)s, (const char_u *)p); ptofree = concat_str(s, p);
p = (const char *)ptofree; p = (const char *)ptofree;
xfree(s); xfree(s);
} }

View File

@ -586,11 +586,11 @@ void ex_sort(exarg_T *eap)
p = s + start_col; p = s + start_col;
if (sort_nr) { if (sort_nr) {
if (sort_what & STR2NR_HEX) { if (sort_what & STR2NR_HEX) {
s = (char *)skiptohex((char_u *)p); s = skiptohex(p);
} else if (sort_what & STR2NR_BIN) { } else if (sort_what & STR2NR_BIN) {
s = (char *)skiptobin(p); s = (char *)skiptobin(p);
} else { } else {
s = (char *)skiptodigit((char_u *)p); s = skiptodigit(p);
} }
if (s > p && s[-1] == '-') { if (s > p && s[-1] == '-') {
s--; // include preceding negative sign s--; // include preceding negative sign
@ -2006,7 +2006,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
if (!eap->forceit && !eap->append) { if (!eap->forceit && !eap->append) {
#ifdef UNIX #ifdef UNIX
// It is possible to open a directory on Unix. // It is possible to open a directory on Unix.
if (os_isdir((char_u *)ffname)) { if (os_isdir(ffname)) {
semsg(_(e_isadir2), ffname); semsg(_(e_isadir2), ffname);
return FAIL; return FAIL;
} }
@ -3940,8 +3940,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
// what matches. Temporarily replace the line // what matches. Temporarily replace the line
// and change it back afterwards. // and change it back afterwards.
orig_line = (char *)vim_strsave(ml_get(lnum)); orig_line = (char *)vim_strsave(ml_get(lnum));
char *new_line = (char *)concat_str((char_u *)new_start, char *new_line = concat_str(new_start, sub_firstline + copycol);
(char_u *)sub_firstline + copycol);
// Position the cursor relative to the end of the line, the // Position the cursor relative to the end of the line, the
// previous substitute may have inserted or deleted characters // previous substitute may have inserted or deleted characters
@ -4939,7 +4938,7 @@ char *skip_vimgrep_pat(char *p, char **s, int *flags)
if (s != NULL) { if (s != NULL) {
*s = p; *s = p;
} }
p = (char *)skiptowhite((char_u *)p); p = skiptowhite(p);
if (s != NULL && *p != NUL) { if (s != NULL && *p != NUL) {
*p++ = NUL; *p++ = NUL;
} }

View File

@ -462,7 +462,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
if (breakpoint != NULL && dbg_tick != NULL if (breakpoint != NULL && dbg_tick != NULL
&& *dbg_tick != debug_tick) { && *dbg_tick != debug_tick) {
*breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline), *breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline),
(char_u *)fname, SOURCING_LNUM); fname, SOURCING_LNUM);
*dbg_tick = debug_tick; *dbg_tick = debug_tick;
} }
@ -471,10 +471,10 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
// Did we encounter a breakpoint? // Did we encounter a breakpoint?
if (breakpoint != NULL && *breakpoint != 0 && *breakpoint <= SOURCING_LNUM) { if (breakpoint != NULL && *breakpoint != 0 && *breakpoint <= SOURCING_LNUM) {
dbg_breakpoint((char_u *)fname, SOURCING_LNUM); dbg_breakpoint(fname, SOURCING_LNUM);
// Find next breakpoint. // Find next breakpoint.
*breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline), *breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline),
(char_u *)fname, SOURCING_LNUM); fname, SOURCING_LNUM);
*dbg_tick = debug_tick; *dbg_tick = debug_tick;
} }
if (do_profiling == PROF_YES) { if (do_profiling == PROF_YES) {
@ -639,8 +639,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
// Check for the next breakpoint at or after the ":while" // Check for the next breakpoint at or after the ":while"
// or ":for". // or ":for".
if (breakpoint != NULL) { if (breakpoint != NULL) {
*breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline), *breakpoint = dbg_find_breakpoint(getline_equal(fgetline, cookie, getsourceline), fname,
(char_u *)fname,
((wcmd_T *)lines_ga.ga_data)[current_line].lnum - 1); ((wcmd_T *)lines_ga.ga_data)[current_line].lnum - 1);
*dbg_tick = debug_tick; *dbg_tick = debug_tick;
} }
@ -3665,7 +3664,7 @@ char *replace_makeprg(exarg_T *eap, char *arg, char **cmdlinep)
STRCAT(new_cmdline, arg); STRCAT(new_cmdline, arg);
} }
msg_make((char_u *)arg); msg_make(arg);
// 'eap->cmd' is not set here, because it is not used at CMD_make // 'eap->cmd' is not set here, because it is not used at CMD_make
xfree(*cmdlinep); xfree(*cmdlinep);
@ -3807,7 +3806,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp)
// done by ExpandOne() below. // done by ExpandOne() below.
#ifdef UNIX #ifdef UNIX
if (!has_wildcards) { if (!has_wildcards) {
backslash_halve((char_u *)eap->arg); backslash_halve(eap->arg);
} }
#else #else
backslash_halve((char_u *)eap->arg); backslash_halve((char_u *)eap->arg);
@ -5032,7 +5031,7 @@ static void ex_tabs(exarg_T *eap)
msg_putchar('\n'); msg_putchar('\n');
vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++); vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++);
msg_outtrans_attr(IObuff, HL_ATTR(HLF_T)); msg_outtrans_attr((char *)IObuff, HL_ATTR(HLF_T));
ui_flush(); // output one line at a time ui_flush(); // output one line at a time
os_breakcheck(); os_breakcheck();
@ -6154,7 +6153,7 @@ FILE *open_exfile(char_u *fname, int forceit, char *mode)
{ {
#ifdef UNIX #ifdef UNIX
// with Unix it is possible to open a directory // with Unix it is possible to open a directory
if (os_isdir(fname)) { if (os_isdir((char *)fname)) {
semsg(_(e_isadir2), fname); semsg(_(e_isadir2), fname);
return NULL; return NULL;
} }
@ -6881,7 +6880,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
if (src[*usedlen] == '<') { if (src[*usedlen] == '<') {
(*usedlen)++; (*usedlen)++;
char *s; char *s;
if ((s = (char *)STRRCHR(result, '.')) != NULL if ((s = strrchr(result, '.')) != NULL
&& s >= path_tail(result)) { && s >= path_tail(result)) {
resultlen = (size_t)(s - result); resultlen = (size_t)(s - result);
} }

View File

@ -726,14 +726,14 @@ static void report_pending(int action, int pending, void *value)
break; break;
case CSTP_RETURN: case CSTP_RETURN:
// ":return" command producing value, allocated // ":return" command producing value, allocated
s = (char *)get_return_cmd(value); s = get_return_cmd(value);
break; break;
default: default:
if (pending & CSTP_THROW) { if (pending & CSTP_THROW) {
vim_snprintf((char *)IObuff, IOSIZE, vim_snprintf((char *)IObuff, IOSIZE,
mesg, _("Exception")); mesg, _("Exception"));
mesg = (char *)concat_str(IObuff, (char_u *)": %s"); mesg = concat_str((char *)IObuff, ": %s");
s = ((except_T *)value)->value; s = ((except_T *)value)->value;
} else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT)) { } else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT)) {
s = _("Error and interrupt"); s = _("Error and interrupt");

View File

@ -3198,7 +3198,7 @@ static void draw_cmdline(int start, int len)
} }
} }
msg_outtrans_len((char_u *)arshape_buf, newlen); msg_outtrans_len(arshape_buf, newlen);
} else { } else {
draw_cmdline_no_arabicshape: draw_cmdline_no_arabicshape:
if (kv_size(ccline.last_colors.colors)) { if (kv_size(ccline.last_colors.colors)) {
@ -3213,7 +3213,7 @@ draw_cmdline_no_arabicshape:
chunk.attr); chunk.attr);
} }
} else { } else {
msg_outtrans_len(ccline.cmdbuff + start, len); msg_outtrans_len((char *)ccline.cmdbuff + start, len);
} }
} }
} }

View File

@ -956,7 +956,7 @@ void ex_mkrc(exarg_T *eap)
} }
// When using 'viewdir' may have to create the directory. // When using 'viewdir' may have to create the directory.
if (using_vdir && !os_isdir(p_vdir)) { if (using_vdir && !os_isdir((char *)p_vdir)) {
vim_mkdir_emsg((const char *)p_vdir, 0755); vim_mkdir_emsg((const char *)p_vdir, 0755);
} }

View File

@ -471,7 +471,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
STRCPY(buf, ff_expand_buffer); STRCPY(buf, ff_expand_buffer);
STRCPY(buf + eb_len, search_ctx->ffsc_fix_path); STRCPY(buf + eb_len, search_ctx->ffsc_fix_path);
if (os_isdir(buf)) { if (os_isdir((char *)buf)) {
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path); STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
add_pathsep((char *)ff_expand_buffer); add_pathsep((char *)ff_expand_buffer);
} else { } else {
@ -796,7 +796,7 @@ char_u *vim_findfile(void *search_ctx_arg)
*/ */
for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; i++) { for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; i++) {
if (!path_with_url(stackp->ffs_filearray[i]) if (!path_with_url(stackp->ffs_filearray[i])
&& !os_isdir((char_u *)stackp->ffs_filearray[i])) { && !os_isdir(stackp->ffs_filearray[i])) {
continue; // not a directory continue; // not a directory
} }
// prepare the filename to be checked for existence below // prepare the filename to be checked for existence below
@ -828,7 +828,7 @@ char_u *vim_findfile(void *search_ctx_arg)
|| (os_path_exists(file_path) || (os_path_exists(file_path)
&& (search_ctx->ffsc_find_what == FINDFILE_BOTH && (search_ctx->ffsc_find_what == FINDFILE_BOTH
|| ((search_ctx->ffsc_find_what == FINDFILE_DIR) || ((search_ctx->ffsc_find_what == FINDFILE_DIR)
== os_isdir(file_path))))) == os_isdir((char *)file_path)))))
#ifndef FF_VERBOSE #ifndef FF_VERBOSE
&& (ff_check_visited(&search_ctx->ffsc_visited_list->ffvl_visited_list, && (ff_check_visited(&search_ctx->ffsc_visited_list->ffvl_visited_list,
file_path, (char_u *)"") == OK) file_path, (char_u *)"") == OK)
@ -885,7 +885,7 @@ char_u *vim_findfile(void *search_ctx_arg)
} else { } else {
// still wildcards left, push the directories for further search // still wildcards left, push the directories for further search
for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; i++) { for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; i++) {
if (!os_isdir((char_u *)stackp->ffs_filearray[i])) { if (!os_isdir(stackp->ffs_filearray[i])) {
continue; // not a directory continue; // not a directory
} }
ff_push(search_ctx, ff_push(search_ctx,
@ -909,7 +909,7 @@ char_u *vim_findfile(void *search_ctx_arg)
stackp->ffs_fix_path) == 0) { stackp->ffs_fix_path) == 0) {
continue; // don't repush same directory continue; // don't repush same directory
} }
if (!os_isdir((char_u *)stackp->ffs_filearray[i])) { if (!os_isdir(stackp->ffs_filearray[i])) {
continue; // not a directory continue; // not a directory
} }
ff_push(search_ctx, ff_push(search_ctx,
@ -1476,7 +1476,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
(os_path_exists((char_u *)NameBuff) (os_path_exists((char_u *)NameBuff)
&& (find_what == FINDFILE_BOTH && (find_what == FINDFILE_BOTH
|| ((find_what == FINDFILE_DIR) || ((find_what == FINDFILE_DIR)
== os_isdir((char_u *)NameBuff))))) { == os_isdir(NameBuff))))) {
file_name = vim_strsave((char_u *)NameBuff); file_name = vim_strsave((char_u *)NameBuff);
goto theend; goto theend;
} }

View File

@ -143,7 +143,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr)
msg_scroll = msg_scroll_save; msg_scroll = msg_scroll_save;
msg_scrolled_ign = true; msg_scrolled_ign = true;
// may truncate the message to avoid a hit-return prompt // may truncate the message to avoid a hit-return prompt
msg_outtrans_attr(msg_may_trunc(false, IObuff), attr); msg_outtrans_attr((char *)msg_may_trunc(false, IObuff), attr);
msg_clr_eos(); msg_clr_eos();
ui_flush(); ui_flush();
msg_scrolled_ign = false; msg_scrolled_ign = false;
@ -2775,7 +2775,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
if (trailing_pathseps) { if (trailing_pathseps) {
IObuff[dir_len - 2] = NUL; IObuff[dir_len - 2] = NUL;
} }
if (*dirp == NUL && !os_isdir(IObuff)) { if (*dirp == NUL && !os_isdir((char *)IObuff)) {
int ret; int ret;
char *failed_dir; char *failed_dir;
if ((ret = os_mkdir_recurse((char *)IObuff, 0755, &failed_dir)) != 0) { if ((ret = os_mkdir_recurse((char *)IObuff, 0755, &failed_dir)) != 0) {
@ -2936,7 +2936,7 @@ nobackup:
if (trailing_pathseps) { if (trailing_pathseps) {
IObuff[dir_len - 2] = NUL; IObuff[dir_len - 2] = NUL;
} }
if (*dirp == NUL && !os_isdir(IObuff)) { if (*dirp == NUL && !os_isdir((char *)IObuff)) {
int ret; int ret;
char *failed_dir; char *failed_dir;
if ((ret = os_mkdir_recurse((char *)IObuff, 0755, &failed_dir)) != 0) { if ((ret = os_mkdir_recurse((char *)IObuff, 0755, &failed_dir)) != 0) {
@ -4948,7 +4948,7 @@ int buf_check_timestamp(buf_T *buf)
buf_store_file_info(buf, &file_info); buf_store_file_info(buf, &file_info);
} }
if (os_isdir((char_u *)buf->b_fname)) { if (os_isdir(buf->b_fname)) {
// Don't do anything for a directory. Might contain the file explorer. // Don't do anything for a directory. Might contain the file explorer.
} else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar) } else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar)
&& !bufIsChanged(buf) && file_info_ok) { && !bufIsChanged(buf) && file_info_ok) {
@ -5318,7 +5318,7 @@ static void vim_mktempdir(void)
for (size_t i = 0; i < ARRAY_SIZE(temp_dirs); i++) { for (size_t i = 0; i < ARRAY_SIZE(temp_dirs); i++) {
// Expand environment variables, leave room for "/tmp/nvim.<user>/XXXXXX/999999999". // Expand environment variables, leave room for "/tmp/nvim.<user>/XXXXXX/999999999".
expand_env((char *)temp_dirs[i], tmp, TEMP_FILE_PATH_MAXLEN - 64); expand_env((char *)temp_dirs[i], tmp, TEMP_FILE_PATH_MAXLEN - 64);
if (!os_isdir((char_u *)tmp)) { if (!os_isdir(tmp)) {
continue; continue;
} }
@ -5328,7 +5328,7 @@ static void vim_mktempdir(void)
xstrlcat(tmp, user, sizeof(tmp)); xstrlcat(tmp, user, sizeof(tmp));
(void)os_mkdir(tmp, 0700); // Always create, to avoid a race. (void)os_mkdir(tmp, 0700); // Always create, to avoid a race.
bool owned = os_file_owned(tmp); bool owned = os_file_owned(tmp);
bool isdir = os_isdir((char_u *)tmp); bool isdir = os_isdir(tmp);
#ifdef UNIX #ifdef UNIX
int perm = os_getperm(tmp); // XDG_RUNTIME_DIR must be owned by the user, mode 0700. int perm = os_getperm(tmp); // XDG_RUNTIME_DIR must be owned by the user, mode 0700.
bool valid = isdir && owned && 0700 == (perm & 0777); bool valid = isdir && owned && 0700 == (perm & 0777);

View File

@ -1280,7 +1280,7 @@ void restore_typeahead(tasave_T *tp)
/// Open a new script file for the ":source!" command. /// Open a new script file for the ":source!" command.
/// ///
/// @param directly when true execute directly /// @param directly when true execute directly
void openscript(char_u *name, bool directly) void openscript(char *name, bool directly)
{ {
if (curscript + 1 == NSCRIPT) { if (curscript + 1 == NSCRIPT) {
emsg(_(e_nesting)); emsg(_(e_nesting));
@ -1302,7 +1302,7 @@ void openscript(char_u *name, bool directly)
curscript++; curscript++;
} }
// use NameBuff for expanded name // use NameBuff for expanded name
expand_env((char *)name, NameBuff, MAXPATHL); expand_env(name, NameBuff, MAXPATHL);
int error; int error;
if ((scriptin[curscript] = file_open_new(&error, (char *)NameBuff, if ((scriptin[curscript] = file_open_new(&error, (char *)NameBuff,
kFileReadOnly, 0)) == NULL) { kFileReadOnly, 0)) == NULL) {

View File

@ -177,7 +177,7 @@ EXTERN bool msg_scrolled_ign INIT(= false);
// is reset before the screen is redrawn, so we need to keep track of this. // is reset before the screen is redrawn, so we need to keep track of this.
EXTERN bool msg_did_scroll INIT(= false); EXTERN bool msg_did_scroll INIT(= false);
EXTERN char_u *keep_msg INIT(= NULL); // msg to be shown after redraw EXTERN char *keep_msg INIT(= NULL); // msg to be shown after redraw
EXTERN int keep_msg_attr INIT(= 0); // highlight attr for keep_msg EXTERN int keep_msg_attr INIT(= 0); // highlight attr for keep_msg
EXTERN bool need_fileinfo INIT(= false); // do fileinfo() after redraw EXTERN bool need_fileinfo INIT(= false); // do fileinfo() after redraw
EXTERN int msg_scroll INIT(= false); // msg_start() will scroll EXTERN int msg_scroll INIT(= false); // msg_start() will scroll

View File

@ -3062,7 +3062,8 @@ int mch_print_text_out(char_u *const textp, size_t len)
if (prt_do_conv) { if (prt_do_conv) {
// Convert from multi-byte to 8-bit encoding // Convert from multi-byte to 8-bit encoding
tofree = p = string_convert(&prt_conv, p, &len); p = (char_u *)string_convert(&prt_conv, (char *)p, &len);
tofree = p;
if (p == NULL) { if (p == NULL) {
p = (char_u *)""; p = (char_u *)"";
len = 0; len = 0;

View File

@ -741,8 +741,8 @@ void fix_help_buffer(void)
const char *const f2 = fnames[i2]; const char *const f2 = fnames[i2];
const char *const t1 = path_tail(f1); const char *const t1 = path_tail(f1);
const char *const t2 = path_tail(f2); const char *const t2 = path_tail(f2);
const char *const e1 = (char *)STRRCHR(t1, '.'); const char *const e1 = strrchr(t1, '.');
const char *const e2 = (char *)STRRCHR(t2, '.'); const char *const e2 = strrchr(t2, '.');
if (e1 == NULL || e2 == NULL) { if (e1 == NULL || e2 == NULL) {
continue; continue;
} }
@ -811,7 +811,7 @@ void fix_help_buffer(void)
} else { } else {
// Do the conversion. If it fails // Do the conversion. If it fails
// use the unconverted text. // use the unconverted text.
cp = (char *)string_convert(&vc, IObuff, NULL); cp = string_convert(&vc, (char *)IObuff, NULL);
if (cp == NULL) { if (cp == NULL) {
cp = (char *)IObuff; cp = (char *)IObuff;
} }
@ -1163,13 +1163,13 @@ void ex_helptags(exarg_T *eap)
} }
if (STRCMP(eap->arg, "ALL") == 0) { if (STRCMP(eap->arg, "ALL") == 0) {
do_in_path((char_u *)p_rtp, "doc", DIP_ALL + DIP_DIR, helptags_cb, &add_help_tags); do_in_path(p_rtp, "doc", DIP_ALL + DIP_DIR, helptags_cb, &add_help_tags);
} else { } else {
ExpandInit(&xpc); ExpandInit(&xpc);
xpc.xp_context = EXPAND_DIRECTORIES; xpc.xp_context = EXPAND_DIRECTORIES;
dirname = (char *)ExpandOne(&xpc, (char_u *)eap->arg, NULL, dirname = (char *)ExpandOne(&xpc, (char_u *)eap->arg, NULL,
WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
if (dirname == NULL || !os_isdir((char_u *)dirname)) { if (dirname == NULL || !os_isdir(dirname)) {
semsg(_("E150: Not a directory: %s"), eap->arg); semsg(_("E150: Not a directory: %s"), eap->arg);
} else { } else {
do_helptags(dirname, add_help_tags, false); do_helptags(dirname, add_help_tags, false);

View File

@ -852,14 +852,14 @@ void do_highlight(const char *line, const bool forceit, const bool init)
} }
// Isolate the name. // Isolate the name.
name_end = (const char *)skiptowhite((const char_u *)line); name_end = (const char *)skiptowhite(line);
linep = (const char *)skipwhite(name_end); linep = (const char *)skipwhite(name_end);
// Check for "default" argument. // Check for "default" argument.
if (strncmp(line, "default", (size_t)(name_end - line)) == 0) { if (strncmp(line, "default", (size_t)(name_end - line)) == 0) {
dodefault = true; dodefault = true;
line = linep; line = linep;
name_end = (const char *)skiptowhite((const char_u *)line); name_end = (const char *)skiptowhite(line);
linep = (const char *)skipwhite(name_end); linep = (const char *)skipwhite(name_end);
} }
@ -891,9 +891,9 @@ void do_highlight(const char *line, const bool forceit, const bool init)
int to_id; int to_id;
HlGroup *hlgroup = NULL; HlGroup *hlgroup = NULL;
from_end = (const char *)skiptowhite((const char_u *)from_start); from_end = (const char *)skiptowhite(from_start);
to_start = (const char *)skipwhite(from_end); to_start = (const char *)skipwhite(from_end);
to_end = (const char *)skiptowhite((const char_u *)to_start); to_end = (const char *)skiptowhite(to_start);
if (ends_excmd((uint8_t)(*from_start)) if (ends_excmd((uint8_t)(*from_start))
|| ends_excmd((uint8_t)(*to_start))) { || ends_excmd((uint8_t)(*to_start))) {
@ -969,7 +969,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
redraw_all_later(UPD_NOT_VALID); redraw_all_later(UPD_NOT_VALID);
return; return;
} }
name_end = (const char *)skiptowhite((const char_u *)line); name_end = (const char *)skiptowhite(line);
linep = (const char *)skipwhite(name_end); linep = (const char *)skipwhite(name_end);
} }
@ -1054,7 +1054,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
} }
} else { } else {
arg_start = linep; arg_start = linep;
linep = (const char *)skiptowhite((const char_u *)linep); linep = (const char *)skiptowhite(linep);
} }
if (linep == arg_start) { if (linep == arg_start) {
semsg(_("E417: missing argument: %s"), key_start); semsg(_("E417: missing argument: %s"), key_start);
@ -2074,13 +2074,13 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
// (part of) subcommand already typed // (part of) subcommand already typed
if (*arg != NUL) { if (*arg != NUL) {
const char *p = (const char *)skiptowhite((const char_u *)arg); const char *p = (const char *)skiptowhite(arg);
if (*p != NUL) { // Past "default" or group name. if (*p != NUL) { // Past "default" or group name.
include_default = 0; include_default = 0;
if (strncmp("default", arg, (unsigned)(p - arg)) == 0) { if (strncmp("default", arg, (unsigned)(p - arg)) == 0) {
arg = (const char *)skipwhite(p); arg = (const char *)skipwhite(p);
xp->xp_pattern = (char *)arg; xp->xp_pattern = (char *)arg;
p = (const char *)skiptowhite((const char_u *)arg); p = (const char *)skiptowhite(arg);
} }
if (*p != NUL) { // past group name if (*p != NUL) { // past group name
include_link = 0; include_link = 0;
@ -2090,10 +2090,10 @@ void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
if (strncmp("link", arg, (unsigned)(p - arg)) == 0 if (strncmp("link", arg, (unsigned)(p - arg)) == 0
|| strncmp("clear", arg, (unsigned)(p - arg)) == 0) { || strncmp("clear", arg, (unsigned)(p - arg)) == 0) {
xp->xp_pattern = skipwhite(p); xp->xp_pattern = skipwhite(p);
p = (const char *)skiptowhite((char_u *)xp->xp_pattern); p = (const char *)skiptowhite(xp->xp_pattern);
if (*p != NUL) { // Past first group name. if (*p != NUL) { // Past first group name.
xp->xp_pattern = skipwhite(p); xp->xp_pattern = skipwhite(p);
p = (const char *)skiptowhite((char_u *)xp->xp_pattern); p = (const char *)skiptowhite(xp->xp_pattern);
} }
} }
if (*p != NUL) { // Past group name(s). if (*p != NUL) { // Past group name(s).

View File

@ -153,10 +153,10 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
// (part of) subcommand already typed // (part of) subcommand already typed
if (*arg != NUL) { if (*arg != NUL) {
const char *p = (const char *)skiptowhite((const char_u *)arg); const char *p = (const char *)skiptowhite(arg);
if (*p != NUL) { // Past first word. if (*p != NUL) { // Past first word.
xp->xp_pattern = skipwhite(p); xp->xp_pattern = skipwhite(p);
if (*skiptowhite((char_u *)xp->xp_pattern) != NUL) { if (*skiptowhite(xp->xp_pattern) != NUL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} else if (STRNICMP(arg, "add", p - arg) == 0) { } else if (STRNICMP(arg, "add", p - arg) == 0) {
xp->xp_context = EXPAND_FILES; xp->xp_context = EXPAND_FILES;

View File

@ -676,10 +676,10 @@ static int cin_first_id_amount(void)
line = get_cursor_line_ptr(); line = get_cursor_line_ptr();
p = (char_u *)skipwhite((char *)line); p = (char_u *)skipwhite((char *)line);
len = (int)(skiptowhite(p) - p); len = (int)((char_u *)skiptowhite((char *)p) - p);
if (len == 6 && STRNCMP(p, "static", 6) == 0) { if (len == 6 && STRNCMP(p, "static", 6) == 0) {
p = (char_u *)skipwhite((char *)p + 6); p = (char_u *)skipwhite((char *)p + 6);
len = (int)(skiptowhite(p) - p); len = (int)((char_u *)skiptowhite((char *)p) - p);
} }
if (len == 6 && STRNCMP(p, "struct", 6) == 0) { if (len == 6 && STRNCMP(p, "struct", 6) == 0) {
p = (char_u *)skipwhite((char *)p + 6); p = (char_u *)skipwhite((char *)p + 6);

View File

@ -3767,7 +3767,7 @@ static int get_normal_compl_info(char_u *line, int startcol, colnr_T curs_col)
/// Sets the global variables: compl_col, compl_length and compl_pattern. /// Sets the global variables: compl_col, compl_length and compl_pattern.
static int get_wholeline_compl_info(char_u *line, colnr_T curs_col) static int get_wholeline_compl_info(char_u *line, colnr_T curs_col)
{ {
compl_col = (colnr_T)getwhitecols(line); compl_col = (colnr_T)getwhitecols((char *)line);
compl_length = (int)curs_col - (int)compl_col; compl_length = (int)curs_col - (int)compl_col;
if (compl_length < 0) { // cursor in indent: empty pattern if (compl_length < 0) { // cursor in indent: empty pattern
compl_length = 0; compl_length = 0;
@ -3985,7 +3985,7 @@ static void ins_compl_continue_search(char_u *line)
// first non_blank in the line, if it is not a wordchar // first non_blank in the line, if it is not a wordchar
// include it to get a better pattern, but then we don't // include it to get a better pattern, but then we don't
// want the "\\<" prefix, check it below. // want the "\\<" prefix, check it below.
compl_col = (colnr_T)getwhitecols(line); compl_col = (colnr_T)getwhitecols((char *)line);
compl_startpos.col = compl_col; compl_startpos.col = compl_col;
compl_startpos.lnum = curwin->w_cursor.lnum; compl_startpos.lnum = curwin->w_cursor.lnum;
compl_cont_status &= ~CONT_SOL; // clear SOL if present compl_cont_status &= ~CONT_SOL; // clear SOL if present

View File

@ -188,7 +188,7 @@ void ex_language(exarg_T *eap)
// Check for "messages {name}", "ctype {name}" or "time {name}" argument. // Check for "messages {name}", "ctype {name}" or "time {name}" argument.
// Allow abbreviation, but require at least 3 characters to avoid // Allow abbreviation, but require at least 3 characters to avoid
// confusion with a two letter language name "me" or "ct". // confusion with a two letter language name "me" or "ct".
p = (char *)skiptowhite((char_u *)eap->arg); p = skiptowhite(eap->arg);
if ((*p == NUL || ascii_iswhite(*p)) && p - eap->arg >= 3) { if ((*p == NUL || ascii_iswhite(*p)) && p - eap->arg >= 3) {
if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) { if (STRNICMP(eap->arg, "messages", p - eap->arg) == 0) {
what = VIM_LC_MESSAGES; what = VIM_LC_MESSAGES;

View File

@ -63,13 +63,13 @@ static void log_path_init(void)
expand_env("$" ENV_LOGFILE, log_file_path, (int)size - 1); expand_env("$" ENV_LOGFILE, log_file_path, (int)size - 1);
if (strequal("$" ENV_LOGFILE, log_file_path) if (strequal("$" ENV_LOGFILE, log_file_path)
|| log_file_path[0] == '\0' || log_file_path[0] == '\0'
|| os_isdir((char_u *)log_file_path) || os_isdir(log_file_path)
|| !log_try_create(log_file_path)) { || !log_try_create(log_file_path)) {
// Make $XDG_STATE_HOME if it does not exist. // Make $XDG_STATE_HOME if it does not exist.
char *loghome = get_xdg_home(kXDGStateHome); char *loghome = get_xdg_home(kXDGStateHome);
char *failed_dir = NULL; char *failed_dir = NULL;
bool log_dir_failure = false; bool log_dir_failure = false;
if (!os_isdir((char_u *)loghome)) { if (!os_isdir(loghome)) {
log_dir_failure = (os_mkdir_recurse(loghome, 0700, &failed_dir) != 0); log_dir_failure = (os_mkdir_recurse(loghome, 0700, &failed_dir) != 0);
} }
XFREE_CLEAR(loghome); XFREE_CLEAR(loghome);

View File

@ -501,7 +501,7 @@ static int nlua_iconv(lua_State *lstate)
vimconv.vc_type = CONV_NONE; vimconv.vc_type = CONV_NONE;
convert_setup_ext(&vimconv, from, false, to, false); convert_setup_ext(&vimconv, from, false, to, false);
char_u *ret = string_convert(&vimconv, (char_u *)str, &str_len); char_u *ret = (char_u *)string_convert(&vimconv, (char *)str, &str_len);
convert_setup(&vimconv, NULL, NULL); convert_setup(&vimconv, NULL, NULL);

View File

@ -1342,8 +1342,8 @@ scripterror:
ga_grow(&global_alist.al_ga, 1); ga_grow(&global_alist.al_ga, 1);
char *p = xstrdup(argv[0]); char *p = xstrdup(argv[0]);
if (parmp->diff_mode && os_isdir((char_u *)p) && GARGCOUNT > 0 if (parmp->diff_mode && os_isdir(p) && GARGCOUNT > 0
&& !os_isdir((char_u *)alist_name(&GARGLIST[0]))) { && !os_isdir(alist_name(&GARGLIST[0]))) {
char *r = concat_fnames(p, path_tail(alist_name(&GARGLIST[0])), true); char *r = concat_fnames(p, path_tail(alist_name(&GARGLIST[0])), true);
xfree(p); xfree(p);
p = r; p = r;

View File

@ -922,7 +922,7 @@ static void show_one_mark(int c, char_u *arg, pos_T *p, char_u *name_arg, int cu
snprintf((char *)IObuff, IOSIZE, " %c %6" PRIdLINENR " %4d ", c, p->lnum, p->col); snprintf((char *)IObuff, IOSIZE, " %c %6" PRIdLINENR " %4d ", c, p->lnum, p->col);
msg_outtrans((char *)IObuff); msg_outtrans((char *)IObuff);
if (name != NULL) { if (name != NULL) {
msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0); msg_outtrans_attr((char *)name, current ? HL_ATTR(HLF_D) : 0);
} }
} }
ui_flush(); // show one line at a time ui_flush(); // show one line at a time
@ -1052,7 +1052,7 @@ void ex_jumps(exarg_T *eap)
i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx : curwin->w_jumplistidx - i, i > curwin->w_jumplistidx ? i - curwin->w_jumplistidx : curwin->w_jumplistidx - i,
curwin->w_jumplist[i].fmark.mark.lnum, curwin->w_jumplist[i].fmark.mark.col); curwin->w_jumplist[i].fmark.mark.lnum, curwin->w_jumplist[i].fmark.mark.col);
msg_outtrans((char *)IObuff); msg_outtrans((char *)IObuff);
msg_outtrans_attr(name, msg_outtrans_attr((char *)name,
curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum
? HL_ATTR(HLF_D) : 0); ? HL_ATTR(HLF_D) : 0);
xfree(name); xfree(name);
@ -1097,7 +1097,7 @@ void ex_changes(exarg_T *eap)
curbuf->b_changelist[i].mark.col); curbuf->b_changelist[i].mark.col);
msg_outtrans((char *)IObuff); msg_outtrans((char *)IObuff);
name = mark_line(&curbuf->b_changelist[i].mark, 17); name = mark_line(&curbuf->b_changelist[i].mark, 17);
msg_outtrans_attr(name, HL_ATTR(HLF_D)); msg_outtrans_attr((char *)name, HL_ATTR(HLF_D));
xfree(name); xfree(name);
os_breakcheck(); os_breakcheck();
} }

View File

@ -1183,7 +1183,7 @@ void ex_match(exarg_T *eap)
&& (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) { && (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) {
end = (char_u *)eap->arg + 4; end = (char_u *)eap->arg + 4;
} else { } else {
p = skiptowhite((char_u *)eap->arg); p = (char_u *)skiptowhite(eap->arg);
if (!eap->skip) { if (!eap->skip) {
g = vim_strnsave((char_u *)eap->arg, (size_t)(p - (char_u *)eap->arg)); g = vim_strnsave((char_u *)eap->arg, (size_t)(p - (char_u *)eap->arg));
} }

View File

@ -1942,7 +1942,7 @@ void utf_find_illegal(void)
p = get_cursor_pos_ptr(); p = get_cursor_pos_ptr();
if (vimconv.vc_type != CONV_NONE) { if (vimconv.vc_type != CONV_NONE) {
xfree(tofree); xfree(tofree);
tofree = string_convert(&vimconv, p, NULL); tofree = (char_u *)string_convert(&vimconv, (char *)p, NULL);
if (tofree == NULL) { if (tofree == NULL) {
break; break;
} }
@ -2521,16 +2521,14 @@ int convert_setup_ext(vimconv_T *vcp, char_u *from, bool from_unicode_is_utf8, c
return OK; return OK;
} }
/* /// Convert text "ptr[*lenp]" according to "vcp".
* Convert text "ptr[*lenp]" according to "vcp". /// Returns the result in allocated memory and sets "*lenp".
* Returns the result in allocated memory and sets "*lenp". /// When "lenp" is NULL, use NUL terminated strings.
* When "lenp" is NULL, use NUL terminated strings. /// Illegal chars are often changed to "?", unless vcp->vc_fail is set.
* Illegal chars are often changed to "?", unless vcp->vc_fail is set. /// When something goes wrong, NULL is returned and "*lenp" is unchanged.
* When something goes wrong, NULL is returned and "*lenp" is unchanged. char *string_convert(const vimconv_T *const vcp, char *ptr, size_t *lenp)
*/
char_u *string_convert(const vimconv_T *const vcp, char_u *ptr, size_t *lenp)
{ {
return string_convert_ext(vcp, ptr, lenp, NULL); return (char *)string_convert_ext(vcp, (char_u *)ptr, lenp, NULL);
} }
/* /*

View File

@ -857,7 +857,7 @@ void ml_recover(bool checkext)
if ((hp = mf_get(mfp, 0, 1)) == NULL) { if ((hp = mf_get(mfp, 0, 1)) == NULL) {
msg_start(); msg_start();
msg_puts_attr(_("Unable to read block 0 from "), attr | MSG_HIST); msg_puts_attr(_("Unable to read block 0 from "), attr | MSG_HIST);
msg_outtrans_attr(mfp->mf_fname, attr | MSG_HIST); msg_outtrans_attr((char *)mfp->mf_fname, attr | MSG_HIST);
msg_puts_attr(_("\nMaybe no changes were made or Vim did not update the swap file."), msg_puts_attr(_("\nMaybe no changes were made or Vim did not update the swap file."),
attr | MSG_HIST); attr | MSG_HIST);
msg_end(); msg_end();
@ -866,7 +866,7 @@ void ml_recover(bool checkext)
b0p = hp->bh_data; b0p = hp->bh_data;
if (STRNCMP(b0p->b0_version, "VIM 3.0", 7) == 0) { if (STRNCMP(b0p->b0_version, "VIM 3.0", 7) == 0) {
msg_start(); msg_start();
msg_outtrans_attr(mfp->mf_fname, MSG_HIST); msg_outtrans_attr((char *)mfp->mf_fname, MSG_HIST);
msg_puts_attr(_(" cannot be used with this version of Vim.\n"), msg_puts_attr(_(" cannot be used with this version of Vim.\n"),
MSG_HIST); MSG_HIST);
msg_puts_attr(_("Use Vim version 3.0.\n"), MSG_HIST); msg_puts_attr(_("Use Vim version 3.0.\n"), MSG_HIST);
@ -879,7 +879,7 @@ void ml_recover(bool checkext)
} }
if (b0_magic_wrong(b0p)) { if (b0_magic_wrong(b0p)) {
msg_start(); msg_start();
msg_outtrans_attr(mfp->mf_fname, attr | MSG_HIST); msg_outtrans_attr((char *)mfp->mf_fname, attr | MSG_HIST);
msg_puts_attr(_(" cannot be used on this computer.\n"), msg_puts_attr(_(" cannot be used on this computer.\n"),
attr | MSG_HIST); attr | MSG_HIST);
msg_puts_attr(_("The file was created on "), attr | MSG_HIST); msg_puts_attr(_("The file was created on "), attr | MSG_HIST);
@ -901,7 +901,7 @@ void ml_recover(bool checkext)
mf_new_page_size(mfp, (unsigned)char_to_long(b0p->b0_page_size)); mf_new_page_size(mfp, (unsigned)char_to_long(b0p->b0_page_size));
if (mfp->mf_page_size < previous_page_size) { if (mfp->mf_page_size < previous_page_size) {
msg_start(); msg_start();
msg_outtrans_attr(mfp->mf_fname, attr | MSG_HIST); msg_outtrans_attr((char *)mfp->mf_fname, attr | MSG_HIST);
msg_puts_attr(_(" has been damaged (page size is smaller than minimum value).\n"), msg_puts_attr(_(" has been damaged (page size is smaller than minimum value).\n"),
attr | MSG_HIST); attr | MSG_HIST);
msg_end(); msg_end();
@ -3614,7 +3614,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
fname[n - 1]--; // ".swo", ".swn", etc. fname[n - 1]--; // ".swo", ".swn", etc.
} }
if (os_isdir((char_u *)dir_name)) { if (os_isdir(dir_name)) {
*found_existing_dir = true; *found_existing_dir = true;
} else if (!*found_existing_dir && **dirp == NUL) { } else if (!*found_existing_dir && **dirp == NUL) {
int ret; int ret;

View File

@ -853,7 +853,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
msg_puts(" "); msg_puts(" ");
} }
// Same highlighting as for directories!? // Same highlighting as for directories!?
msg_outtrans_attr((char_u *)menu->name, HL_ATTR(HLF_D)); msg_outtrans_attr(menu->name, HL_ATTR(HLF_D));
} }
if (menu != NULL && menu->children == NULL) { if (menu != NULL && menu->children == NULL) {

View File

@ -265,7 +265,7 @@ void msg_multiline_attr(const char *s, int attr, bool check_int, bool *need_clea
// Print the rest of the message. We know there is no special // Print the rest of the message. We know there is no special
// character because strpbrk returned NULL // character because strpbrk returned NULL
if (*s != NUL) { if (*s != NUL) {
msg_outtrans_attr((char_u *)s, attr); msg_outtrans_attr(s, attr);
} }
} }
@ -325,7 +325,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
// Add message to history (unless it's a repeated kept message or a // Add message to history (unless it's a repeated kept message or a
// truncated message) // truncated message)
if ((const char_u *)s != keep_msg if (s != keep_msg
|| (*s != '<' || (*s != '<'
&& last_msg_hist != NULL && last_msg_hist != NULL
&& last_msg_hist->msg != NULL && last_msg_hist->msg != NULL
@ -344,7 +344,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
if (multiline) { if (multiline) {
msg_multiline_attr(s, attr, false, &need_clear); msg_multiline_attr(s, attr, false, &need_clear);
} else { } else {
msg_outtrans_attr((char_u *)s, attr); msg_outtrans_attr(s, attr);
} }
if (need_clear) { if (need_clear) {
msg_clr_eos(); msg_clr_eos();
@ -1307,7 +1307,7 @@ void wait_return(int redraw)
emsg_on_display = false; // can delete error message now emsg_on_display = false; // can delete error message now
lines_left = -1; // reset lines_left at next msg_start() lines_left = -1; // reset lines_left at next msg_start()
reset_last_sourcing(); reset_last_sourcing();
if (keep_msg != NULL && vim_strsize((char *)keep_msg) >= if (keep_msg != NULL && vim_strsize(keep_msg) >=
(Rows - cmdline_row - 1) * Columns + sc_col) { (Rows - cmdline_row - 1) * Columns + sc_col) {
XFREE_CLEAR(keep_msg); // don't redisplay message, it's too long XFREE_CLEAR(keep_msg); // don't redisplay message, it's too long
} }
@ -1350,7 +1350,7 @@ void set_keep_msg(char *s, int attr)
{ {
xfree(keep_msg); xfree(keep_msg);
if (s != NULL && msg_silent == 0) { if (s != NULL && msg_silent == 0) {
keep_msg = vim_strsave((char_u *)s); keep_msg = xstrdup(s);
} else { } else {
keep_msg = NULL; keep_msg = NULL;
} }
@ -1510,7 +1510,7 @@ void msg_home_replace_hl(char_u *fname)
static void msg_home_replace_attr(char_u *fname, int attr) static void msg_home_replace_attr(char_u *fname, int attr)
{ {
char *name = home_replace_save(NULL, (char *)fname); char *name = home_replace_save(NULL, (char *)fname);
msg_outtrans_attr((char_u *)name, attr); msg_outtrans_attr(name, attr);
xfree(name); xfree(name);
} }
@ -1521,29 +1521,29 @@ static void msg_home_replace_attr(char_u *fname, int attr)
/// @return the number of characters it takes on the screen. /// @return the number of characters it takes on the screen.
int msg_outtrans(char *str) int msg_outtrans(char *str)
{ {
return msg_outtrans_attr((char_u *)str, 0); return msg_outtrans_attr(str, 0);
} }
int msg_outtrans_attr(const char_u *str, int attr) int msg_outtrans_attr(const char *str, int attr)
{ {
return msg_outtrans_len_attr(str, (int)STRLEN(str), attr); return msg_outtrans_len_attr((char_u *)str, (int)STRLEN(str), attr);
} }
int msg_outtrans_len(const char_u *str, int len) int msg_outtrans_len(const char *str, int len)
{ {
return msg_outtrans_len_attr(str, len, 0); return msg_outtrans_len_attr((char_u *)str, len, 0);
} }
/// Output one character at "p". /// Output one character at "p".
/// Handles multi-byte characters. /// Handles multi-byte characters.
/// ///
/// @return pointer to the next character. /// @return pointer to the next character.
char_u *msg_outtrans_one(char_u *p, int attr) char *msg_outtrans_one(char *p, int attr)
{ {
int l; int l;
if ((l = utfc_ptr2len((char *)p)) > 1) { if ((l = utfc_ptr2len(p)) > 1) {
msg_outtrans_len_attr(p, l, attr); msg_outtrans_len_attr((char_u *)p, l, attr);
return p + l; return p + l;
} }
msg_puts_attr((const char *)transchar_byte(*p), attr); msg_puts_attr((const char *)transchar_byte(*p), attr);
@ -1628,12 +1628,13 @@ int msg_outtrans_len_attr(const char_u *msgstr, int len, int attr)
return retval; return retval;
} }
void msg_make(char_u *arg) void msg_make(char *arg)
{ {
int i; int i;
static char_u *str = (char_u *)"eeffoc", *rs = (char_u *)"Plon#dqg#vxjduB"; static char *str = "eeffoc";
static char *rs = "Plon#dqg#vxjduB";
arg = (char_u *)skipwhite((char *)arg); arg = skipwhite(arg);
for (i = 5; *arg && i >= 0; i--) { for (i = 5; *arg && i >= 0; i--) {
if (*arg++ != str[i]) { if (*arg++ != str[i]) {
break; break;
@ -1976,13 +1977,13 @@ void msg_prt_line(char_u *s, int list)
/// Use grid_puts() to output one multi-byte character. /// Use grid_puts() to output one multi-byte character.
/// ///
/// @return the pointer "s" advanced to the next character. /// @return the pointer "s" advanced to the next character.
static char_u *screen_puts_mbyte(char_u *s, int l, int attr) static char *screen_puts_mbyte(char *s, int l, int attr)
{ {
int cw; int cw;
attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr); attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr);
msg_didout = true; // remember that line is not empty msg_didout = true; // remember that line is not empty
cw = utf_ptr2cells((char *)s); cw = utf_ptr2cells(s);
if (cw > 1 if (cw > 1
&& (cmdmsg_rl ? msg_col <= 1 : msg_col == Columns - 1)) { && (cmdmsg_rl ? msg_col <= 1 : msg_col == Columns - 1)) {
// Doesn't fit, print a highlighted '>' to fill it up. // Doesn't fit, print a highlighted '>' to fill it up.
@ -1990,7 +1991,7 @@ static char_u *screen_puts_mbyte(char_u *s, int l, int attr)
return s; return s;
} }
grid_puts_len(&msg_grid_adj, (char *)s, l, msg_row, msg_col, attr); grid_puts_len(&msg_grid_adj, s, l, msg_row, msg_col, attr);
if (cmdmsg_rl) { if (cmdmsg_rl) {
msg_col -= cw; msg_col -= cw;
if (msg_col == 0) { if (msg_col == 0) {
@ -2197,7 +2198,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
// ourselves). // ourselves).
if (t_col > 0) { if (t_col > 0) {
// output postponed text // output postponed text
t_puts(&t_col, t_s, s, attr); t_puts(&t_col, (char *)t_s, (char *)s, attr);
} }
// When no more prompt and no more room, truncate here // When no more prompt and no more room, truncate here
@ -2222,7 +2223,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
} else { } else {
l = utfc_ptr2len((char *)s); l = utfc_ptr2len((char *)s);
} }
s = screen_puts_mbyte((char_u *)s, l, attr); s = (char_u *)screen_puts_mbyte((char *)s, l, attr);
did_last_char = true; did_last_char = true;
} else { } else {
did_last_char = false; did_last_char = false;
@ -2281,7 +2282,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
if (t_col > 0 && (wrap || *s == '\r' || *s == '\b' if (t_col > 0 && (wrap || *s == '\r' || *s == '\b'
|| *s == '\t' || *s == BELL)) { || *s == '\t' || *s == BELL)) {
// Output any postponed text. // Output any postponed text.
t_puts(&t_col, t_s, s, attr); t_puts(&t_col, (char *)t_s, (char *)s, attr);
} }
if (wrap && p_more && !recurse) { if (wrap && p_more && !recurse) {
@ -2324,7 +2325,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
// characters and draw them all at once later. // characters and draw them all at once later.
if (cmdmsg_rl || (cw > 1 && msg_col + t_col >= Columns - 1)) { if (cmdmsg_rl || (cw > 1 && msg_col + t_col >= Columns - 1)) {
if (l > 1) { if (l > 1) {
s = screen_puts_mbyte((char_u *)s, l, attr) - 1; s = (char_u *)screen_puts_mbyte((char *)s, l, attr) - 1;
} else { } else {
msg_screen_putchar(*s, attr); msg_screen_putchar(*s, attr);
} }
@ -2342,7 +2343,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
// Output any postponed text. // Output any postponed text.
if (t_col > 0) { if (t_col > 0) {
t_puts(&t_col, t_s, s, attr); t_puts(&t_col, (char *)t_s, (char *)s, attr);
} }
if (p_more && !recurse) { if (p_more && !recurse) {
store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, false); store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, false);
@ -2698,7 +2699,7 @@ static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp)
} }
/// Output any postponed text for msg_puts_attr_len(). /// Output any postponed text for msg_puts_attr_len().
static void t_puts(int *t_col, const char_u *t_s, const char_u *s, int attr) static void t_puts(int *t_col, const char *t_s, const char *s, int attr)
{ {
attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr); attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr);
// Output postponed text. // Output postponed text.
@ -2708,7 +2709,7 @@ static void t_puts(int *t_col, const char_u *t_s, const char_u *s, int attr)
*t_col = 0; *t_col = 0;
// If the string starts with a composing character don't increment the // If the string starts with a composing character don't increment the
// column position for it. // column position for it.
if (utf_iscomposing(utf_ptr2char((char *)t_s))) { if (utf_iscomposing(utf_ptr2char(t_s))) {
msg_col--; msg_col--;
} }
if (msg_col >= Columns) { if (msg_col >= Columns) {

View File

@ -631,16 +631,16 @@ static void normal_redraw_mode_message(NormalState *s)
if (must_redraw && keep_msg != NULL && !emsg_on_display) { if (must_redraw && keep_msg != NULL && !emsg_on_display) {
char_u *kmsg; char_u *kmsg;
kmsg = keep_msg; kmsg = (char_u *)keep_msg;
keep_msg = NULL; keep_msg = NULL;
// Showmode() will clear keep_msg, but we want to use it anyway. // Showmode() will clear keep_msg, but we want to use it anyway.
// First update w_topline. // First update w_topline.
setcursor(); setcursor();
update_screen(0); update_screen(0);
// now reset it, otherwise it's put in the history again // now reset it, otherwise it's put in the history again
keep_msg = kmsg; keep_msg = (char *)kmsg;
kmsg = vim_strsave(keep_msg); kmsg = vim_strsave((char_u *)keep_msg);
msg_attr((const char *)kmsg, keep_msg_attr); msg_attr((const char *)kmsg, keep_msg_attr);
xfree(kmsg); xfree(kmsg);
} }
@ -1302,7 +1302,7 @@ static void normal_redraw(NormalState *s)
// Display message after redraw. If an external message is still visible, // Display message after redraw. If an external message is still visible,
// it contains the kept message already. // it contains the kept message already.
if (keep_msg != NULL && !msg_ext_is_visible()) { if (keep_msg != NULL && !msg_ext_is_visible()) {
char_u *const p = vim_strsave(keep_msg); char *const p = xstrdup(keep_msg);
// msg_start() will set keep_msg to NULL, make a copy // msg_start() will set keep_msg to NULL, make a copy
// first. Don't reset keep_msg, msg_attr_keep() uses it to // first. Don't reset keep_msg, msg_attr_keep() uses it to

View File

@ -2500,7 +2500,7 @@ int op_change(oparg_T *oap)
} }
firstline = ml_get(oap->start.lnum); firstline = ml_get(oap->start.lnum);
pre_textlen = (long)STRLEN(firstline); pre_textlen = (long)STRLEN(firstline);
pre_indent = (long)getwhitecols(firstline); pre_indent = (long)getwhitecols((char *)firstline);
bd.textcol = curwin->w_cursor.col; bd.textcol = curwin->w_cursor.col;
} }
@ -2521,7 +2521,7 @@ int op_change(oparg_T *oap)
// the indent, exclude that indent change from the inserted text. // the indent, exclude that indent change from the inserted text.
firstline = ml_get(oap->start.lnum); firstline = ml_get(oap->start.lnum);
if (bd.textcol > (colnr_T)pre_indent) { if (bd.textcol > (colnr_T)pre_indent) {
long new_indent = (long)getwhitecols(firstline); long new_indent = (long)getwhitecols((char *)firstline);
pre_textlen += new_indent - pre_indent; pre_textlen += new_indent - pre_indent;
bd.textcol += (colnr_T)(new_indent - pre_indent); bd.textcol += (colnr_T)(new_indent - pre_indent);
@ -3860,7 +3860,7 @@ void ex_display(exarg_T *eap)
for (p = (char_u *)yb->y_array[j]; for (p = (char_u *)yb->y_array[j];
*p != NUL && (n -= ptr2cells((char *)p)) >= 0; p++) { // -V1019 *p != NUL && (n -= ptr2cells((char *)p)) >= 0; p++) { // -V1019
clen = utfc_ptr2len((char *)p); clen = utfc_ptr2len((char *)p);
msg_outtrans_len(p, clen); msg_outtrans_len((char *)p, clen);
p += clen - 1; p += clen - 1;
} }
} }
@ -3938,10 +3938,10 @@ static void dis_msg(const char_u *p, bool skip_esc)
&& !(*p == ESC && skip_esc && *(p + 1) == NUL) && !(*p == ESC && skip_esc && *(p + 1) == NUL)
&& (n -= ptr2cells((char *)p)) >= 0) { && (n -= ptr2cells((char *)p)) >= 0) {
if ((l = utfc_ptr2len((char *)p)) > 1) { if ((l = utfc_ptr2len((char *)p)) > 1) {
msg_outtrans_len(p, l); msg_outtrans_len((char *)p, l);
p += l; p += l;
} else { } else {
msg_outtrans_len(p++, 1); msg_outtrans_len((char *)p++, 1);
} }
} }
os_breakcheck(); os_breakcheck();

View File

@ -765,12 +765,12 @@ static char *vim_version_dir(const char *vimdir)
return NULL; return NULL;
} }
char *p = concat_fnames(vimdir, VIM_VERSION_NODOT, true); char *p = concat_fnames(vimdir, VIM_VERSION_NODOT, true);
if (os_isdir((char_u *)p)) { if (os_isdir(p)) {
return p; return p;
} }
xfree(p); xfree(p);
p = concat_fnames(vimdir, RUNTIME_DIRNAME, true); p = concat_fnames(vimdir, RUNTIME_DIRNAME, true);
if (os_isdir((char_u *)p)) { if (os_isdir(p)) {
return p; return p;
} }
xfree(p); xfree(p);
@ -976,7 +976,7 @@ char *vim_getenv(const char *name)
assert(vim_path_end >= vim_path); assert(vim_path_end >= vim_path);
vim_path = xstrndup(vim_path, (size_t)(vim_path_end - vim_path)); vim_path = xstrndup(vim_path, (size_t)(vim_path_end - vim_path));
if (!os_isdir((char_u *)vim_path)) { if (!os_isdir(vim_path)) {
xfree(vim_path); xfree(vim_path);
vim_path = NULL; vim_path = NULL;
} }

View File

@ -129,10 +129,10 @@ bool os_isrealdir(const char *name)
/// Check if the given path exists and is a directory. /// Check if the given path exists and is a directory.
/// ///
/// @return `true` if `name` is a directory. /// @return `true` if `name` is a directory.
bool os_isdir(const char_u *name) bool os_isdir(const char *name)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
int32_t mode = os_getperm((const char *)name); int32_t mode = os_getperm(name);
if (mode < 0) { if (mode < 0) {
return false; return false;
} }
@ -865,7 +865,7 @@ int os_file_is_writable(const char *name)
int r; int r;
RUN_UV_FS_FUNC(r, uv_fs_access, name, W_OK, NULL); RUN_UV_FS_FUNC(r, uv_fs_access, name, W_OK, NULL);
if (r == 0) { if (r == 0) {
return os_isdir((char_u *)name) ? 2 : 1; return os_isdir(name) ? 2 : 1;
} }
return 0; return 0;
} }
@ -915,7 +915,7 @@ int os_mkdir_recurse(const char *const dir, int32_t mode, char **const failed_di
char *e = curdir + dirlen; char *e = curdir + dirlen;
const char *const real_end = e; const char *const real_end = e;
const char past_head_save = *past_head; const char past_head_save = *past_head;
while (!os_isdir((char_u *)curdir)) { while (!os_isdir(curdir)) {
e = path_tail_with_sep(curdir); e = path_tail_with_sep(curdir);
if (e <= past_head) { if (e <= past_head) {
*past_head = NUL; *past_head = NUL;

View File

@ -55,7 +55,7 @@ static void save_patterns(int num_pat, char **pat, int *num_file, char ***file)
char_u *s = vim_strsave((char_u *)pat[i]); char_u *s = vim_strsave((char_u *)pat[i]);
// Be compatible with expand_filename(): halve the number of // Be compatible with expand_filename(): halve the number of
// backslashes. // backslashes.
backslash_halve(s); backslash_halve((char *)s);
(*file)[i] = (char *)s; (*file)[i] = (char *)s;
} }
*num_file = num_pat; *num_file = num_pat;
@ -508,7 +508,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
} }
// check if this entry should be included // check if this entry should be included
dir = (os_isdir((char_u *)(*file)[i])); dir = (os_isdir((*file)[i]));
if ((dir && !(flags & EW_DIR)) || (!dir && !(flags & EW_FILE))) { if ((dir && !(flags & EW_DIR)) || (!dir && !(flags & EW_FILE))) {
continue; continue;
} }

View File

@ -326,7 +326,7 @@ bool dir_of_file_exists(char_u *fname)
} }
char c = *p; char c = *p;
*p = NUL; *p = NUL;
bool retval = os_isdir(fname); bool retval = os_isdir((char *)fname);
*p = c; *p = c;
return retval; return retval;
} }
@ -752,7 +752,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff,
// no more wildcards, check if there is a match // no more wildcards, check if there is a match
// remove backslashes for the remaining components only // remove backslashes for the remaining components only
if (*path_end != NUL) { if (*path_end != NUL) {
backslash_halve(buf + len + 1); backslash_halve((char *)buf + len + 1);
} }
// add existing file or symbolic link // add existing file or symbolic link
if ((flags & EW_ALLLINKS) ? os_fileinfo_link((char *)buf, &file_info) if ((flags & EW_ALLLINKS) ? os_fileinfo_link((char *)buf, &file_info)
@ -1135,7 +1135,7 @@ static int expand_in_path(garray_T *const gap, char_u *const pattern, const int
if (flags & EW_ADDSLASH) { if (flags & EW_ADDSLASH) {
glob_flags |= WILD_ADD_SLASH; glob_flags |= WILD_ADD_SLASH;
} }
globpath((char *)paths, pattern, gap, glob_flags); globpath((char *)paths, (char *)pattern, gap, glob_flags);
xfree(paths); xfree(paths);
return gap->ga_len; return gap->ga_len;
@ -1312,7 +1312,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
} }
if (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND))) { if (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND))) {
char_u *t = backslash_halve_save(p); char_u *t = (char_u *)backslash_halve_save((char *)p);
/* When EW_NOTFOUND is used, always add files and dirs. Makes /* When EW_NOTFOUND is used, always add files and dirs. Makes
* "vim c:/" work. */ * "vim c:/" work. */
@ -1472,7 +1472,7 @@ void addfile(garray_T *gap, char_u *f, int flags)
} }
#endif #endif
isdir = os_isdir(f); isdir = os_isdir((char *)f);
if ((isdir && !(flags & EW_DIR)) || (!isdir && !(flags & EW_FILE))) { if ((isdir && !(flags & EW_DIR)) || (!isdir && !(flags & EW_FILE))) {
return; return;
} }
@ -1845,7 +1845,7 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force)
return OK; return OK;
} }
int rv = path_to_absolute((char_u *)fname, (char_u *)buf, len, force); int rv = path_to_absolute(fname, buf, len, force);
if (rv == FAIL) { if (rv == FAIL) {
xstrlcpy(buf, fname, len); // something failed; use the filename xstrlcpy(buf, fname, len); // something failed; use the filename
} }
@ -1904,7 +1904,7 @@ void path_fix_case(char *name)
} }
// Open the directory where the file is located. // Open the directory where the file is located.
char *slash = (char *)STRRCHR(name, '/'); char *slash = strrchr(name, '/');
char *tail; char *tail;
Directory dir; Directory dir;
bool ok; bool ok;
@ -2139,7 +2139,7 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char ***file, int flags)
true); true);
emsg_off--; emsg_off--;
if (eval_pat != NULL) { if (eval_pat != NULL) {
exp_pat = (char *)concat_str(eval_pat, (char_u *)exp_pat + usedlen); exp_pat = concat_str((char *)eval_pat, exp_pat + usedlen);
} }
} }
@ -2353,20 +2353,20 @@ int append_path(char *path, const char *to_append, size_t max_len)
/// @param force also expand when "fname" is already absolute. /// @param force also expand when "fname" is already absolute.
/// ///
/// @return FAIL for failure, OK for success. /// @return FAIL for failure, OK for success.
static int path_to_absolute(const char_u *fname, char_u *buf, size_t len, int force) static int path_to_absolute(const char *fname, char *buf, size_t len, int force)
{ {
char_u *p; char *p;
*buf = NUL; *buf = NUL;
char *relative_directory = xmalloc(len); char *relative_directory = xmalloc(len);
char *end_of_path = (char *)fname; char *end_of_path = (char *)fname;
// expand it if forced or not an absolute path // expand it if forced or not an absolute path
if (force || !path_is_absolute(fname)) { if (force || !path_is_absolute((char_u *)fname)) {
p = STRRCHR(fname, '/'); p = strrchr(fname, '/');
#ifdef WIN32 #ifdef WIN32
if (p == NULL) { if (p == NULL) {
p = STRRCHR(fname, '\\'); p = strrchr(fname, '\\');
} }
#endif #endif
if (p != NULL) { if (p != NULL) {
@ -2380,19 +2380,19 @@ static int path_to_absolute(const char_u *fname, char_u *buf, size_t len, int fo
memcpy(relative_directory, fname, (size_t)(p - fname)); memcpy(relative_directory, fname, (size_t)(p - fname));
relative_directory[p - fname] = NUL; relative_directory[p - fname] = NUL;
} }
end_of_path = (char *)(p + 1); end_of_path = p + 1;
} else { } else {
relative_directory[0] = NUL; relative_directory[0] = NUL;
end_of_path = (char *)fname; end_of_path = (char *)fname;
} }
if (FAIL == path_full_dir_name(relative_directory, (char *)buf, len)) { if (FAIL == path_full_dir_name(relative_directory, buf, len)) {
xfree(relative_directory); xfree(relative_directory);
return FAIL; return FAIL;
} }
} }
xfree(relative_directory); xfree(relative_directory);
return append_path((char *)buf, end_of_path, len); return append_path(buf, end_of_path, len);
} }
/// Check if file `fname` is a full (absolute) path. /// Check if file `fname` is a full (absolute) path.

View File

@ -262,7 +262,7 @@ int linetabsize_col(int startcol, char *s)
cts.cts_vcol += lbr_chartabsize_adv(&cts); cts.cts_vcol += lbr_chartabsize_adv(&cts);
} }
clear_chartabsize_arg(&cts); clear_chartabsize_arg(&cts);
return (int)cts.cts_vcol; return cts.cts_vcol;
} }
/// Like linetabsize(), but for a given window instead of the current one. /// Like linetabsize(), but for a given window instead of the current one.
@ -530,7 +530,7 @@ static int win_nolbr_chartabsize(chartabsize_T *cts, int *headp)
wp->w_buffer->b_p_ts, wp->w_buffer->b_p_ts,
wp->w_buffer->b_p_vts_array); wp->w_buffer->b_p_vts_array);
} }
n = ptr2cells((char *)s); n = ptr2cells(s);
// Add one cell for a double-width character in the last column of the // Add one cell for a double-width character in the last column of the
// window, displayed with a ">". // window, displayed with a ">".

View File

@ -524,7 +524,7 @@ void pum_redraw(void)
} }
if (pum_rl) { if (pum_rl) {
char *rt = (char *)reverse_text(st); char *rt = reverse_text((char *)st);
char *rt_start = rt; char *rt_start = rt;
int size = vim_strsize(rt); int size = vim_strsize(rt);

View File

@ -279,7 +279,7 @@ void ex_profile(exarg_T *eap)
char *e; char *e;
int len; int len;
e = (char *)skiptowhite((char_u *)eap->arg); e = skiptowhite(eap->arg);
len = (int)(e - eap->arg); len = (int)(e - eap->arg);
e = skipwhite(e); e = skipwhite(e);
@ -354,7 +354,7 @@ void set_context_in_profile_cmd(expand_T *xp, const char *arg)
pexpand_what = PEXP_SUBCMD; pexpand_what = PEXP_SUBCMD;
xp->xp_pattern = (char *)arg; xp->xp_pattern = (char *)arg;
char_u *const end_subcmd = skiptowhite((const char_u *)arg); char_u *const end_subcmd = (char_u *)skiptowhite(arg);
if (*end_subcmd == NUL) { if (*end_subcmd == NUL) {
return; return;
} }
@ -612,7 +612,7 @@ static void func_dump_profile(FILE *fd)
.script_ctx = fp->uf_script_ctx, .script_ctx = fp->uf_script_ctx,
.channel_id = 0, .channel_id = 0,
}; };
char *p = (char *)get_scriptname(last_set, &should_free); char *p = get_scriptname(last_set, &should_free);
fprintf(fd, " Defined: %s:%" PRIdLINENR "\n", fprintf(fd, " Defined: %s:%" PRIdLINENR "\n",
p, fp->uf_script_ctx.sc_lnum); p, fp->uf_script_ctx.sc_lnum);
if (should_free) { if (should_free) {
@ -721,7 +721,7 @@ static void script_dump_profile(FILE *fd)
fprintf(fd, "\n"); fprintf(fd, "\n");
fprintf(fd, "count total (s) self (s)\n"); fprintf(fd, "count total (s) self (s)\n");
sfd = os_fopen((char *)si->sn_name, "r"); sfd = os_fopen(si->sn_name, "r");
if (sfd == NULL) { if (sfd == NULL) {
fprintf(fd, "Cannot open file!\n"); fprintf(fd, "Cannot open file!\n");
} else { } else {

View File

@ -799,7 +799,7 @@ retry:
// Convert a line if it contains a non-ASCII character // Convert a line if it contains a non-ASCII character
if (state->vc.vc_type != CONV_NONE && has_non_ascii((char_u *)state->linebuf)) { if (state->vc.vc_type != CONV_NONE && has_non_ascii((char_u *)state->linebuf)) {
char *line = (char *)string_convert(&state->vc, (char_u *)state->linebuf, &state->linelen); char *line = string_convert(&state->vc, state->linebuf, &state->linelen);
if (line != NULL) { if (line != NULL) {
if (state->linelen < IOSIZE) { if (state->linelen < IOSIZE) {
STRLCPY(state->linebuf, line, state->linelen + 1); STRLCPY(state->linebuf, line, state->linelen + 1);
@ -2129,7 +2129,7 @@ static char *qf_push_dir(char *dirbuf, struct dir_stack_T **stackptr, bool is_fi
while (ds_new) { while (ds_new) {
xfree((*stackptr)->dirname); xfree((*stackptr)->dirname);
(*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, true); (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, true);
if (os_isdir((char_u *)(*stackptr)->dirname)) { if (os_isdir((*stackptr)->dirname)) {
break; break;
} }
@ -3054,7 +3054,7 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel)
} }
msg_putchar('\n'); msg_putchar('\n');
msg_outtrans_attr(IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr); msg_outtrans_attr((char *)IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr);
if (qfp->qf_lnum != 0) { if (qfp->qf_lnum != 0) {
msg_puts_attr(":", qfSepAttr); msg_puts_attr(":", qfSepAttr);

View File

@ -123,7 +123,7 @@ char *estack_sfile(estack_arg_T which)
? &entry->es_info.ufunc->uf_script_ctx ? &entry->es_info.ufunc->uf_script_ctx
: &entry->es_info.aucmd->script_ctx); : &entry->es_info.aucmd->script_ctx);
return def_ctx->sc_sid > 0 return def_ctx->sc_sid > 0
? xstrdup((char *)(SCRIPT_ITEM(def_ctx->sc_sid).sn_name)) ? xstrdup((SCRIPT_ITEM(def_ctx->sc_sid).sn_name))
: NULL; : NULL;
} else if (entry->es_type == ETYPE_SCRIPT) { } else if (entry->es_type == ETYPE_SCRIPT) {
return xstrdup(entry->es_name); return xstrdup(entry->es_name);
@ -192,7 +192,7 @@ void runtime_init(void)
void ex_runtime(exarg_T *eap) void ex_runtime(exarg_T *eap)
{ {
char *arg = eap->arg; char *arg = eap->arg;
char *p = (char *)skiptowhite((char_u *)arg); char *p = skiptowhite(arg);
ptrdiff_t len = p - arg; ptrdiff_t len = p - arg;
int flags = eap->forceit ? DIP_ALL : 0; int flags = eap->forceit ? DIP_ALL : 0;
@ -226,9 +226,9 @@ static void source_callback(char *fname, void *cookie)
/// When "flags" has DIP_ERR: give an error message if there is no match. /// When "flags" has DIP_ERR: give an error message if there is no match.
/// ///
/// return FAIL when no file could be sourced, OK otherwise. /// return FAIL when no file could be sourced, OK otherwise.
int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback, void *cookie) int do_in_path(char *path, char *name, int flags, DoInRuntimepathCB callback, void *cookie)
{ {
char_u *tail; char *tail;
int num_files; int num_files;
char **files; char **files;
int i; int i;
@ -236,17 +236,17 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback,
// Make a copy of 'runtimepath'. Invoking the callback may change the // Make a copy of 'runtimepath'. Invoking the callback may change the
// value. // value.
char_u *rtp_copy = vim_strsave(path); char *rtp_copy = xstrdup(path);
char *buf = xmallocz(MAXPATHL); char *buf = xmallocz(MAXPATHL);
{ {
if (p_verbose > 10 && name != NULL) { if (p_verbose > 10 && name != NULL) {
verbose_enter(); verbose_enter();
smsg(_("Searching for \"%s\" in \"%s\""), name, (char *)path); smsg(_("Searching for \"%s\" in \"%s\""), name, path);
verbose_leave(); verbose_leave();
} }
// Loop over all entries in 'runtimepath'. // Loop over all entries in 'runtimepath'.
char *rtp = (char *)rtp_copy; char *rtp = rtp_copy;
while (*rtp != NUL && ((flags & DIP_ALL) || !did_one)) { while (*rtp != NUL && ((flags & DIP_ALL) || !did_one)) {
// Copy the path from 'runtimepath' to buf[]. // Copy the path from 'runtimepath' to buf[].
copy_option_part(&rtp, buf, MAXPATHL, ","); copy_option_part(&rtp, buf, MAXPATHL, ",");
@ -267,14 +267,14 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback,
did_one = true; did_one = true;
} else if (buflen + STRLEN(name) + 2 < MAXPATHL) { } else if (buflen + STRLEN(name) + 2 < MAXPATHL) {
add_pathsep(buf); add_pathsep(buf);
tail = (char_u *)buf + STRLEN(buf); tail = buf + STRLEN(buf);
// Loop over all patterns in "name" // Loop over all patterns in "name"
char *np = name; char *np = name;
while (*np != NUL && ((flags & DIP_ALL) || !did_one)) { while (*np != NUL && ((flags & DIP_ALL) || !did_one)) {
// Append the pattern from "name" to buf[]. // Append the pattern from "name" to buf[].
assert(MAXPATHL >= (tail - (char_u *)buf)); assert(MAXPATHL >= (tail - buf));
copy_option_part(&np, (char *)tail, (size_t)(MAXPATHL - (tail - (char_u *)buf)), "\t "); copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)), "\t ");
if (p_verbose > 10) { if (p_verbose > 10) {
verbose_enter(); verbose_enter();
@ -303,7 +303,7 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback,
xfree(buf); xfree(buf);
xfree(rtp_copy); xfree(rtp_copy);
if (!did_one && name != NULL) { if (!did_one && name != NULL) {
char *basepath = path == (char_u *)p_rtp ? "runtimepath" : "packpath"; char *basepath = path == p_rtp ? "runtimepath" : "packpath";
if (flags & DIP_ERR) { if (flags & DIP_ERR) {
semsg(_(e_dirnotf), basepath, name); semsg(_(e_dirnotf), basepath, name);
@ -363,19 +363,19 @@ void runtime_search_path_unref(RuntimeSearchPath path, int *ref)
/// When "flags" has DIP_ERR: give an error message if there is no match. /// When "flags" has DIP_ERR: give an error message if there is no match.
/// ///
/// return FAIL when no file could be sourced, OK otherwise. /// return FAIL when no file could be sourced, OK otherwise.
int do_in_cached_path(char_u *name, int flags, DoInRuntimepathCB callback, void *cookie) int do_in_cached_path(char *name, int flags, DoInRuntimepathCB callback, void *cookie)
{ {
char_u *tail; char *tail;
int num_files; int num_files;
char **files; char **files;
int i; int i;
bool did_one = false; bool did_one = false;
char_u buf[MAXPATHL]; char buf[MAXPATHL];
if (p_verbose > 10 && name != NULL) { if (p_verbose > 10 && name != NULL) {
verbose_enter(); verbose_enter();
smsg(_("Searching for \"%s\" in runtime path"), (char *)name); smsg(_("Searching for \"%s\" in runtime path"), name);
verbose_leave(); verbose_leave();
} }
@ -399,15 +399,15 @@ int do_in_cached_path(char_u *name, int flags, DoInRuntimepathCB callback, void
(*callback)(item.path, cookie); (*callback)(item.path, cookie);
} else if (buflen + STRLEN(name) + 2 < MAXPATHL) { } else if (buflen + STRLEN(name) + 2 < MAXPATHL) {
STRCPY(buf, item.path); STRCPY(buf, item.path);
add_pathsep((char *)buf); add_pathsep(buf);
tail = buf + STRLEN(buf); tail = buf + STRLEN(buf);
// Loop over all patterns in "name" // Loop over all patterns in "name"
char *np = (char *)name; char *np = name;
while (*np != NUL && ((flags & DIP_ALL) || !did_one)) { while (*np != NUL && ((flags & DIP_ALL) || !did_one)) {
// Append the pattern from "name" to buf[]. // Append the pattern from "name" to buf[].
assert(MAXPATHL >= (tail - buf)); assert(MAXPATHL >= (tail - buf));
copy_option_part(&np, (char *)tail, (size_t)(MAXPATHL - (tail - buf)), "\t "); copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)), "\t ");
if (p_verbose > 10) { if (p_verbose > 10) {
verbose_enter(); verbose_enter();
@ -419,7 +419,7 @@ int do_in_cached_path(char_u *name, int flags, DoInRuntimepathCB callback, void
| (flags & DIP_DIRFILE) ? (EW_DIR|EW_FILE) : 0; | (flags & DIP_DIRFILE) ? (EW_DIR|EW_FILE) : 0;
// Expand wildcards, invoke the callback for each match. // Expand wildcards, invoke the callback for each match.
char *(pat[]) = { (char *)buf }; char *(pat[]) = { buf };
if (gen_expand_wildcards(1, pat, &num_files, &files, ew_flags) == OK) { if (gen_expand_wildcards(1, pat, &num_files, &files, ew_flags) == OK) {
for (i = 0; i < num_files; i++) { for (i = 0; i < num_files; i++) {
(*callback)(files[i], cookie); (*callback)(files[i], cookie);
@ -499,7 +499,7 @@ ArrayOf(String) runtime_get_named_common(bool lua, Array pat, bool all,
if (lua) { if (lua) {
if (item->has_lua == kNone) { if (item->has_lua == kNone) {
size_t size = (size_t)snprintf(buf, buf_len, "%s/lua/", item->path); size_t size = (size_t)snprintf(buf, buf_len, "%s/lua/", item->path);
item->has_lua = (size < buf_len && os_isdir((char_u *)buf)); item->has_lua = (size < buf_len && os_isdir(buf));
} }
if (item->has_lua == kFalse) { if (item->has_lua == kFalse) {
continue; continue;
@ -534,13 +534,13 @@ done:
/// If "name" is NULL calls callback for each entry in "path". Cookie is /// If "name" is NULL calls callback for each entry in "path". Cookie is
/// passed by reference in this case, setting it to NULL indicates that callback /// passed by reference in this case, setting it to NULL indicates that callback
/// has done its job. /// has done its job.
int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, int do_in_path_and_pp(char *path, char *name, int flags, DoInRuntimepathCB callback, void *cookie)
void *cookie)
{ {
int done = FAIL; int done = FAIL;
if ((flags & DIP_NORTP) == 0) { if ((flags & DIP_NORTP) == 0) {
done |= do_in_path(path, (char *)((name && !*name) ? NULL : name), flags, callback, cookie); done |= do_in_path(path, (name && !*name) ? NULL : name, flags, callback,
cookie);
} }
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) { if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) {
@ -550,7 +550,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
char *suffix = (flags & DIP_AFTER) ? "after/" : ""; char *suffix = (flags & DIP_AFTER) ? "after/" : "";
vim_snprintf(s, len, start_dir, suffix, name); vim_snprintf(s, len, start_dir, suffix, name);
done |= do_in_path((char_u *)p_pp, s, flags & ~DIP_AFTER, callback, cookie); done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie);
xfree(s); xfree(s);
@ -560,7 +560,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
s = xmallocz(len); s = xmallocz(len);
vim_snprintf(s, len, start_dir, suffix, name); vim_snprintf(s, len, start_dir, suffix, name);
done |= do_in_path((char_u *)p_pp, s, flags & ~DIP_AFTER, callback, cookie); done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie);
xfree(s); xfree(s);
} }
@ -572,7 +572,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
char *s = xmallocz(len); char *s = xmallocz(len);
vim_snprintf(s, len, opt_dir, name); vim_snprintf(s, len, opt_dir, name);
done |= do_in_path((char_u *)p_pp, s, flags, callback, cookie); done |= do_in_path(p_pp, s, flags, callback, cookie);
xfree(s); xfree(s);
@ -582,7 +582,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
s = xmallocz(len); s = xmallocz(len);
vim_snprintf(s, len, opt_dir, name); vim_snprintf(s, len, opt_dir, name);
done |= do_in_path((char_u *)p_pp, s, flags, callback, cookie); done |= do_in_path(p_pp, s, flags, callback, cookie);
xfree(s); xfree(s);
} }
@ -625,7 +625,7 @@ static void expand_rtp_entry(RuntimeSearchPath *search_path, Map(String, handle_
} }
static void expand_pack_entry(RuntimeSearchPath *search_path, Map(String, handle_T) *rtp_used, static void expand_pack_entry(RuntimeSearchPath *search_path, Map(String, handle_T) *rtp_used,
CharVec *after_path, char_u *pack_entry, size_t pack_entry_len) CharVec *after_path, char *pack_entry, size_t pack_entry_len)
{ {
static char buf[MAXPATHL]; static char buf[MAXPATHL];
char *(start_pat[]) = { "/pack/*/start/*", "/start/*" }; // NOLINT char *(start_pat[]) = { "/pack/*/start/*", "/start/*" }; // NOLINT
@ -664,10 +664,10 @@ RuntimeSearchPath runtime_search_path_build(void)
RuntimeSearchPath search_path = KV_INITIAL_VALUE; RuntimeSearchPath search_path = KV_INITIAL_VALUE;
CharVec after_path = KV_INITIAL_VALUE; CharVec after_path = KV_INITIAL_VALUE;
static char_u buf[MAXPATHL]; static char buf[MAXPATHL];
for (char *entry = p_pp; *entry != NUL;) { for (char *entry = p_pp; *entry != NUL;) {
char *cur_entry = entry; char *cur_entry = entry;
copy_option_part(&entry, (char *)buf, MAXPATHL, ","); copy_option_part(&entry, buf, MAXPATHL, ",");
String the_entry = { .data = cur_entry, .size = STRLEN(buf) }; String the_entry = { .data = cur_entry, .size = STRLEN(buf) };
@ -678,18 +678,18 @@ RuntimeSearchPath runtime_search_path_build(void)
char *rtp_entry; char *rtp_entry;
for (rtp_entry = p_rtp; *rtp_entry != NUL;) { for (rtp_entry = p_rtp; *rtp_entry != NUL;) {
char *cur_entry = rtp_entry; char *cur_entry = rtp_entry;
copy_option_part(&rtp_entry, (char *)buf, MAXPATHL, ","); copy_option_part(&rtp_entry, buf, MAXPATHL, ",");
size_t buflen = STRLEN(buf); size_t buflen = STRLEN(buf);
if (path_is_after((char *)buf, buflen)) { if (path_is_after(buf, buflen)) {
rtp_entry = cur_entry; rtp_entry = cur_entry;
break; break;
} }
// fact: &rtp entries can contain wild chars // fact: &rtp entries can contain wild chars
expand_rtp_entry(&search_path, &rtp_used, (char *)buf, false); expand_rtp_entry(&search_path, &rtp_used, buf, false);
handle_T *h = map_ref(String, handle_T)(&pack_used, cstr_as_string((char *)buf), false); handle_T *h = map_ref(String, handle_T)(&pack_used, cstr_as_string(buf), false);
if (h) { if (h) {
(*h)++; (*h)++;
expand_pack_entry(&search_path, &rtp_used, &after_path, buf, buflen); expand_pack_entry(&search_path, &rtp_used, &after_path, buf, buflen);
@ -700,7 +700,7 @@ RuntimeSearchPath runtime_search_path_build(void)
String item = kv_A(pack_entries, i); String item = kv_A(pack_entries, i);
handle_T h = map_get(String, handle_T)(&pack_used, item); handle_T h = map_get(String, handle_T)(&pack_used, item);
if (h == 0) { if (h == 0) {
expand_pack_entry(&search_path, &rtp_used, &after_path, (char_u *)item.data, item.size); expand_pack_entry(&search_path, &rtp_used, &after_path, item.data, item.size);
} }
} }
@ -712,8 +712,8 @@ RuntimeSearchPath runtime_search_path_build(void)
// "after" dirs in rtp // "after" dirs in rtp
for (; *rtp_entry != NUL;) { for (; *rtp_entry != NUL;) {
copy_option_part(&rtp_entry, (char *)buf, MAXPATHL, ","); copy_option_part(&rtp_entry, buf, MAXPATHL, ",");
expand_rtp_entry(&search_path, &rtp_used, (char *)buf, path_is_after((char *)buf, STRLEN(buf))); expand_rtp_entry(&search_path, &rtp_used, buf, path_is_after(buf, STRLEN(buf)));
} }
// strings are not owned // strings are not owned
@ -767,13 +767,13 @@ int do_in_runtimepath(char *name, int flags, DoInRuntimepathCB callback, void *c
{ {
int success = FAIL; int success = FAIL;
if (!(flags & DIP_NORTP)) { if (!(flags & DIP_NORTP)) {
success |= do_in_cached_path((name && !*name) ? NULL : (char_u *)name, flags, callback, cookie); success |= do_in_cached_path((name && !*name) ? NULL : name, flags, callback, cookie);
flags = (flags & ~DIP_START) | DIP_NORTP; flags = (flags & ~DIP_START) | DIP_NORTP;
} }
// TODO(bfredl): we could integrate disabled OPT dirs into the cached path // TODO(bfredl): we could integrate disabled OPT dirs into the cached path
// which would effectivize ":packadd myoptpack" as well // which would effectivize ":packadd myoptpack" as well
if ((flags & (DIP_START|DIP_OPT)) && (success == FAIL || (flags & DIP_ALL))) { if ((flags & (DIP_START|DIP_OPT)) && (success == FAIL || (flags & DIP_ALL))) {
success |= do_in_path_and_pp((char_u *)p_rtp, (char_u *)name, flags, callback, cookie); success |= do_in_path_and_pp(p_rtp, name, flags, callback, cookie);
} }
return success; return success;
} }
@ -789,7 +789,7 @@ int source_runtime(char *name, int flags)
} }
/// Just like source_runtime(), but use "path" instead of 'runtimepath'. /// Just like source_runtime(), but use "path" instead of 'runtimepath'.
int source_in_path(char_u *path, char_u *name, int flags) int source_in_path(char *path, char *name, int flags)
{ {
return do_in_path_and_pp(path, name, flags, source_callback, NULL); return do_in_path_and_pp(path, name, flags, source_callback, NULL);
} }
@ -813,14 +813,14 @@ static void source_all_matches(char *pat)
/// ///
/// @param fname the package path /// @param fname the package path
/// @param is_pack whether the added dir is a "pack/*/start/*/" style package /// @param is_pack whether the added dir is a "pack/*/start/*/" style package
static int add_pack_dir_to_rtp(char_u *fname, bool is_pack) static int add_pack_dir_to_rtp(char *fname, bool is_pack)
{ {
char *p; char *p;
char *buf = NULL; char *buf = NULL;
char *afterdir = NULL; char *afterdir = NULL;
int retval = FAIL; int retval = FAIL;
char *p1 = get_past_head((char *)fname); char *p1 = get_past_head(fname);
char *p2 = p1; char *p2 = p1;
char *p3 = p1; char *p3 = p1;
char *p4 = p1; char *p4 = p1;
@ -841,7 +841,7 @@ static int add_pack_dir_to_rtp(char_u *fname, bool is_pack)
p4++; // append pathsep in order to expand symlink p4++; // append pathsep in order to expand symlink
char c = *p4; char c = *p4;
*p4 = NUL; *p4 = NUL;
char *const ffname = fix_fname((char *)fname); char *const ffname = fix_fname(fname);
*p4 = c; *p4 = c;
if (ffname == NULL) { if (ffname == NULL) {
@ -895,9 +895,9 @@ static int add_pack_dir_to_rtp(char_u *fname, bool is_pack)
} }
// check if rtp/pack/name/start/name/after exists // check if rtp/pack/name/start/name/after exists
afterdir = concat_fnames((char *)fname, "after", true); afterdir = concat_fnames(fname, "after", true);
size_t afterlen = 0; size_t afterlen = 0;
if (is_pack ? pack_has_entries((char_u *)afterdir) : os_isdir((char_u *)afterdir)) { if (is_pack ? pack_has_entries(afterdir) : os_isdir(afterdir)) {
afterlen = strlen(afterdir) + 1; // add one for comma afterlen = strlen(afterdir) + 1; // add one for comma
} }
@ -964,29 +964,29 @@ theend:
/// Load scripts in "plugin" directory of the package. /// Load scripts in "plugin" directory of the package.
/// For opt packages, also load scripts in "ftdetect" (start packages already /// For opt packages, also load scripts in "ftdetect" (start packages already
/// load these from filetype.vim) /// load these from filetype.vim)
static int load_pack_plugin(bool opt, char_u *fname) static int load_pack_plugin(bool opt, char *fname)
{ {
static const char *ftpat = "%s/ftdetect/*.vim"; // NOLINT static const char *ftpat = "%s/ftdetect/*.vim"; // NOLINT
char *const ffname = fix_fname((char *)fname); char *const ffname = fix_fname(fname);
size_t len = strlen(ffname) + STRLEN(ftpat); size_t len = strlen(ffname) + STRLEN(ftpat);
char_u *pat = xmallocz(len); char *pat = xmallocz(len);
vim_snprintf((char *)pat, len, "%s/plugin/**/*.vim", ffname); // NOLINT vim_snprintf(pat, len, "%s/plugin/**/*.vim", ffname); // NOLINT
source_all_matches((char *)pat); source_all_matches(pat);
vim_snprintf((char *)pat, len, "%s/plugin/**/*.lua", ffname); // NOLINT vim_snprintf(pat, len, "%s/plugin/**/*.lua", ffname); // NOLINT
source_all_matches((char *)pat); source_all_matches(pat);
char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes"); char *cmd = xstrdup("g:did_load_filetypes");
// If runtime/filetype.vim wasn't loaded yet, the scripts will be // If runtime/filetype.vim wasn't loaded yet, the scripts will be
// found when it loads. // found when it loads.
if (opt && eval_to_number((char *)cmd) > 0) { if (opt && eval_to_number(cmd) > 0) {
do_cmdline_cmd("augroup filetypedetect"); do_cmdline_cmd("augroup filetypedetect");
vim_snprintf((char *)pat, len, ftpat, ffname); vim_snprintf(pat, len, ftpat, ffname);
source_all_matches((char *)pat); source_all_matches(pat);
vim_snprintf((char *)pat, len, "%s/ftdetect/*.lua", ffname); // NOLINT vim_snprintf((char *)pat, len, "%s/ftdetect/*.lua", ffname); // NOLINT
source_all_matches((char *)pat); source_all_matches(pat);
do_cmdline_cmd("augroup END"); do_cmdline_cmd("augroup END");
} }
xfree(cmd); xfree(cmd);
@ -1001,7 +1001,7 @@ static int APP_ADD_DIR;
static int APP_LOAD; static int APP_LOAD;
static int APP_BOTH; static int APP_BOTH;
static void add_pack_plugin(bool opt, char_u *fname, void *cookie) static void add_pack_plugin(bool opt, char *fname, void *cookie)
{ {
if (cookie != &APP_LOAD) { if (cookie != &APP_LOAD) {
char *buf = xmalloc(MAXPATHL); char *buf = xmalloc(MAXPATHL);
@ -1010,7 +1010,7 @@ static void add_pack_plugin(bool opt, char_u *fname, void *cookie)
const char *p = (const char *)p_rtp; const char *p = (const char *)p_rtp;
while (*p != NUL) { while (*p != NUL) {
copy_option_part((char **)&p, buf, MAXPATHL, ","); copy_option_part((char **)&p, buf, MAXPATHL, ",");
if (path_fnamecmp(buf, (char *)fname) == 0) { if (path_fnamecmp(buf, fname) == 0) {
found = true; found = true;
break; break;
} }
@ -1031,25 +1031,25 @@ static void add_pack_plugin(bool opt, char_u *fname, void *cookie)
static void add_start_pack_plugin(char *fname, void *cookie) static void add_start_pack_plugin(char *fname, void *cookie)
{ {
add_pack_plugin(false, (char_u *)fname, cookie); add_pack_plugin(false, fname, cookie);
} }
static void add_opt_pack_plugin(char *fname, void *cookie) static void add_opt_pack_plugin(char *fname, void *cookie)
{ {
add_pack_plugin(true, (char_u *)fname, cookie); add_pack_plugin(true, fname, cookie);
} }
/// Add all packages in the "start" directory to 'runtimepath'. /// Add all packages in the "start" directory to 'runtimepath'.
void add_pack_start_dirs(void) void add_pack_start_dirs(void)
{ {
do_in_path((char_u *)p_pp, NULL, DIP_ALL + DIP_DIR, add_pack_start_dir, NULL); do_in_path(p_pp, NULL, DIP_ALL + DIP_DIR, add_pack_start_dir, NULL);
} }
static bool pack_has_entries(char_u *buf) static bool pack_has_entries(char *buf)
{ {
int num_files; int num_files;
char **files; char **files;
char *(pat[]) = { (char *)buf }; char *(pat[]) = { buf };
if (gen_expand_wildcards(1, pat, &num_files, &files, EW_DIR) == OK) { if (gen_expand_wildcards(1, pat, &num_files, &files, EW_DIR) == OK) {
FreeWild(num_files, files); FreeWild(num_files, files);
} }
@ -1058,7 +1058,7 @@ static bool pack_has_entries(char_u *buf)
static void add_pack_start_dir(char *fname, void *cookie) static void add_pack_start_dir(char *fname, void *cookie)
{ {
static char_u buf[MAXPATHL]; static char buf[MAXPATHL];
char *(start_pat[]) = { "/start/*", "/pack/*/start/*" }; // NOLINT char *(start_pat[]) = { "/start/*", "/pack/*/start/*" }; // NOLINT
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (STRLEN(fname) + STRLEN(start_pat[i]) + 1 > MAXPATHL) { if (STRLEN(fname) + STRLEN(start_pat[i]) + 1 > MAXPATHL) {
@ -1076,9 +1076,9 @@ static void add_pack_start_dir(char *fname, void *cookie)
void load_start_packages(void) void load_start_packages(void)
{ {
did_source_packages = true; did_source_packages = true;
do_in_path((char_u *)p_pp, "pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT do_in_path(p_pp, "pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT
add_start_pack_plugin, &APP_LOAD); add_start_pack_plugin, &APP_LOAD);
do_in_path((char_u *)p_pp, "start/*", DIP_ALL + DIP_DIR, // NOLINT do_in_path(p_pp, "start/*", DIP_ALL + DIP_DIR, // NOLINT
add_start_pack_plugin, &APP_LOAD); add_start_pack_plugin, &APP_LOAD);
} }
@ -1099,12 +1099,12 @@ void ex_packloadall(exarg_T *eap)
void load_plugins(void) void load_plugins(void)
{ {
if (p_lpl) { if (p_lpl) {
char_u *rtp_copy = (char_u *)p_rtp; char *rtp_copy = p_rtp;
char_u *const plugin_pattern_vim = (char_u *)"plugin/**/*.vim"; // NOLINT char *const plugin_pattern_vim = "plugin/**/*.vim"; // NOLINT
char_u *const plugin_pattern_lua = (char_u *)"plugin/**/*.lua"; // NOLINT char *const plugin_pattern_lua = "plugin/**/*.lua"; // NOLINT
if (!did_source_packages) { if (!did_source_packages) {
rtp_copy = vim_strsave((char_u *)p_rtp); rtp_copy = xstrdup(p_rtp);
add_pack_start_dirs(); add_pack_start_dirs();
} }
@ -1121,8 +1121,8 @@ void load_plugins(void)
} }
TIME_MSG("loading packages"); TIME_MSG("loading packages");
source_runtime((char *)plugin_pattern_vim, DIP_ALL | DIP_AFTER); source_runtime(plugin_pattern_vim, DIP_ALL | DIP_AFTER);
source_runtime((char *)plugin_pattern_lua, DIP_ALL | DIP_AFTER); source_runtime(plugin_pattern_lua, DIP_ALL | DIP_AFTER);
TIME_MSG("loading after plugins"); TIME_MSG("loading after plugins");
} }
} }
@ -1146,7 +1146,7 @@ void ex_packadd(exarg_T *eap)
// The first round don't give a "not found" error, in the second round // The first round don't give a "not found" error, in the second round
// only when nothing was found in the first round. // only when nothing was found in the first round.
res = res =
do_in_path((char_u *)p_pp, pat, DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0), do_in_path(p_pp, pat, DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0),
round == 1 ? add_start_pack_plugin : add_opt_pack_plugin, round == 1 ? add_start_pack_plugin : add_opt_pack_plugin,
eap->forceit ? &APP_ADD_DIR : &APP_BOTH); eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
xfree(pat); xfree(pat);
@ -1162,7 +1162,7 @@ void ex_packadd(exarg_T *eap)
/// 'packpath'/pack/ * /opt/ * /{dirnames}/{pat}.vim /// 'packpath'/pack/ * /opt/ * /{dirnames}/{pat}.vim
/// When "flags" has DIP_LUA: search also performed for .lua files /// When "flags" has DIP_LUA: search also performed for .lua files
/// "dirnames" is an array with one or more directory names. /// "dirnames" is an array with one or more directory names.
int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirnames[]) int ExpandRTDir(char *pat, int flags, int *num_file, char ***file, char *dirnames[])
{ {
*num_file = 0; *num_file = 0;
*file = NULL; *file = NULL;
@ -1174,11 +1174,11 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
// TODO(bfredl): this is bullshit, exandpath should not reinvent path logic. // TODO(bfredl): this is bullshit, exandpath should not reinvent path logic.
for (int i = 0; dirnames[i] != NULL; i++) { for (int i = 0; dirnames[i] != NULL; i++) {
size_t size = STRLEN(dirnames[i]) + pat_len + 7; size_t size = STRLEN(dirnames[i]) + pat_len + 7;
char_u *s = xmalloc(size); char *s = xmalloc(size);
snprintf((char *)s, size, "%s/%s*.vim", dirnames[i], pat); snprintf(s, size, "%s/%s*.vim", dirnames[i], pat);
globpath(p_rtp, s, &ga, 0); globpath(p_rtp, s, &ga, 0);
if (flags & DIP_LUA) { if (flags & DIP_LUA) {
snprintf((char *)s, size, "%s/%s*.lua", dirnames[i], pat); snprintf(s, size, "%s/%s*.lua", dirnames[i], pat);
globpath(p_rtp, s, &ga, 0); globpath(p_rtp, s, &ga, 0);
} }
xfree(s); xfree(s);
@ -1187,11 +1187,11 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
if (flags & DIP_START) { if (flags & DIP_START) {
for (int i = 0; dirnames[i] != NULL; i++) { for (int i = 0; dirnames[i] != NULL; i++) {
size_t size = STRLEN(dirnames[i]) + pat_len + 22; size_t size = STRLEN(dirnames[i]) + pat_len + 22;
char_u *s = xmalloc(size); char *s = xmalloc(size);
snprintf((char *)s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT snprintf(s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
if (flags & DIP_LUA) { if (flags & DIP_LUA) {
snprintf((char *)s, size, "pack/*/start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT snprintf(s, size, "pack/*/start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
} }
xfree(s); xfree(s);
@ -1199,11 +1199,11 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
for (int i = 0; dirnames[i] != NULL; i++) { for (int i = 0; dirnames[i] != NULL; i++) {
size_t size = STRLEN(dirnames[i]) + pat_len + 22; size_t size = STRLEN(dirnames[i]) + pat_len + 22;
char_u *s = xmalloc(size); char *s = xmalloc(size);
snprintf((char *)s, size, "start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT snprintf(s, size, "start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
if (flags & DIP_LUA) { if (flags & DIP_LUA) {
snprintf((char *)s, size, "start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT snprintf(s, size, "start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
} }
xfree(s); xfree(s);
@ -1213,11 +1213,11 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
if (flags & DIP_OPT) { if (flags & DIP_OPT) {
for (int i = 0; dirnames[i] != NULL; i++) { for (int i = 0; dirnames[i] != NULL; i++) {
size_t size = STRLEN(dirnames[i]) + pat_len + 20; size_t size = STRLEN(dirnames[i]) + pat_len + 20;
char_u *s = xmalloc(size); char *s = xmalloc(size);
snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT snprintf(s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
if (flags & DIP_LUA) { if (flags & DIP_LUA) {
snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT snprintf(s, size, "pack/*/opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
} }
xfree(s); xfree(s);
@ -1225,11 +1225,11 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
for (int i = 0; dirnames[i] != NULL; i++) { for (int i = 0; dirnames[i] != NULL; i++) {
size_t size = STRLEN(dirnames[i]) + pat_len + 20; size_t size = STRLEN(dirnames[i]) + pat_len + 20;
char_u *s = xmalloc(size); char *s = xmalloc(size);
snprintf((char *)s, size, "opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT snprintf(s, size, "opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
if (flags & DIP_LUA) { if (flags & DIP_LUA) {
snprintf((char *)s, size, "opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT snprintf(s, size, "opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
} }
xfree(s); xfree(s);
@ -1237,9 +1237,9 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
} }
for (int i = 0; i < ga.ga_len; i++) { for (int i = 0; i < ga.ga_len; i++) {
char_u *match = ((char_u **)ga.ga_data)[i]; char *match = ((char **)ga.ga_data)[i];
char_u *s = match; char *s = match;
char_u *e = s + STRLEN(s); char *e = s + STRLEN(s);
if (e - s > 4 && (STRNICMP(e - 4, ".vim", 4) == 0 if (e - s > 4 && (STRNICMP(e - 4, ".vim", 4) == 0
|| ((flags & DIP_LUA) || ((flags & DIP_LUA)
&& STRNICMP(e - 4, ".lua", 4) == 0))) { && STRNICMP(e - 4, ".lua", 4) == 0))) {
@ -1271,7 +1271,7 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
/// Expand loadplugin names: /// Expand loadplugin names:
/// 'packpath'/pack/ * /opt/{pat} /// 'packpath'/pack/ * /opt/{pat}
int ExpandPackAddDir(char_u *pat, int *num_file, char ***file) int ExpandPackAddDir(char *pat, int *num_file, char ***file)
{ {
garray_T ga; garray_T ga;
@ -1281,16 +1281,16 @@ int ExpandPackAddDir(char_u *pat, int *num_file, char ***file)
ga_init(&ga, (int)sizeof(char *), 10); ga_init(&ga, (int)sizeof(char *), 10);
size_t buflen = pat_len + 26; size_t buflen = pat_len + 26;
char_u *s = xmalloc(buflen); char *s = xmalloc(buflen);
snprintf((char *)s, buflen, "pack/*/opt/%s*", pat); // NOLINT snprintf(s, buflen, "pack/*/opt/%s*", pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
snprintf((char *)s, buflen, "opt/%s*", pat); // NOLINT snprintf(s, buflen, "opt/%s*", pat); // NOLINT
globpath(p_pp, s, &ga, 0); globpath(p_pp, s, &ga, 0);
xfree(s); xfree(s);
for (int i = 0; i < ga.ga_len; i++) { for (int i = 0; i < ga.ga_len; i++) {
char_u *match = ((char_u **)ga.ga_data)[i]; char *match = ((char **)ga.ga_data)[i];
s = (char_u *)path_tail((char *)match); s = path_tail(match);
memmove(match, s, STRLEN(s) + 1); memmove(match, s, STRLEN(s) + 1);
} }
@ -1479,7 +1479,7 @@ char *get_lib_dir(void)
// TODO(bfredl): too fragile? Ideally default_lib_dir would be made empty // TODO(bfredl): too fragile? Ideally default_lib_dir would be made empty
// in an appimage build // in an appimage build
if (strlen(default_lib_dir) != 0 if (strlen(default_lib_dir) != 0
&& os_isdir((const char_u *)default_lib_dir)) { && os_isdir(default_lib_dir)) {
return xstrdup(default_lib_dir); return xstrdup(default_lib_dir);
} }
@ -1611,7 +1611,7 @@ static void cmd_source(char *fname, exarg_T *eap)
// - after ":argdo", ":windo" or ":bufdo" // - after ":argdo", ":windo" or ":bufdo"
// - another command follows // - another command follows
// - inside a loop // - inside a loop
openscript((char_u *)fname, global_busy || listcmd_busy || eap->nextcmd != NULL openscript(fname, global_busy || listcmd_busy || eap->nextcmd != NULL
|| eap->cstack->cs_idx >= 0); || eap->cstack->cs_idx >= 0);
// ":source" read ex commands // ":source" read ex commands
@ -1691,12 +1691,12 @@ static FILE *fopen_noinh_readbin(char *filename)
/// ///
/// @return true if this line did begin with a continuation (the next line /// @return true if this line did begin with a continuation (the next line
/// should also be considered, if it exists); false otherwise /// should also be considered, if it exists); false otherwise
static bool concat_continued_line(garray_T *const ga, const int init_growsize, static bool concat_continued_line(garray_T *const ga, const int init_growsize, const char *const p,
const char_u *const p, size_t len) size_t len)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
const char *const line = (char *)skipwhite_len(p, len); const char *const line = skipwhite_len((char *)p, len);
len -= (size_t)((char_u *)line - p); len -= (size_t)(line - p);
// Skip lines starting with '\" ', concat lines starting with '\' // Skip lines starting with '\" ', concat lines starting with '\'
if (len >= 3 && STRNCMP(line, "\"\\ ", 3) == 0) { if (len >= 3 && STRNCMP(line, "\"\\ ", 3) == 0) {
return true; return true;
@ -1732,15 +1732,15 @@ static char *get_str_line(int c, void *cookie, int indent, bool do_concat)
return NULL; return NULL;
} }
const char *line = p->buf + p->offset; const char *line = p->buf + p->offset;
const char *eol = (char *)skip_to_newline((char_u *)line); const char *eol = skip_to_newline(line);
garray_T ga; garray_T ga;
ga_init(&ga, sizeof(char_u), 400); ga_init(&ga, sizeof(char), 400);
ga_concat_len(&ga, line, (size_t)(eol - line)); ga_concat_len(&ga, line, (size_t)(eol - line));
if (do_concat && vim_strchr(p_cpo, CPO_CONCAT) == NULL) { if (do_concat && vim_strchr(p_cpo, CPO_CONCAT) == NULL) {
while (eol[0] != NUL) { while (eol[0] != NUL) {
line = eol + 1; line = eol + 1;
const char_u *const next_eol = skip_to_newline((char_u *)line); const char *const next_eol = skip_to_newline(line);
if (!concat_continued_line(&ga, 400, (char_u *)line, (size_t)(next_eol - (char_u *)line))) { if (!concat_continued_line(&ga, 400, line, (size_t)(next_eol - line))) {
break; break;
} }
eol = (char *)next_eol; eol = (char *)next_eol;
@ -1770,7 +1770,7 @@ scriptitem_T *new_script_item(char *const name, scid_T *const sid_out)
SCRIPT_ITEM(script_items.ga_len).sn_name = NULL; SCRIPT_ITEM(script_items.ga_len).sn_name = NULL;
SCRIPT_ITEM(script_items.ga_len).sn_prof_on = false; SCRIPT_ITEM(script_items.ga_len).sn_prof_on = false;
} }
SCRIPT_ITEM(sid).sn_name = (char_u *)name; SCRIPT_ITEM(sid).sn_name = name;
new_script_vars(sid); // Allocate the local script variables to use for this script. new_script_vars(sid); // Allocate the local script variables to use for this script.
return &SCRIPT_ITEM(sid); return &SCRIPT_ITEM(sid);
} }
@ -1814,7 +1814,7 @@ static void cmd_source_buffer(const exarg_T *const eap)
return; return;
} }
garray_T ga; garray_T ga;
ga_init(&ga, sizeof(char_u), 400); ga_init(&ga, sizeof(char), 400);
const linenr_T final_lnum = eap->line2; const linenr_T final_lnum = eap->line2;
// Copy the contents to be executed. // Copy the contents to be executed.
for (linenr_T curr_lnum = eap->line1; curr_lnum <= final_lnum; curr_lnum++) { for (linenr_T curr_lnum = eap->line1; curr_lnum <= final_lnum; curr_lnum++) {
@ -1825,7 +1825,7 @@ static void cmd_source_buffer(const exarg_T *const eap)
ga_concat(&ga, (char *)ml_get(curr_lnum)); ga_concat(&ga, (char *)ml_get(curr_lnum));
ga_append(&ga, NL); ga_append(&ga, NL);
} }
((char_u *)ga.ga_data)[ga.ga_len - 1] = NUL; ((char *)ga.ga_data)[ga.ga_len - 1] = NUL;
const GetStrLineCookie cookie = { const GetStrLineCookie cookie = {
.buf = ga.ga_data, .buf = ga.ga_data,
.offset = 0, .offset = 0,
@ -1886,7 +1886,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
if (fname_exp == NULL) { if (fname_exp == NULL) {
return retval; return retval;
} }
if (os_isdir((char_u *)fname_exp)) { if (os_isdir(fname_exp)) {
smsg(_("Cannot source a directory: \"%s\""), fname); smsg(_("Cannot source a directory: \"%s\""), fname);
goto theend; goto theend;
} }
@ -1963,7 +1963,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
cookie.finished = false; cookie.finished = false;
// Check if this script has a breakpoint. // Check if this script has a breakpoint.
cookie.breakpoint = dbg_find_breakpoint(true, (char_u *)fname_exp, (linenr_T)0); cookie.breakpoint = dbg_find_breakpoint(true, fname_exp, (linenr_T)0);
cookie.fname = fname_exp; cookie.fname = fname_exp;
cookie.dbg_tick = debug_tick; cookie.dbg_tick = debug_tick;
@ -1992,7 +1992,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
si = get_current_script_id(&fname_exp, &current_sctx); si = get_current_script_id(&fname_exp, &current_sctx);
// Keep the sourcing name/lnum, for recursive calls. // Keep the sourcing name/lnum, for recursive calls.
estack_push(ETYPE_SCRIPT, (char *)si->sn_name, 0); estack_push(ETYPE_SCRIPT, si->sn_name, 0);
if (l_do_profiling == PROF_YES) { if (l_do_profiling == PROF_YES) {
bool forceit = false; bool forceit = false;
@ -2025,7 +2025,7 @@ int do_source(char *fname, int check_other, int is_vimrc)
&& firstline[1] == 0xbb && firstline[2] == 0xbf) { && firstline[1] == 0xbb && firstline[2] == 0xbf) {
// Found BOM; setup conversion, skip over BOM and recode the line. // Found BOM; setup conversion, skip over BOM and recode the line.
convert_setup(&cookie.conv, "utf-8", p_enc); convert_setup(&cookie.conv, "utf-8", p_enc);
p = (char *)string_convert(&cookie.conv, (char_u *)firstline + 3, NULL); p = string_convert(&cookie.conv, (char *)firstline + 3, NULL);
if (p == NULL) { if (p == NULL) {
p = xstrdup((char *)firstline + 3); p = xstrdup((char *)firstline + 3);
} }
@ -2128,7 +2128,7 @@ scriptitem_T *get_current_script_id(char **fnamep, sctx_T *ret_sctx)
} }
if (script_sctx.sc_sid == 0) { if (script_sctx.sc_sid == 0) {
si = new_script_item(*fnamep, &script_sctx.sc_sid); si = new_script_item(*fnamep, &script_sctx.sc_sid);
*fnamep = xstrdup((char *)si->sn_name); *fnamep = xstrdup(si->sn_name);
} }
if (ret_sctx != NULL) { if (ret_sctx != NULL) {
*ret_sctx = script_sctx; *ret_sctx = script_sctx;
@ -2145,7 +2145,7 @@ void ex_scriptnames(exarg_T *eap)
if (eap->line2 < 1 || eap->line2 > script_items.ga_len) { if (eap->line2 < 1 || eap->line2 > script_items.ga_len) {
emsg(_(e_invarg)); emsg(_(e_invarg));
} else { } else {
eap->arg = (char *)SCRIPT_ITEM(eap->line2).sn_name; eap->arg = SCRIPT_ITEM(eap->line2).sn_name;
do_exedit(eap, NULL); do_exedit(eap, NULL);
} }
return; return;
@ -2153,7 +2153,7 @@ void ex_scriptnames(exarg_T *eap)
for (int i = 1; i <= script_items.ga_len && !got_int; i++) { for (int i = 1; i <= script_items.ga_len && !got_int; i++) {
if (SCRIPT_ITEM(i).sn_name != NULL) { if (SCRIPT_ITEM(i).sn_name != NULL) {
home_replace(NULL, (char *)SCRIPT_ITEM(i).sn_name, (char *)NameBuff, MAXPATHL, true); home_replace(NULL, SCRIPT_ITEM(i).sn_name, (char *)NameBuff, MAXPATHL, true);
vim_snprintf((char *)IObuff, IOSIZE, "%3d: %s", i, NameBuff); vim_snprintf((char *)IObuff, IOSIZE, "%3d: %s", i, NameBuff);
if (!message_filtered((char *)IObuff)) { if (!message_filtered((char *)IObuff)) {
msg_putchar('\n'); msg_putchar('\n');
@ -2179,40 +2179,40 @@ void scriptnames_slash_adjust(void)
/// Get a pointer to a script name. Used for ":verbose set". /// Get a pointer to a script name. Used for ":verbose set".
/// Message appended to "Last set from " /// Message appended to "Last set from "
char_u *get_scriptname(LastSet last_set, bool *should_free) char *get_scriptname(LastSet last_set, bool *should_free)
{ {
*should_free = false; *should_free = false;
switch (last_set.script_ctx.sc_sid) { switch (last_set.script_ctx.sc_sid) {
case SID_MODELINE: case SID_MODELINE:
return (char_u *)_("modeline"); return _("modeline");
case SID_CMDARG: case SID_CMDARG:
return (char_u *)_("--cmd argument"); return _("--cmd argument");
case SID_CARG: case SID_CARG:
return (char_u *)_("-c argument"); return _("-c argument");
case SID_ENV: case SID_ENV:
return (char_u *)_("environment variable"); return _("environment variable");
case SID_ERROR: case SID_ERROR:
return (char_u *)_("error handler"); return _("error handler");
case SID_WINLAYOUT: case SID_WINLAYOUT:
return (char_u *)_("changed window size"); return _("changed window size");
case SID_LUA: case SID_LUA:
return (char_u *)_("Lua"); return _("Lua");
case SID_API_CLIENT: case SID_API_CLIENT:
snprintf((char *)IObuff, IOSIZE, _("API client (channel id %" PRIu64 ")"), last_set.channel_id); snprintf((char *)IObuff, IOSIZE, _("API client (channel id %" PRIu64 ")"), last_set.channel_id);
return IObuff; return (char *)IObuff;
case SID_STR: case SID_STR:
return (char_u *)_("anonymous :source"); return _("anonymous :source");
default: { default: {
char *const sname = (char *)SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name; char *const sname = SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name;
if (sname == NULL) { if (sname == NULL) {
snprintf((char *)IObuff, IOSIZE, _("anonymous :source (script id %d)"), snprintf((char *)IObuff, IOSIZE, _("anonymous :source (script id %d)"),
last_set.script_ctx.sc_sid); last_set.script_ctx.sc_sid);
return IObuff; return (char *)IObuff;
} }
*should_free = true; *should_free = true;
return (char_u *)home_replace_save(NULL, sname); return home_replace_save(NULL, sname);
} }
} }
} }
@ -2248,7 +2248,7 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
// If breakpoints have been added/deleted need to check for it. // If breakpoints have been added/deleted need to check for it.
if (sp->dbg_tick < debug_tick) { if (sp->dbg_tick < debug_tick) {
sp->breakpoint = dbg_find_breakpoint(true, (char_u *)sp->fname, SOURCING_LNUM); sp->breakpoint = dbg_find_breakpoint(true, sp->fname, SOURCING_LNUM);
sp->dbg_tick = debug_tick; sp->dbg_tick = debug_tick;
} }
if (do_profiling == PROF_YES) { if (do_profiling == PROF_YES) {
@ -2287,11 +2287,10 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
|| (p[0] == '"' && p[1] == '\\' && p[2] == ' '))) { || (p[0] == '"' && p[1] == '\\' && p[2] == ' '))) {
garray_T ga; garray_T ga;
ga_init(&ga, (int)sizeof(char_u), 400); ga_init(&ga, (int)sizeof(char), 400);
ga_concat(&ga, line); ga_concat(&ga, line);
while (sp->nextline != NULL while (sp->nextline != NULL
&& concat_continued_line(&ga, 400, (char_u *)sp->nextline, && concat_continued_line(&ga, 400, sp->nextline, STRLEN(sp->nextline))) {
STRLEN(sp->nextline))) {
xfree(sp->nextline); xfree(sp->nextline);
sp->nextline = get_one_sourceline(sp); sp->nextline = get_one_sourceline(sp);
} }
@ -2305,7 +2304,7 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
char *s; char *s;
// Convert the encoding of the script line. // Convert the encoding of the script line.
s = (char *)string_convert(&sp->conv, (char_u *)line, NULL); s = string_convert(&sp->conv, line, NULL);
if (s != NULL) { if (s != NULL) {
xfree(line); xfree(line);
line = s; line = s;
@ -2314,9 +2313,9 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
// Did we encounter a breakpoint? // Did we encounter a breakpoint?
if (sp->breakpoint != 0 && sp->breakpoint <= SOURCING_LNUM) { if (sp->breakpoint != 0 && sp->breakpoint <= SOURCING_LNUM) {
dbg_breakpoint((char_u *)sp->fname, SOURCING_LNUM); dbg_breakpoint(sp->fname, SOURCING_LNUM);
// Find next breakpoint. // Find next breakpoint.
sp->breakpoint = dbg_find_breakpoint(true, (char_u *)sp->fname, SOURCING_LNUM); sp->breakpoint = dbg_find_breakpoint(true, sp->fname, SOURCING_LNUM);
sp->dbg_tick = debug_tick; sp->dbg_tick = debug_tick;
} }

View File

@ -51,7 +51,7 @@ typedef enum {
} estack_arg_T; } estack_arg_T;
typedef struct scriptitem_S { typedef struct scriptitem_S {
char_u *sn_name; char *sn_name;
bool sn_prof_on; ///< true when script is/was profiled bool sn_prof_on; ///< true when script is/was profiled
bool sn_pr_force; ///< forceit: profile functions in this script bool sn_pr_force; ///< forceit: profile functions in this script
proftime_T sn_pr_child; ///< time set when going into first child proftime_T sn_pr_child; ///< time set when going into first child

View File

@ -1270,7 +1270,7 @@ static int get_encoded_char_adv(const char_u **p)
int64_t num = 0; int64_t num = 0;
for (int bytes = s[1] == 'x' ? 1 : s[1] == 'u' ? 2 : 4; bytes > 0; bytes--) { for (int bytes = s[1] == 'x' ? 1 : s[1] == 'u' ? 2 : 4; bytes > 0; bytes--) {
*p += 2; *p += 2;
int n = hexhex2nr(*p); int n = hexhex2nr((char *)(*p));
if (n < 0) { if (n < 0) {
return 0; return 0;
} }

View File

@ -170,7 +170,7 @@ int search_regcomp(char_u *pat, int pat_save, int pat_use, int options, regmmatc
} }
if (curwin->w_p_rl && *curwin->w_p_rlc == 's') { if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {
mr_pattern = reverse_text(pat); mr_pattern = (char_u *)reverse_text((char *)pat);
mr_pattern_alloced = true; mr_pattern_alloced = true;
} else { } else {
mr_pattern = pat; mr_pattern = pat;
@ -1261,7 +1261,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
// it would be blanked out again very soon. Show it on the // it would be blanked out again very soon. Show it on the
// left, but do reverse the text. // left, but do reverse the text.
if (curwin->w_p_rl && *curwin->w_p_rlc == 's') { if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {
char_u *r = reverse_text(trunc != NULL ? trunc : msgbuf); char_u *r = (char_u *)reverse_text(trunc != NULL ? (char *)trunc : (char *)msgbuf);
xfree(msgbuf); xfree(msgbuf);
msgbuf = r; msgbuf = r;
// move reversed text to beginning of buffer // move reversed text to beginning of buffer
@ -3666,7 +3666,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
if (new_fname != NULL) { if (new_fname != NULL) {
// using "new_fname" is more reliable, e.g., when // using "new_fname" is more reliable, e.g., when
// 'includeexpr' is set. // 'includeexpr' is set.
msg_outtrans_attr(new_fname, HL_ATTR(HLF_D)); msg_outtrans_attr((char *)new_fname, HL_ATTR(HLF_D));
} else { } else {
/* /*
* Isolate the file name. * Isolate the file name.
@ -3702,7 +3702,7 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
} }
save_char = p[i]; save_char = p[i];
p[i] = NUL; p[i] = NUL;
msg_outtrans_attr(p, HL_ATTR(HLF_D)); msg_outtrans_attr((char *)p, HL_ATTR(HLF_D));
p[i] = save_char; p[i] = save_char;
} }

View File

@ -3023,7 +3023,7 @@ shada_write_file_nomerge: {}
if (tail != fname) { if (tail != fname) {
const char tail_save = *tail; const char tail_save = *tail;
*tail = NUL; *tail = NUL;
if (!os_isdir((char_u *)fname)) { if (!os_isdir(fname)) {
int ret; int ret;
char *failed_dir; char *failed_dir;
if ((ret = os_mkdir_recurse(fname, 0700, &failed_dir)) != 0) { if ((ret = os_mkdir_recurse(fname, 0700, &failed_dir)) != 0) {

View File

@ -858,7 +858,7 @@ static void sign_define_init_icon(sign_T *sp, char_u *icon)
{ {
xfree(sp->sn_icon); xfree(sp->sn_icon);
sp->sn_icon = vim_strsave(icon); sp->sn_icon = vim_strsave(icon);
backslash_halve(sp->sn_icon); backslash_halve((char *)sp->sn_icon);
} }
/// Initialize the text for a new sign /// Initialize the text for a new sign
@ -1353,7 +1353,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
if (STRNCMP(arg, "line=", 5) == 0) { if (STRNCMP(arg, "line=", 5) == 0) {
arg += 5; arg += 5;
*lnum = atoi((char *)arg); *lnum = atoi((char *)arg);
arg = skiptowhite(arg); arg = (char_u *)skiptowhite((char *)arg);
lnum_arg = true; lnum_arg = true;
} else if (STRNCMP(arg, "*", 1) == 0 && cmd == SIGNCMD_UNPLACE) { } else if (STRNCMP(arg, "*", 1) == 0 && cmd == SIGNCMD_UNPLACE) {
if (*signid != -1) { if (*signid != -1) {
@ -1361,11 +1361,11 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
return FAIL; return FAIL;
} }
*signid = -2; *signid = -2;
arg = skiptowhite(arg + 1); arg = (char_u *)skiptowhite((char *)arg + 1);
} else if (STRNCMP(arg, "name=", 5) == 0) { } else if (STRNCMP(arg, "name=", 5) == 0) {
arg += 5; arg += 5;
name = arg; name = arg;
arg = skiptowhite(arg); arg = (char_u *)skiptowhite((char *)arg);
if (*arg != NUL) { if (*arg != NUL) {
*arg++ = NUL; *arg++ = NUL;
} }
@ -1376,14 +1376,14 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
} else if (STRNCMP(arg, "group=", 6) == 0) { } else if (STRNCMP(arg, "group=", 6) == 0) {
arg += 6; arg += 6;
*group = arg; *group = arg;
arg = skiptowhite(arg); arg = (char_u *)skiptowhite((char *)arg);
if (*arg != NUL) { if (*arg != NUL) {
*arg++ = NUL; *arg++ = NUL;
} }
} else if (STRNCMP(arg, "priority=", 9) == 0) { } else if (STRNCMP(arg, "priority=", 9) == 0) {
arg += 9; arg += 9;
*prio = atoi((char *)arg); *prio = atoi((char *)arg);
arg = skiptowhite(arg); arg = (char_u *)skiptowhite((char *)arg);
} else if (STRNCMP(arg, "file=", 5) == 0) { } else if (STRNCMP(arg, "file=", 5) == 0) {
arg += 5; arg += 5;
filename = arg; filename = arg;
@ -1427,7 +1427,7 @@ void ex_sign(exarg_T *eap)
sign_T *sp; sign_T *sp;
// Parse the subcommand. // Parse the subcommand.
p = skiptowhite(arg); p = (char_u *)skiptowhite((char *)arg);
idx = sign_cmd_idx(arg, p); idx = sign_cmd_idx(arg, p);
if (idx == SIGNCMD_LAST) { if (idx == SIGNCMD_LAST) {
semsg(_("E160: Unknown sign command: %s"), arg); semsg(_("E160: Unknown sign command: %s"), arg);
@ -1449,7 +1449,7 @@ void ex_sign(exarg_T *eap)
// Isolate the sign name. If it's a number skip leading zeroes, // Isolate the sign name. If it's a number skip leading zeroes,
// so that "099" and "99" are the same sign. But keep "0". // so that "099" and "99" are the same sign. But keep "0".
p = skiptowhite(arg); p = (char_u *)skiptowhite((char *)arg);
if (*p != NUL) { if (*p != NUL) {
*p++ = NUL; *p++ = NUL;
} }
@ -1789,7 +1789,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
expand_what = EXP_SUBCMD; expand_what = EXP_SUBCMD;
xp->xp_pattern = (char *)arg; xp->xp_pattern = (char *)arg;
end_subcmd = skiptowhite(arg); end_subcmd = (char_u *)skiptowhite((char *)arg);
if (*end_subcmd == NUL) { if (*end_subcmd == NUL) {
// expand subcmd name // expand subcmd name
// :sign {subcmd}<CTRL-D> // :sign {subcmd}<CTRL-D>
@ -1814,7 +1814,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
do { do {
p = (char_u *)skipwhite((char *)p); p = (char_u *)skipwhite((char *)p);
last = p; last = p;
p = skiptowhite(p); p = (char_u *)skiptowhite((char *)p);
} while (*p != NUL); } while (*p != NUL);
p = (char_u *)vim_strchr((char *)last, '='); p = (char_u *)vim_strchr((char *)last, '=');

View File

@ -243,7 +243,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
if (*ptr == '0' && (ptr[1] == 'b' || ptr[1] == 'B')) { if (*ptr == '0' && (ptr[1] == 'b' || ptr[1] == 'B')) {
mi.mi_end = (char_u *)skipbin((char *)ptr + 2); mi.mi_end = (char_u *)skipbin((char *)ptr + 2);
} else if (*ptr == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) { } else if (*ptr == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) {
mi.mi_end = skiphex(ptr + 2); mi.mi_end = (char_u *)skiphex((char *)ptr + 2);
} else { } else {
mi.mi_end = (char_u *)skipdigits((char *)ptr); mi.mi_end = (char_u *)skipdigits((char *)ptr);
} }
@ -1258,10 +1258,10 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att
// For checking first word with a capital skip white space. // For checking first word with a capital skip white space.
if (capcol == 0) { if (capcol == 0) {
capcol = (int)getwhitecols(line); capcol = (int)getwhitecols((char *)line);
} else if (curline && wp == curwin) { } else if (curline && wp == curwin) {
// For spellbadword(): check if first word needs a capital. // For spellbadword(): check if first word needs a capital.
col = (int)getwhitecols(line); col = (int)getwhitecols((char *)line);
if (check_need_cap(lnum, col)) { if (check_need_cap(lnum, col)) {
capcol = col; capcol = col;
} }
@ -1876,7 +1876,7 @@ char *did_set_spelllang(win_T *wp)
// Check if we loaded this language before. // Check if we loaded this language before.
for (slang = first_lang; slang != NULL; slang = slang->sl_next) { for (slang = first_lang; slang != NULL; slang = slang->sl_next) {
if (path_full_compare((char *)lang, (char *)slang->sl_fname, false, true) if (path_full_compare((char *)lang, slang->sl_fname, false, true)
== kEqualFiles) { == kEqualFiles) {
break; break;
} }
@ -1925,7 +1925,7 @@ char *did_set_spelllang(win_T *wp)
// Loop over the languages, there can be several files for "lang". // Loop over the languages, there can be several files for "lang".
for (slang = first_lang; slang != NULL; slang = slang->sl_next) { for (slang = first_lang; slang != NULL; slang = slang->sl_next) {
if (filename if (filename
? path_full_compare((char *)lang, (char *)slang->sl_fname, false, true) == kEqualFiles ? path_full_compare((char *)lang, slang->sl_fname, false, true) == kEqualFiles
: STRICMP(lang, slang->sl_name) == 0) { : STRICMP(lang, slang->sl_name) == 0) {
region_mask = REGION_ALL; region_mask = REGION_ALL;
if (!filename && region != NULL) { if (!filename && region != NULL) {
@ -1981,7 +1981,7 @@ char *did_set_spelllang(win_T *wp)
// If it was already found above then skip it. // If it was already found above then skip it.
for (c = 0; c < ga.ga_len; c++) { for (c = 0; c < ga.ga_len; c++) {
p = LANGP_ENTRY(ga, c)->lp_slang->sl_fname; p = (char_u *)LANGP_ENTRY(ga, c)->lp_slang->sl_fname;
if (p != NULL if (p != NULL
&& path_full_compare((char *)spf_name, (char *)p, false, true) == kEqualFiles) { && path_full_compare((char *)spf_name, (char *)p, false, true) == kEqualFiles) {
break; break;
@ -1994,7 +1994,7 @@ char *did_set_spelllang(win_T *wp)
// Check if it was loaded already. // Check if it was loaded already.
for (slang = first_lang; slang != NULL; slang = slang->sl_next) { for (slang = first_lang; slang != NULL; slang = slang->sl_next) {
if (path_full_compare((char *)spf_name, (char *)slang->sl_fname, false, true) if (path_full_compare((char *)spf_name, slang->sl_fname, false, true)
== kEqualFiles) { == kEqualFiles) {
break; break;
} }
@ -2473,7 +2473,7 @@ bool check_need_cap(linenr_T lnum, colnr_T col)
char_u *line = get_cursor_line_ptr(); char_u *line = get_cursor_line_ptr();
char_u *line_copy = NULL; char_u *line_copy = NULL;
colnr_T endcol = 0; colnr_T endcol = 0;
if (getwhitecols(line) >= (int)col) { if (getwhitecols((char *)line) >= (int)col) {
// At start of line, check if previous line is empty or sentence // At start of line, check if previous line is empty or sentence
// ends there. // ends there.
if (lnum == 1) { if (lnum == 1) {
@ -2484,7 +2484,7 @@ bool check_need_cap(linenr_T lnum, colnr_T col)
need_cap = true; need_cap = true;
} else { } else {
// Append a space in place of the line break. // Append a space in place of the line break.
line_copy = concat_str(line, (char_u *)" "); line_copy = (char_u *)concat_str((char *)line, " ");
line = line_copy; line = line_copy;
endcol = (colnr_T)STRLEN(line); endcol = (colnr_T)STRLEN(line);
} }
@ -3599,8 +3599,8 @@ char *compile_cap_prog(synblock_T *synblock)
synblock->b_cap_prog = NULL; synblock->b_cap_prog = NULL;
} else { } else {
// Prepend a ^ so that we only match at one column // Prepend a ^ so that we only match at one column
char_u *re = concat_str((char_u *)"^", (char_u *)synblock->b_p_spc); char *re = concat_str("^", synblock->b_p_spc);
synblock->b_cap_prog = vim_regcomp((char *)re, RE_MAGIC); synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
xfree(re); xfree(re);
if (synblock->b_cap_prog == NULL) { if (synblock->b_cap_prog == NULL) {
synblock->b_cap_prog = rp; // restore the previous program synblock->b_cap_prog = rp; // restore the previous program

View File

@ -115,9 +115,9 @@ typedef struct slang_S slang_T;
struct slang_S { struct slang_S {
slang_T *sl_next; // next language slang_T *sl_next; // next language
char_u *sl_name; // language name "en", "en.rare", "nl", etc. char_u *sl_name; // language name "en", "en.rare", "nl", etc.
char_u *sl_fname; // name of .spl file char *sl_fname; // name of .spl file
bool sl_add; // true if it's a .add file. bool sl_add; // true if it's a .add file.
char_u *sl_fbyts; // case-folded word bytes char_u *sl_fbyts; // case-folded word bytes
long sl_fbyts_len; // length of sl_fbyts long sl_fbyts_len; // length of sl_fbyts

View File

@ -604,7 +604,7 @@ slang_T *spell_load_file(char_u *fname, char_u *lang, slang_T *old_lp, bool sile
lp = slang_alloc(lang); lp = slang_alloc(lang);
// Remember the file name, used to reload the file when it's updated. // Remember the file name, used to reload the file when it's updated.
lp->sl_fname = vim_strsave(fname); lp->sl_fname = (char *)vim_strsave(fname);
// Check for .add.spl. // Check for .add.spl.
lp->sl_add = strstr(path_tail((char *)fname), SPL_FNAME_ADD) != NULL; lp->sl_add = strstr(path_tail((char *)fname), SPL_FNAME_ADD) != NULL;
@ -869,12 +869,12 @@ static void tree_count_words(char_u *byts, idx_T *idxs)
} }
} }
// Load the .sug files for languages that have one and weren't loaded yet. /// Load the .sug files for languages that have one and weren't loaded yet.
void suggest_load_files(void) void suggest_load_files(void)
{ {
langp_T *lp; langp_T *lp;
slang_T *slang; slang_T *slang;
char_u *dotp; char *dotp;
FILE *fd; FILE *fd;
char_u buf[MAXWLEN]; char_u buf[MAXWLEN];
int i; int i;
@ -894,12 +894,12 @@ void suggest_load_files(void)
// don't try again and again. // don't try again and again.
slang->sl_sugloaded = true; slang->sl_sugloaded = true;
dotp = STRRCHR(slang->sl_fname, '.'); dotp = strrchr(slang->sl_fname, '.');
if (dotp == NULL || FNAMECMP(dotp, ".spl") != 0) { if (dotp == NULL || FNAMECMP(dotp, ".spl") != 0) {
continue; continue;
} }
STRCPY(dotp, ".sug"); STRCPY(dotp, ".sug");
fd = os_fopen((char *)slang->sl_fname, "r"); fd = os_fopen(slang->sl_fname, "r");
if (fd == NULL) { if (fd == NULL) {
goto nextone; goto nextone;
} }
@ -1822,7 +1822,7 @@ static void spell_reload_one(char_u *fname, bool added_word)
bool didit = false; bool didit = false;
for (slang = first_lang; slang != NULL; slang = slang->sl_next) { for (slang = first_lang; slang != NULL; slang = slang->sl_next) {
if (path_full_compare((char *)fname, (char *)slang->sl_fname, false, true) == kEqualFiles) { if (path_full_compare((char *)fname, slang->sl_fname, false, true) == kEqualFiles) {
slang_clear(slang); slang_clear(slang);
if (spell_load_file(fname, NULL, slang, false) == NULL) { if (spell_load_file(fname, NULL, slang, false) == NULL) {
// reloading failed, clear the language // reloading failed, clear the language
@ -2075,7 +2075,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
// Convert from "SET" to 'encoding' when needed. // Convert from "SET" to 'encoding' when needed.
xfree(pc); xfree(pc);
if (spin->si_conv.vc_type != CONV_NONE) { if (spin->si_conv.vc_type != CONV_NONE) {
pc = string_convert(&spin->si_conv, rline, NULL); pc = (char_u *)string_convert(&spin->si_conv, (char *)rline, NULL);
if (pc == NULL) { if (pc == NULL) {
smsg(_("Conversion failure for word in %s line %d: %s"), smsg(_("Conversion failure for word in %s line %d: %s"),
fname, lnum, rline); fname, lnum, rline);
@ -3155,7 +3155,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
// Convert from "SET" to 'encoding' when needed. // Convert from "SET" to 'encoding' when needed.
if (spin->si_conv.vc_type != CONV_NONE) { if (spin->si_conv.vc_type != CONV_NONE) {
pc = string_convert(&spin->si_conv, line, NULL); pc = (char_u *)string_convert(&spin->si_conv, (char *)line, NULL);
if (pc == NULL) { if (pc == NULL) {
smsg(_("Conversion failure for word in %s line %d: %s"), smsg(_("Conversion failure for word in %s line %d: %s"),
fname, lnum, line); fname, lnum, line);
@ -3701,7 +3701,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
// Convert from "/encoding={encoding}" to 'encoding' when needed. // Convert from "/encoding={encoding}" to 'encoding' when needed.
xfree(pc); xfree(pc);
if (spin->si_conv.vc_type != CONV_NONE) { if (spin->si_conv.vc_type != CONV_NONE) {
pc = string_convert(&spin->si_conv, rline, NULL); pc = (char_u *)string_convert(&spin->si_conv, (char *)rline, NULL);
if (pc == NULL) { if (pc == NULL) {
smsg(_("Conversion failure for word in %s line %ld: %s"), smsg(_("Conversion failure for word in %s line %ld: %s"),
fname, lnum, rline); fname, lnum, rline);
@ -4907,7 +4907,7 @@ static void spell_make_sugfile(spellinfo_T *spin, char *wfname)
// of the code for the soundfolding stuff. // of the code for the soundfolding stuff.
// It might have been done already by spell_reload_one(). // It might have been done already by spell_reload_one().
for (slang = first_lang; slang != NULL; slang = slang->sl_next) { for (slang = first_lang; slang != NULL; slang = slang->sl_next) {
if (path_full_compare(wfname, (char *)slang->sl_fname, false, true) if (path_full_compare(wfname, slang->sl_fname, false, true)
== kEqualFiles) { == kEqualFiles) {
break; break;
} }
@ -5343,7 +5343,7 @@ static void mkspell(int fcount, char **fnames, bool ascii, bool over_write, bool
emsg(_(e_exists)); emsg(_(e_exists));
goto theend; goto theend;
} }
if (os_isdir((char_u *)wfname)) { if (os_isdir(wfname)) {
semsg(_(e_isadir2), wfname); semsg(_(e_isadir2), wfname);
goto theend; goto theend;
} }
@ -5723,7 +5723,7 @@ static void init_spellfile(void)
"/%.*s", (int)(lend - lstart), lstart); "/%.*s", (int)(lend - lstart), lstart);
} }
l = (int)STRLEN(buf); l = (int)STRLEN(buf);
fname = LANGP_ENTRY(curwin->w_s->b_langp, 0) fname = (char_u *)LANGP_ENTRY(curwin->w_s->b_langp, 0)
->lp_slang->sl_fname; ->lp_slang->sl_fname;
vim_snprintf((char *)buf + l, MAXPATHL - (size_t)l, ".%s.add", vim_snprintf((char *)buf + l, MAXPATHL - (size_t)l, ".%s.add",
((fname != NULL ((fname != NULL

View File

@ -972,7 +972,7 @@ static void suggest_try_special(suginfo_T *su)
char_u word[MAXWLEN]; char_u word[MAXWLEN];
// Recognize a word that is repeated: "the the". // Recognize a word that is repeated: "the the".
char_u *p = skiptowhite(su->su_fbadword); char_u *p = (char_u *)skiptowhite((char *)su->su_fbadword);
size_t len = (size_t)(p - su->su_fbadword); size_t len = (size_t)(p - su->su_fbadword);
p = (char_u *)skipwhite((char *)p); p = (char_u *)skipwhite((char *)p);
if (STRLEN(p) == len && STRNCMP(su->su_fbadword, p, len) == 0) { if (STRLEN(p) == len && STRNCMP(su->su_fbadword, p, len) == 0) {
@ -1369,8 +1369,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
if (compound_ok) { if (compound_ok) {
p = preword; p = preword;
while (*skiptowhite(p) != NUL) { while (*skiptowhite((char *)p) != NUL) {
p = (char_u *)skipwhite((char *)skiptowhite(p)); p = (char_u *)skipwhite(skiptowhite((char *)p));
} }
if (fword_ends && !can_compound(slang, p, if (fword_ends && !can_compound(slang, p,
compflags + sp->ts_compsplit)) { compflags + sp->ts_compsplit)) {
@ -1590,8 +1590,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
break; break;
} }
p = preword; p = preword;
while (*skiptowhite(p) != NUL) { while (*skiptowhite((char *)p) != NUL) {
p = (char_u *)skipwhite((char *)skiptowhite(p)); p = (char_u *)skipwhite(skiptowhite((char *)p));
} }
if (sp->ts_complen > sp->ts_compsplit if (sp->ts_complen > sp->ts_compsplit
&& !can_compound(slang, p, && !can_compound(slang, p,
@ -2636,8 +2636,8 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
// removing the space. Don't do it when the good word also contains a // removing the space. Don't do it when the good word also contains a
// space. // space.
if (ascii_iswhite(su->su_badptr[su->su_badlen]) if (ascii_iswhite(su->su_badptr[su->su_badlen])
&& *skiptowhite(stp->st_word) == NUL) { && *skiptowhite((char *)stp->st_word) == NUL) {
for (p = fword; *(p = skiptowhite(p)) != NUL;) { for (p = fword; *(p = (char_u *)skiptowhite((char *)p)) != NUL;) {
STRMOVE(p, p + 1); STRMOVE(p, p + 1);
} }
} }

View File

@ -503,7 +503,7 @@ static int sort_compare(const void *s1, const void *s2)
void sort_strings(char **files, int count) void sort_strings(char **files, int count)
{ {
qsort((void *)files, (size_t)count, sizeof(char_u *), sort_compare); qsort((void *)files, (size_t)count, sizeof(char *), sort_compare);
} }
/* /*
@ -540,14 +540,12 @@ bool has_non_ascii_len(const char *const s, const size_t len)
return false; return false;
} }
/* /// Concatenate two strings and return the result in allocated memory.
* Concatenate two strings and return the result in allocated memory. char *concat_str(const char *restrict str1, const char *restrict str2)
*/
char_u *concat_str(const char_u *restrict str1, const char_u *restrict str2)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
{ {
size_t l = STRLEN(str1); size_t l = STRLEN(str1);
char_u *dest = xmalloc(l + STRLEN(str2) + 1); char *dest = xmalloc(l + STRLEN(str2) + 1);
STRCPY(dest, str1); STRCPY(dest, str1);
STRCPY(dest + l, str2); STRCPY(dest + l, str2);
return dest; return dest;
@ -1511,15 +1509,15 @@ int kv_do_printf(StringBuilder *str, const char *fmt, ...)
/// Reverse text into allocated memory. /// Reverse text into allocated memory.
/// ///
/// @return the allocated string. /// @return the allocated string.
char_u *reverse_text(char_u *s) char *reverse_text(char *s)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_RET
{ {
// Reverse the pattern. // Reverse the pattern.
size_t len = STRLEN(s); size_t len = STRLEN(s);
char_u *rev = xmalloc(len + 1); char *rev = xmalloc(len + 1);
size_t rev_i = len; size_t rev_i = len;
for (size_t s_i = 0; s_i < len; s_i++) { for (size_t s_i = 0; s_i < len; s_i++) {
const int mb_len = utfc_ptr2len((char *)s + s_i); const int mb_len = utfc_ptr2len(s + s_i);
rev_i -= (size_t)mb_len; rev_i -= (size_t)mb_len;
memmove(rev + rev_i, s + s_i, (size_t)mb_len); memmove(rev + rev_i, s + s_i, (size_t)mb_len);
s_i += (size_t)mb_len - 1; s_i += (size_t)mb_len - 1;

View File

@ -3013,7 +3013,7 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing)
return; return;
} }
next = skiptowhite(arg); next = (char_u *)skiptowhite((char *)arg);
if (*arg == NUL) { if (*arg == NUL) {
if (curwin->w_s->b_syn_conceal) { if (curwin->w_s->b_syn_conceal) {
msg("syntax conceal on"); msg("syntax conceal on");
@ -3042,7 +3042,7 @@ static void syn_cmd_case(exarg_T *eap, int syncing)
return; return;
} }
next = skiptowhite(arg); next = (char_u *)skiptowhite((char *)arg);
if (*arg == NUL) { if (*arg == NUL) {
if (curwin->w_s->b_syn_ic) { if (curwin->w_s->b_syn_ic) {
msg("syntax case ignore"); msg("syntax case ignore");
@ -3081,7 +3081,7 @@ static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
return; return;
} }
arg_end = skiptowhite(arg); arg_end = (char_u *)skiptowhite((char *)arg);
if (STRNICMP(arg, "start", 5) == 0 && arg_end - arg == 5) { if (STRNICMP(arg, "start", 5) == 0 && arg_end - arg == 5) {
curwin->w_s->b_syn_foldlevel = SYNFLD_START; curwin->w_s->b_syn_foldlevel = SYNFLD_START;
} else if (STRNICMP(arg, "minimum", 7) == 0 && arg_end - arg == 7) { } else if (STRNICMP(arg, "minimum", 7) == 0 && arg_end - arg == 7) {
@ -3110,7 +3110,7 @@ static void syn_cmd_spell(exarg_T *eap, int syncing)
return; return;
} }
next = skiptowhite(arg); next = (char_u *)skiptowhite((char *)arg);
if (*arg == NUL) { if (*arg == NUL) {
if (curwin->w_s->b_syn_spell == SYNSPL_TOP) { if (curwin->w_s->b_syn_spell == SYNSPL_TOP) {
msg("syntax spell toplevel"); msg("syntax spell toplevel");
@ -3345,7 +3345,7 @@ static void syn_cmd_clear(exarg_T *eap, int syncing)
* Clear the group IDs that are in the argument. * Clear the group IDs that are in the argument.
*/ */
while (!ends_excmd(*arg)) { while (!ends_excmd(*arg)) {
arg_end = skiptowhite(arg); arg_end = (char_u *)skiptowhite((char *)arg);
if (*arg == '@') { if (*arg == '@') {
id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1)); id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
if (id == 0) { if (id == 0) {
@ -3522,7 +3522,7 @@ static void syn_cmd_list(exarg_T *eap, int syncing)
* List the group IDs and syntax clusters that are in the argument. * List the group IDs and syntax clusters that are in the argument.
*/ */
while (!ends_excmd(*arg) && !got_int) { while (!ends_excmd(*arg) && !got_int) {
arg_end = skiptowhite(arg); arg_end = (char_u *)skiptowhite((char *)arg);
if (*arg == '@') { if (*arg == '@') {
int id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1)); int id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
if (id == 0) { if (id == 0) {
@ -4029,7 +4029,7 @@ static void add_keyword(char_u *const name, const int id, const int flags,
/// Return NULL if the end of the command was found instead of further args. /// Return NULL if the end of the command was found instead of further args.
static char *get_group_name(char *arg, char **name_end) static char *get_group_name(char *arg, char **name_end)
{ {
*name_end = (char *)skiptowhite((char_u *)arg); *name_end = skiptowhite(arg);
char *rest = skipwhite(*name_end); char *rest = skipwhite(*name_end);
// Check if there are enough arguments. The first argument may be a // Check if there are enough arguments. The first argument may be a
@ -4163,7 +4163,7 @@ static char *get_syn_options(char *arg, syn_opt_arg_T *opt, int *conceal_char, i
return NULL; return NULL;
} }
gname_start = (char_u *)arg; gname_start = (char_u *)arg;
arg = (char *)skiptowhite((char_u *)arg); arg = skiptowhite(arg);
if (gname_start == (char_u *)arg) { if (gname_start == (char_u *)arg) {
return NULL; return NULL;
} }
@ -4600,7 +4600,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
} }
if (item == ITEM_MATCHGROUP) { if (item == ITEM_MATCHGROUP) {
p = (char *)skiptowhite((char_u *)rest); p = skiptowhite(rest);
if ((p - rest == 4 && STRNCMP(rest, "NONE", 4) == 0) || eap->skip) { if ((p - rest == 4 && STRNCMP(rest, "NONE", 4) == 0) || eap->skip) {
matchgroup_id = 0; matchgroup_id = 0;
} else { } else {
@ -5141,7 +5141,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
} }
while (!ends_excmd(*arg_start)) { while (!ends_excmd(*arg_start)) {
arg_end = (char *)skiptowhite(arg_start); arg_end = skiptowhite((char *)arg_start);
next_arg = (char_u *)skipwhite(arg_end); next_arg = (char_u *)skipwhite(arg_end);
xfree(key); xfree(key);
key = vim_strnsave_up(arg_start, (size_t)(arg_end - (char *)arg_start)); key = vim_strnsave_up(arg_start, (size_t)(arg_end - (char *)arg_start));
@ -5150,7 +5150,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT; curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
} }
if (!ends_excmd(*next_arg)) { if (!ends_excmd(*next_arg)) {
arg_end = (char *)skiptowhite(next_arg); arg_end = skiptowhite((char *)next_arg);
if (!eap->skip) { if (!eap->skip) {
curwin->w_s->b_syn_sync_id = curwin->w_s->b_syn_sync_id =
(int16_t)syn_check_group((char *)next_arg, (size_t)(arg_end - (char *)next_arg)); (int16_t)syn_check_group((char *)next_arg, (size_t)(arg_end - (char *)next_arg));
@ -5693,10 +5693,10 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg)
// (part of) subcommand already typed // (part of) subcommand already typed
if (*arg != NUL) { if (*arg != NUL) {
const char *p = (const char *)skiptowhite((const char_u *)arg); const char *p = (const char *)skiptowhite(arg);
if (*p != NUL) { // Past first word. if (*p != NUL) { // Past first word.
xp->xp_pattern = skipwhite(p); xp->xp_pattern = skipwhite(p);
if (*skiptowhite((char_u *)xp->xp_pattern) != NUL) { if (*skiptowhite(xp->xp_pattern) != NUL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} else if (STRNICMP(arg, "case", p - arg) == 0) { } else if (STRNICMP(arg, "case", p - arg) == 0) {
expand_what = EXP_CASE; expand_what = EXP_CASE;
@ -6028,7 +6028,7 @@ static void syntime_report(void)
if (len > (int)STRLEN(p->pattern)) { if (len > (int)STRLEN(p->pattern)) {
len = (int)STRLEN(p->pattern); len = (int)STRLEN(p->pattern);
} }
msg_outtrans_len(p->pattern, len); msg_outtrans_len((char *)p->pattern, len);
msg_puts("\n"); msg_puts("\n");
} }
ga_clear(&ga); ga_clear(&ga);

View File

@ -738,7 +738,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
mt_names[matches[i][0] & MT_MASK]); mt_names[matches[i][0] & MT_MASK]);
msg_puts((char *)IObuff); msg_puts((char *)IObuff);
if (tagp.tagkind != NULL) { if (tagp.tagkind != NULL) {
msg_outtrans_len(tagp.tagkind, msg_outtrans_len((char *)tagp.tagkind,
(int)(tagp.tagkind_end - tagp.tagkind)); (int)(tagp.tagkind_end - tagp.tagkind));
} }
msg_advance(13); msg_advance(13);
@ -752,7 +752,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
// it and put "..." in the middle // it and put "..." in the middle
p = tag_full_fname(&tagp); p = tag_full_fname(&tagp);
if (p != NULL) { if (p != NULL) {
msg_outtrans_attr(p, HL_ATTR(HLF_D)); msg_outtrans_attr((char *)p, HL_ATTR(HLF_D));
XFREE_CLEAR(p); XFREE_CLEAR(p);
} }
if (msg_col > 0) { if (msg_col > 0) {
@ -794,7 +794,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
} }
msg_advance(15); msg_advance(15);
} }
p = msg_outtrans_one(p, attr); p = (char_u *)msg_outtrans_one((char *)p, attr);
if (*p == TAB) { if (*p == TAB) {
msg_puts_attr(" ", attr); msg_puts_attr(" ", attr);
break; break;
@ -852,7 +852,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
msg_putchar(' '); msg_putchar(' ');
p++; p++;
} else { } else {
p = msg_outtrans_one(p, 0); p = (char_u *)msg_outtrans_one((char *)p, 0);
} }
// don't display the "$/;\"" and "$?;\"" // don't display the "$/;\"" and "$?;\""
@ -1052,7 +1052,7 @@ void do_tags(exarg_T *eap)
tagstack[i].tagname, tagstack[i].tagname,
tagstack[i].fmark.mark.lnum); tagstack[i].fmark.mark.lnum);
msg_outtrans((char *)IObuff); msg_outtrans((char *)IObuff);
msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum msg_outtrans_attr((char *)name, tagstack[i].fmark.fnum == curbuf->b_fnum
? HL_ATTR(HLF_D) : 0); ? HL_ATTR(HLF_D) : 0);
xfree(name); xfree(name);
} }
@ -1561,7 +1561,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
// Try tag file names from tags option one by one. // Try tag file names from tags option one by one.
for (first_file = true; for (first_file = true;
use_cscope || get_tagfname(&tn, first_file, tag_fname) == OK; use_cscope || get_tagfname(&tn, first_file, (char *)tag_fname) == OK;
first_file = false) { first_file = false) {
// A file that doesn't exist is silently ignored. Only when not a // A file that doesn't exist is silently ignored. Only when not a
// single file is found, an error message is given (further on). // single file is found, an error message is given (further on).
@ -1705,7 +1705,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
eof = vim_fgets(lbuf, lbuf_size, fp); eof = vim_fgets(lbuf, lbuf_size, fp);
} }
// skip empty and blank lines // skip empty and blank lines
while (!eof && vim_isblankline(lbuf)) { while (!eof && vim_isblankline((char *)lbuf)) {
search_info.curr_offset = vim_ftell(fp); search_info.curr_offset = vim_ftell(fp);
eof = vim_fgets(lbuf, lbuf_size, fp); eof = vim_fgets(lbuf, lbuf_size, fp);
} }
@ -1726,7 +1726,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
eof = use_cscope eof = use_cscope
? cs_fgets(lbuf, lbuf_size) ? cs_fgets(lbuf, lbuf_size)
: vim_fgets(lbuf, lbuf_size, fp); : vim_fgets(lbuf, lbuf_size, fp);
} while (!eof && vim_isblankline(lbuf)); } while (!eof && vim_isblankline((char *)lbuf));
if (eof) { if (eof) {
break; // end of file break; // end of file
@ -1741,7 +1741,7 @@ line_read_in:
// Convert every line. Converting the pattern from 'enc' to // Convert every line. Converting the pattern from 'enc' to
// the tags file encoding doesn't work, because characters are // the tags file encoding doesn't work, because characters are
// not recognized. // not recognized.
conv_line = string_convert(&vimconv, lbuf, NULL); conv_line = (char_u *)string_convert(&vimconv, (char *)lbuf, NULL);
if (conv_line != NULL) { if (conv_line != NULL) {
// Copy or swap lbuf and conv_line. // Copy or swap lbuf and conv_line.
len = (int)STRLEN(conv_line) + 1; len = (int)STRLEN(conv_line) + 1;
@ -2340,10 +2340,10 @@ void free_tag_stuff(void)
/// @param buf pointer to buffer of MAXPATHL chars /// @param buf pointer to buffer of MAXPATHL chars
/// ///
/// @return FAIL if no more tag file names, OK otherwise. /// @return FAIL if no more tag file names, OK otherwise.
int get_tagfname(tagname_T *tnp, int first, char_u *buf) int get_tagfname(tagname_T *tnp, int first, char *buf)
{ {
char_u *fname = NULL; char *fname = NULL;
char_u *r_ptr; char *r_ptr;
if (first) { if (first) {
CLEAR_POINTER(tnp); CLEAR_POINTER(tnp);
@ -2374,7 +2374,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
slash_adjust(buf); slash_adjust(buf);
#endif #endif
simplify_filename(buf); simplify_filename((char_u *)buf);
for (int i = 0; i < tag_fnames.ga_len; i++) { for (int i = 0; i < tag_fnames.ga_len; i++) {
if (STRCMP(buf, ((char **)(tag_fnames.ga_data))[i]) == 0) { if (STRCMP(buf, ((char **)(tag_fnames.ga_data))[i]) == 0) {
@ -2402,7 +2402,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
*/ */
for (;;) { for (;;) {
if (tnp->tn_did_filefind_init) { if (tnp->tn_did_filefind_init) {
fname = vim_findfile(tnp->tn_search_ctx); fname = (char *)vim_findfile(tnp->tn_search_ctx);
if (fname != NULL) { if (fname != NULL) {
break; break;
} }
@ -2422,17 +2422,17 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
* Copy next file name into buf. * Copy next file name into buf.
*/ */
buf[0] = NUL; buf[0] = NUL;
(void)copy_option_part(&tnp->tn_np, (char *)buf, MAXPATHL - 1, " ,"); (void)copy_option_part(&tnp->tn_np, buf, MAXPATHL - 1, " ,");
r_ptr = vim_findfile_stopdir(buf); r_ptr = (char *)vim_findfile_stopdir((char_u *)buf);
// move the filename one char forward and truncate the // move the filename one char forward and truncate the
// filepath with a NUL // filepath with a NUL
filename = (char_u *)path_tail((char *)buf); filename = (char_u *)path_tail(buf);
STRMOVE(filename + 1, filename); STRMOVE(filename + 1, filename);
*filename++ = NUL; *filename++ = NUL;
tnp->tn_search_ctx = vim_findfile_init(buf, filename, tnp->tn_search_ctx = vim_findfile_init((char_u *)buf, filename,
r_ptr, 100, (char_u *)r_ptr, 100,
false, // don't free visited list false, // don't free visited list
FINDFILE_FILE, // we search for a file FINDFILE_FILE, // we search for a file
tnp->tn_search_ctx, true, (char_u *)curbuf->b_ffname); tnp->tn_search_ctx, true, (char_u *)curbuf->b_ffname);

View File

@ -685,7 +685,7 @@ char *u_get_undo_file_name(const char *const buf_ffname, const bool reading)
*p-- = NUL; *p-- = NUL;
} }
bool has_directory = os_isdir((char_u *)dir_name); bool has_directory = os_isdir(dir_name);
if (!has_directory && *dirp == NUL && !reading) { if (!has_directory && *dirp == NUL && !reading) {
// Last directory in the list does not exist, create it. // Last directory in the list does not exist, create it.
int ret; int ret;

View File

@ -216,7 +216,7 @@ const char *set_context_in_user_cmd(expand_T *xp, const char *arg_in)
// Check for attributes // Check for attributes
while (*arg == '-') { while (*arg == '-') {
arg++; // Skip "-". arg++; // Skip "-".
p = (const char *)skiptowhite((const char_u *)arg); p = (const char *)skiptowhite(arg);
if (*p == NUL) { if (*p == NUL) {
// Cursor is still in the attribute. // Cursor is still in the attribute.
p = strchr(arg, '='); p = strchr(arg, '=');
@ -248,7 +248,7 @@ const char *set_context_in_user_cmd(expand_T *xp, const char *arg_in)
} }
// After the attributes comes the new command name. // After the attributes comes the new command name.
p = (const char *)skiptowhite((const char_u *)arg); p = (const char *)skiptowhite(arg);
if (*p == NUL) { if (*p == NUL) {
xp->xp_context = EXPAND_USER_COMMANDS; xp->xp_context = EXPAND_USER_COMMANDS;
xp->xp_pattern = (char *)arg; xp->xp_pattern = (char *)arg;
@ -434,7 +434,7 @@ static void uc_list(char *name, size_t name_len)
msg_putchar(' '); msg_putchar(' ');
} }
msg_outtrans_attr((char_u *)cmd->uc_name, HL_ATTR(HLF_D)); msg_outtrans_attr(cmd->uc_name, HL_ATTR(HLF_D));
len = (int)STRLEN(cmd->uc_name) + 4; len = (int)STRLEN(cmd->uc_name) + 4;
do { do {
@ -930,7 +930,7 @@ void ex_command(exarg_T *eap)
// Check for attributes // Check for attributes
while (*p == '-') { while (*p == '-') {
p++; p++;
end = (char *)skiptowhite((char_u *)p); end = skiptowhite(p);
if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &compl, (char_u **)&compl_arg, if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &compl, (char_u **)&compl_arg,
&addr_type_arg) == FAIL) { &addr_type_arg) == FAIL) {
return; return;

View File

@ -230,10 +230,7 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
# endif # endif
#endif #endif
#define STRRCHR(s, c) (char_u *)strrchr((const char *)(s), (c)) #define STRCAT(d, s) strcat((char *)(d), (char *)(s)) // NOLINT(runtime/printf)
#define STRCAT(d, s) strcat((char *)(d), (char *)(s))
#define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
#define STRLCAT(d, s, n) xstrlcat((char *)(d), (char *)(s), (size_t)(n)) #define STRLCAT(d, s, n) xstrlcat((char *)(d), (char *)(s), (size_t)(n))
// Character used as separated in autoload function/variable names. // Character used as separated in autoload function/variable names.

View File

@ -142,9 +142,7 @@ static inline void viml_preader_get_line(ParserInputReader *const preader,
.allocated = true, .allocated = true,
.size = pline.size, .size = pline.size,
}; };
cpline.data = (char *)string_convert(&preader->conv, cpline.data = string_convert(&preader->conv, (char *)pline.data, &cpline.size);
(char_u *)pline.data,
&cpline.size);
if (pline.allocated) { if (pline.allocated) {
xfree((void *)pline.data); xfree((void *)pline.data);
} }

View File

@ -730,7 +730,7 @@ void win_set_minimal_style(win_T *wp)
char_u *old = (char_u *)wp->w_p_fcs; char_u *old = (char_u *)wp->w_p_fcs;
wp->w_p_fcs = ((*old == NUL) wp->w_p_fcs = ((*old == NUL)
? xstrdup("eob: ") ? xstrdup("eob: ")
: (char *)concat_str(old, (char_u *)",eob: ")); : concat_str((char *)old, ",eob: "));
free_string_option((char *)old); free_string_option((char *)old);
} }
@ -739,7 +739,7 @@ void win_set_minimal_style(win_T *wp)
char_u *old = (char_u *)wp->w_p_winhl; char_u *old = (char_u *)wp->w_p_winhl;
wp->w_p_winhl = ((*old == NUL) wp->w_p_winhl = ((*old == NUL)
? xstrdup("EndOfBuffer:") ? xstrdup("EndOfBuffer:")
: (char *)concat_str(old, (char_u *)",EndOfBuffer:")); : concat_str((char *)old, ",EndOfBuffer:"));
free_string_option((char *)old); free_string_option((char *)old);
parse_winhl_opt(wp); parse_winhl_opt(wp);