aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c96
1 files changed, 47 insertions, 49 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 9839f499eb..107f61919a 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -979,7 +979,7 @@ char *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int end
break;
}
} else { // addr_count == 1
- arg = skipwhite(arg);
+ arg = (char_u *)skipwhite((char *)arg);
if (*arg == NUL) {
break;
}
@@ -3151,8 +3151,8 @@ void maketitle(void)
use_sandbox = was_set_insecurely(curwin, "titlestring", 0);
called_emsg = false;
- build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf),
- p_titlestring, use_sandbox,
+ build_stl_str_hl(curwin, buf, sizeof(buf),
+ (char *)p_titlestring, use_sandbox,
0, maxlen, NULL, NULL);
title_str = (char_u *)buf;
if (called_emsg) {
@@ -3269,8 +3269,8 @@ void maketitle(void)
use_sandbox = was_set_insecurely(curwin, "iconstring", 0);
called_emsg = false;
- build_stl_str_hl(curwin, icon_str, sizeof(buf),
- p_iconstring, use_sandbox,
+ build_stl_str_hl(curwin, (char *)icon_str, sizeof(buf),
+ (char *)p_iconstring, use_sandbox,
0, 0, NULL, NULL);
if (called_emsg) {
set_string_option_direct("iconstring", -1,
@@ -3383,8 +3383,8 @@ typedef enum {
/// @param tabtab Tab clicks definition (can be NULL).
///
/// @return The final width of the statusline
-int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use_sandbox,
- int fillchar, int maxwidth, stl_hlrec_t **hltab, StlClickRecord **tabtab)
+int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, int use_sandbox, int fillchar,
+ int maxwidth, stl_hlrec_t **hltab, StlClickRecord **tabtab)
{
static size_t stl_items_len = 20; // Initial value, grows as needed.
static stl_item_t *stl_items = NULL;
@@ -3395,8 +3395,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
#define TMPLEN 70
char buf_tmp[TMPLEN];
- char_u win_tmp[TMPLEN];
- char_u *usefmt = fmt;
+ char win_tmp[TMPLEN];
+ char *usefmt = fmt;
const int save_must_redraw = must_redraw;
const int save_redr_type = curwin->w_redr_type;
@@ -3421,7 +3421,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
};
set_var(S_LEN("g:statusline_winid"), &tv, false);
- usefmt = (char_u *)eval_to_string_safe((char *)fmt + 2, NULL, use_sandbox);
+ usefmt = eval_to_string_safe(fmt + 2, NULL, use_sandbox);
if (usefmt == NULL) {
usefmt = fmt;
}
@@ -3467,17 +3467,17 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
bool prevchar_isitem = false;
// out_p is the current position in the output buffer
- char_u *out_p = out;
+ char *out_p = out;
// out_end_p is the last valid character in the output buffer
// Note: The null termination character must occur here or earlier,
// so any user-visible characters must occur before here.
- char_u *out_end_p = (out + outlen) - 1;
+ char *out_end_p = (out + outlen) - 1;
// Proceed character by character through the statusline format string
// fmt_p is the current position in the input buffer
- for (char_u *fmt_p = usefmt; *fmt_p;) {
+ for (char *fmt_p = usefmt; *fmt_p;) {
if (curitem == (int)stl_items_len) {
size_t new_len = stl_items_len * 3 / 2;
@@ -3534,7 +3534,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
continue;
}
stl_items[curitem].type = Separate;
- stl_items[curitem++].start = out_p;
+ stl_items[curitem++].start = (char_u *)out_p;
continue;
}
@@ -3542,7 +3542,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
if (*fmt_p == STL_TRUNCMARK) {
fmt_p++;
stl_items[curitem].type = Trunc;
- stl_items[curitem++].start = out_p;
+ stl_items[curitem++].start = (char_u *)out_p;
continue;
}
@@ -3591,7 +3591,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
if (n == curitem && group_start_userhl == group_end_userhl) {
// empty group
- out_p = t;
+ out_p = (char *)t;
group_len = 0;
for (n = stl_groupitems[groupdepth] + 1; n < curitem; n++) {
// do not use the highlighting from the removed group
@@ -3601,7 +3601,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// adjust the start position of TabPage to the next
// item position
if (stl_items[n].type == TabPage) {
- stl_items[n].start = out_p;
+ stl_items[n].start = (char_u *)out_p;
}
}
}
@@ -3624,7 +3624,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
*t = '<';
// { Move the truncated output
- memmove(t + 1, t + n, (size_t)(out_p - (t + n)));
+ memmove(t + 1, t + n, (size_t)((char_u *)out_p - (t + n)));
out_p = out_p - n + 1;
// Fill up space left over by half a double-wide char.
while (++group_len < stl_items[stl_groupitems[groupdepth]].minwid) {
@@ -3657,7 +3657,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
} else {
// { Move the group to the right
group_len = (min_group_width - group_len) * utf_char2len(fillchar);
- memmove(t + group_len, t, (size_t)(out_p - t));
+ memmove(t + group_len, t, (size_t)((char_u *)out_p - t));
if (out_p + group_len >= (out_end_p + 1)) {
group_len = (long)(out_end_p - out_p);
}
@@ -3696,14 +3696,14 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// The first digit group is the item's min width
if (ascii_isdigit(*fmt_p)) {
- minwid = getdigits_int(&fmt_p, false, 0);
+ minwid = getdigits_int((char_u **)&fmt_p, false, 0);
}
// User highlight groups override the min width field
// to denote the styling to use.
if (*fmt_p == STL_USER_HL) {
stl_items[curitem].type = Highlight;
- stl_items[curitem].start = out_p;
+ stl_items[curitem].start = (char_u *)out_p;
stl_items[curitem].minwid = minwid > 9 ? 1 : minwid;
fmt_p++;
curitem++;
@@ -3749,7 +3749,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
}
stl_items[curitem].type = TabPage;
- stl_items[curitem].start = out_p;
+ stl_items[curitem].start = (char_u *)out_p;
stl_items[curitem].minwid = minwid;
fmt_p++;
curitem++;
@@ -3758,7 +3758,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
if (*fmt_p == STL_CLICK_FUNC) {
fmt_p++;
- char *t = (char *)fmt_p;
+ char *t = fmt_p;
while (*fmt_p != STL_CLICK_FUNC && *fmt_p) {
fmt_p++;
}
@@ -3766,8 +3766,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
break;
}
stl_items[curitem].type = ClickFunc;
- stl_items[curitem].start = out_p;
- stl_items[curitem].cmd = xmemdupz(t, (size_t)(((char *)fmt_p - t)));
+ stl_items[curitem].start = (char_u *)out_p;
+ stl_items[curitem].cmd = xmemdupz(t, (size_t)(fmt_p - t));
stl_items[curitem].minwid = minwid;
fmt_p++;
curitem++;
@@ -3779,7 +3779,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
if (*fmt_p == '.') {
fmt_p++;
if (ascii_isdigit(*fmt_p)) {
- maxwid = getdigits_int(&fmt_p, false, 50);
+ maxwid = getdigits_int((char_u **)&fmt_p, false, 50);
}
}
@@ -3791,7 +3791,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
if (*fmt_p == '(') {
stl_groupitems[groupdepth++] = curitem;
stl_items[curitem].type = Group;
- stl_items[curitem].start = out_p;
+ stl_items[curitem].start = (char_u *)out_p;
stl_items[curitem].minwid = minwid;
stl_items[curitem].maxwid = maxwid;
fmt_p++;
@@ -3814,7 +3814,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
// The status line item type
- char_u opt = *fmt_p++;
+ char opt = *fmt_p++;
// OK - now for the real work
NumberBase base = kNumBaseDecimal;
@@ -3845,7 +3845,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
break;
case STL_VIM_EXPR: // '{'
{
- char_u *block_start = fmt_p - 1;
+ char *block_start = fmt_p - 1;
int reevaluate = (*fmt_p == '%');
itemisflag = true;
@@ -3855,7 +3855,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// Attempt to copy the expression to evaluate into
// the output buffer as a null-terminated string.
- char_u *t = out_p;
+ char *t = out_p;
while ((*fmt_p != '}' || (reevaluate && fmt_p[-1] != '%'))
&& *fmt_p != NUL && out_p < out_end_p) {
*out_p++ = *fmt_p++;
@@ -3893,7 +3893,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
// Note: The result stored in `t` is unused.
- str = eval_to_string_safe((char *)out_p, (char **)&t, use_sandbox);
+ str = eval_to_string_safe(out_p, &t, use_sandbox);
curwin = save_curwin;
curbuf = save_curbuf;
@@ -3943,7 +3943,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
xfree(usefmt);
}
XFREE_CLEAR(str);
- usefmt = new_fmt;
+ usefmt = (char *)new_fmt;
fmt_p = usefmt + parsed_usefmt;
evaldepth++;
continue;
@@ -4125,7 +4125,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
case STL_HIGHLIGHT: {
// { The name of the highlight is surrounded by `#`
- char_u *t = fmt_p;
+ char *t = fmt_p;
while (*fmt_p != '#' && *fmt_p != NUL) {
fmt_p++;
}
@@ -4134,8 +4134,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// Create a highlight item based on the name
if (*fmt_p == '#') {
stl_items[curitem].type = Highlight;
- stl_items[curitem].start = out_p;
- stl_items[curitem].minwid = -syn_name2id_len(t, (size_t)(fmt_p - t));
+ stl_items[curitem].start = (char_u *)out_p;
+ stl_items[curitem].minwid = -syn_name2id_len((char_u *)t, (size_t)(fmt_p - t));
curitem++;
fmt_p++;
}
@@ -4146,14 +4146,14 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// If we made it this far, the item is normal and starts at
// our current position in the output buffer.
// Non-normal items would have `continued`.
- stl_items[curitem].start = out_p;
+ stl_items[curitem].start = (char_u *)out_p;
stl_items[curitem].type = Normal;
// Copy the item string into the output buffer
if (str != NULL && *str) {
// { Skip the leading `,` or ` ` if the item is a flag
// and the proper conditions are met
- char_u *t = (char_u *)str;
+ char *t = str;
if (itemisflag) {
if ((t[0] && t[1])
&& ((!prevchar_isitem && *t == ',')
@@ -4164,7 +4164,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
}
// }
- long l = vim_strsize(t);
+ long l = vim_strsize((char_u *)t);
// If this item is non-empty, record that the last thing
// we put in the output buffer was an item
@@ -4175,8 +4175,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// If the item is too wide, truncate it from the beginning
if (l > maxwid) {
while (l >= maxwid) {
- l -= ptr2cells(t);
- t += utfc_ptr2len((char *)t);
+ l -= ptr2cells((char_u *)t);
+ t += utfc_ptr2len(t);
}
// Early out if there isn't enough room for the truncation marker
@@ -4292,11 +4292,9 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
*++t = 0;
// }
- vim_snprintf((char *)out_p, remaining_buf_len, (char *)nstr,
- 0, num, n);
+ vim_snprintf(out_p, remaining_buf_len, (char *)nstr, 0, num, n);
} else {
- vim_snprintf((char *)out_p, remaining_buf_len, (char *)nstr,
- minwid, num);
+ vim_snprintf(out_p, remaining_buf_len, (char *)nstr, minwid, num);
}
// Advance the output buffer position to the end of the
@@ -4333,7 +4331,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// We have now processed the entire statusline format string.
// What follows is post-processing to handle alignment and highlighting.
- int width = vim_strsize(out);
+ int width = vim_strsize((char_u *)out);
if (maxwidth > 0 && width > maxwidth) {
// Result is too long, must truncate somewhere.
int item_idx = 0;
@@ -4341,7 +4339,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
// If there are no items, truncate from beginning
if (itemcnt == 0) {
- trunc_p = out;
+ trunc_p = (char_u *)out;
// Otherwise, look for the truncation item
} else {
@@ -4364,7 +4362,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
if (width - vim_strsize(trunc_p) >= maxwidth) {
// Walk from the beginning of the
// string to find the last character that will fit.
- trunc_p = out;
+ trunc_p = (char_u *)out;
width = 0;
for (;;) {
width += ptr2cells(trunc_p);
@@ -5179,7 +5177,7 @@ static int chk_modeline(linenr_T lnum, int flags)
if (*e == ':'
&& (s[0] != 'V'
- || STRNCMP(skipwhite(e + 1), "set", 3) == 0)
+ || STRNCMP(skipwhite((char *)e + 1), "set", 3) == 0)
&& (s[3] == ':'
|| (VIM_VERSION_100 >= vers && isdigit(s[3]))
|| (VIM_VERSION_100 < vers && s[3] == '<')
@@ -5209,7 +5207,7 @@ static int chk_modeline(linenr_T lnum, int flags)
end = false;
while (end == false) {
- s = skipwhite(s);
+ s = (char_u *)skipwhite((char *)s);
if (*s == NUL) {
break;
}