aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-01-10 03:28:01 +0100
committerGitHub <noreply@github.com>2023-01-10 10:28:01 +0800
commitef6750332008b7b61dde9eeab0da454bf3323ebb (patch)
tree8b5f1e50ab2b5111022f8f9b410b377c1d2c94ad
parentf62da7381e9cd4dd4e926fda320132e8fccf6e48 (diff)
downloadrneovim-ef6750332008b7b61dde9eeab0da454bf3323ebb.tar.gz
rneovim-ef6750332008b7b61dde9eeab0da454bf3323ebb.tar.bz2
rneovim-ef6750332008b7b61dde9eeab0da454bf3323ebb.zip
refactor: replace char_u with char 19 (#21241)
* refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
-rw-r--r--src/nvim/cmdexpand.c4
-rw-r--r--src/nvim/edit.c6
-rw-r--r--src/nvim/eval.c4
-rw-r--r--src/nvim/eval/funcs.c30
-rw-r--r--src/nvim/eval/userfunc.c2
-rw-r--r--src/nvim/ex_session.c32
-rw-r--r--src/nvim/indent_c.c440
-rw-r--r--src/nvim/mark.c38
-rw-r--r--src/nvim/ops.c100
-rw-r--r--src/nvim/path.c38
-rw-r--r--src/nvim/search.c4
-rw-r--r--src/nvim/syntax.c84
-rw-r--r--src/nvim/tag.c216
-rw-r--r--src/nvim/usercmd.c6
14 files changed, 499 insertions, 505 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index 2952d631e4..d603e964e5 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -458,12 +458,12 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
s += skip_wildmenu_char(xp, (char_u *)s);
clen += ptr2cells(s);
if ((l = utfc_ptr2len(s)) > 1) {
- strncpy((char *)buf + len, s, (size_t)l); // NOLINT(runtime/printf)
+ strncpy(buf + len, s, (size_t)l); // NOLINT(runtime/printf)
s += l - 1;
len += l;
} else {
STRCPY(buf + len, transchar_byte((uint8_t)(*s)));
- len += (int)strlen((char *)buf + len);
+ len += (int)strlen(buf + len);
}
}
}
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 5646abf3c4..f3dea5f612 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -3100,7 +3100,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
} else if (*look == ':') {
if (try_match && keytyped == ':') {
p = get_cursor_line_ptr();
- if (cin_iscase((char_u *)p, false) || cin_isscopedecl((char_u *)p) || cin_islabel()) {
+ if (cin_iscase(p, false) || cin_isscopedecl(p) || cin_islabel()) {
return true;
}
// Need to get the line again after cin_islabel().
@@ -3109,8 +3109,8 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
&& p[curwin->w_cursor.col - 1] == ':'
&& p[curwin->w_cursor.col - 2] == ':') {
p[curwin->w_cursor.col - 1] = ' ';
- const bool i = cin_iscase((char_u *)p, false)
- || cin_isscopedecl((char_u *)p)
+ const bool i = cin_iscase(p, false)
+ || cin_isscopedecl(p)
|| cin_islabel();
p = get_cursor_line_ptr();
p[curwin->w_cursor.col - 1] = ':';
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 17eb08cee6..de6f150304 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -8007,7 +8007,7 @@ repeat:
s++;
}
- int sep = (char_u)(*s++);
+ int sep = (uint8_t)(*s++);
if (sep) {
// find end of pattern
p = vim_strchr(s, sep);
@@ -8040,7 +8040,7 @@ repeat:
if (src[*usedlen] == ':' && src[*usedlen + 1] == 'S') {
// vim_strsave_shellescape() needs a NUL terminated string.
- c = (char_u)(*fnamep)[*fnamelen];
+ c = (uint8_t)(*fnamep)[*fnamelen];
if (c != NUL) {
(*fnamep)[*fnamelen] = NUL;
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 180723f412..a87698a9f9 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -226,11 +226,11 @@ const EvalFuncDef *find_internal_func(const char *const name)
return index >= 0 ? &functions[index] : NULL;
}
-int call_internal_func(const char_u *const fname, const int argcount, typval_T *const argvars,
+int call_internal_func(const char *const fname, const int argcount, typval_T *const argvars,
typval_T *const rettv)
FUNC_ATTR_NONNULL_ALL
{
- const EvalFuncDef *const fdef = find_internal_func((const char *)fname);
+ const EvalFuncDef *const fdef = find_internal_func(fname);
if (fdef == NULL) {
return FCERR_UNKNOWN;
} else if (argcount < fdef->min_argc) {
@@ -2751,19 +2751,19 @@ static void f_getpos(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
/// Returns zero on error.
static int getreg_get_regname(typval_T *argvars)
{
- const char_u *strregname;
+ const char *strregname;
if (argvars[0].v_type != VAR_UNKNOWN) {
- strregname = (const char_u *)tv_get_string_chk(&argvars[0]);
+ strregname = tv_get_string_chk(&argvars[0]);
if (strregname == NULL) { // type error; errmsg already given
return 0;
}
} else {
// Default to v:register
- strregname = (char_u *)get_vim_var_str(VV_REG);
+ strregname = get_vim_var_str(VV_REG);
}
- return *strregname == 0 ? '"' : *strregname;
+ return *strregname == 0 ? '"' : (uint8_t)(*strregname);
}
/// "getreg()" function
@@ -3365,13 +3365,11 @@ static void f_iconv(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
const char *const str = tv_get_string(&argvars[0]);
char buf1[NUMBUFLEN];
- char_u *const from =
- (char_u *)enc_canonize(enc_skip((char *)tv_get_string_buf(&argvars[1], buf1)));
+ char *const from = enc_canonize(enc_skip((char *)tv_get_string_buf(&argvars[1], buf1)));
char buf2[NUMBUFLEN];
- char_u *const to =
- (char_u *)enc_canonize(enc_skip((char *)tv_get_string_buf(&argvars[2], buf2)));
+ char *const to = enc_canonize(enc_skip((char *)tv_get_string_buf(&argvars[2], buf2)));
vimconv.vc_type = CONV_NONE;
- convert_setup(&vimconv, (char *)from, (char *)to);
+ convert_setup(&vimconv, from, to);
// If the encodings are equal, no conversion needed.
if (vimconv.vc_type == CONV_NONE) {
@@ -3646,11 +3644,11 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
lval_T lv;
rettv->vval.v_number = -1;
- const char_u *const end = (char_u *)get_lval((char *)tv_get_string(&argvars[0]),
- NULL,
- &lv, false, false,
- GLV_NO_AUTOLOAD|GLV_READ_ONLY,
- FNE_CHECK_START);
+ const char *const end = get_lval((char *)tv_get_string(&argvars[0]),
+ NULL,
+ &lv, false, false,
+ GLV_NO_AUTOLOAD|GLV_READ_ONLY,
+ FNE_CHECK_START);
if (end != NULL && lv.ll_name != NULL) {
if (*end != NUL) {
semsg(_(e_trailing_arg), end);
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 54c4285453..9078050067 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -1618,7 +1618,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
funcexe->fe_basetv);
} else {
// Find the function name in the table, call its implementation.
- error = call_internal_func((char_u *)fname, argcount, argvars, rettv);
+ error = call_internal_func(fname, argcount, argvars, rettv);
}
// The function call (or "FuncUndefined" autocommand sequence) might
// have been aborted by an error, an interrupt, or an explicitly thrown
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index 7bed8d5288..48d52fa5f9 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -215,22 +215,22 @@ static int ses_do_win(win_T *wp)
/// @returns FAIL if writing fails.
static int ses_arglist(FILE *fd, char *cmd, garray_T *gap, int fullname, unsigned *flagp)
{
- char_u *buf = NULL;
- char_u *s;
+ char *buf = NULL;
+ char *s;
if (fprintf(fd, "%s\n%s\n", cmd, "%argdel") < 0) {
return FAIL;
}
for (int i = 0; i < gap->ga_len; i++) {
// NULL file names are skipped (only happens when out of memory).
- s = (char_u *)alist_name(&((aentry_T *)gap->ga_data)[i]);
+ s = alist_name(&((aentry_T *)gap->ga_data)[i]);
if (s != NULL) {
if (fullname) {
buf = xmalloc(MAXPATHL);
- (void)vim_FullName((char *)s, (char *)buf, MAXPATHL, false);
+ (void)vim_FullName(s, buf, MAXPATHL, false);
s = buf;
}
- char *fname_esc = ses_escape_fname((char *)s, flagp);
+ char *fname_esc = ses_escape_fname(s, flagp);
if (fprintf(fd, "$argadd %s\n", fname_esc) < 0) {
xfree(fname_esc);
xfree(buf);
@@ -268,7 +268,7 @@ static char *ses_get_fname(buf_T *buf, const unsigned *flagp)
static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol)
{
char *name = ses_get_fname(buf, flagp);
- if (ses_put_fname(fd, (char_u *)name, flagp) == FAIL
+ if (ses_put_fname(fd, name, flagp) == FAIL
|| (add_eol && fprintf(fd, "\n") < 0)) {
return FAIL;
}
@@ -303,9 +303,9 @@ static char *ses_escape_fname(char *name, unsigned *flagp)
/// characters.
///
/// @return FAIL if writing fails.
-static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp)
+static int ses_put_fname(FILE *fd, char *name, unsigned *flagp)
{
- char *p = ses_escape_fname((char *)name, flagp);
+ char *p = ses_escape_fname(name, flagp);
bool retval = fputs(p, fd) < 0 ? FAIL : OK;
xfree(p);
return retval;
@@ -527,7 +527,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
if (wp->w_localdir != NULL
&& (flagp != &vop_flags || (*flagp & SSOP_CURDIR))) {
if (fputs("lcd ", fd) < 0
- || ses_put_fname(fd, (char_u *)wp->w_localdir, flagp) == FAIL
+ || ses_put_fname(fd, wp->w_localdir, flagp) == FAIL
|| fprintf(fd, "\n") < 0) {
return FAIL;
}
@@ -546,7 +546,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
/// @param fd File descriptor to write to
///
/// @return FAIL on error, OK otherwise.
-static int makeopens(FILE *fd, char_u *dirnow)
+static int makeopens(FILE *fd, char *dirnow)
{
int only_save_windows = true;
int nr;
@@ -585,7 +585,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
if (ssop_flags & SSOP_SESDIR) {
PUTLINE_FAIL("exe \"cd \" . escape(expand(\"<sfile>:p:h\"), ' ')");
} else if (ssop_flags & SSOP_CURDIR) {
- sname = home_replace_save(NULL, globaldir != NULL ? globaldir : (char *)dirnow);
+ sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow);
char *fname_esc = ses_escape_fname(sname, &ssop_flags);
if (fprintf(fd, "cd %s\n", fname_esc) < 0) {
xfree(fname_esc);
@@ -832,7 +832,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
// Take care of tab-local working directories if applicable
if (tp->tp_localdir) {
if (fputs("if exists(':tcd') == 2 | tcd ", fd) < 0
- || ses_put_fname(fd, (char_u *)tp->tp_localdir, &ssop_flags) == FAIL
+ || ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL
|| fputs(" | endif\n", fd) < 0) {
return FAIL;
}
@@ -1001,14 +1001,14 @@ void ex_mkrc(exarg_T *eap)
failed = true;
}
if (eap->cmdidx == CMD_mksession) {
- char_u *dirnow; // current directory
+ char *dirnow; // current directory
dirnow = xmalloc(MAXPATHL);
//
// Change to session file's dir.
//
- if (os_dirname((char *)dirnow, MAXPATHL) == FAIL
- || os_chdir((char *)dirnow) != 0) {
+ if (os_dirname(dirnow, MAXPATHL) == FAIL
+ || os_chdir(dirnow) != 0) {
*dirnow = NUL;
}
if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) {
@@ -1028,7 +1028,7 @@ void ex_mkrc(exarg_T *eap)
if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR)
|| ((ssop_flags & SSOP_CURDIR) && globaldir !=
NULL))) {
- if (os_chdir((char *)dirnow) != 0) {
+ if (os_chdir(dirnow) != 0) {
emsg(_(e_prev_dir));
}
shorten_fnames(true);
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 64844a510f..ccf4448e93 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -56,7 +56,7 @@ pos_T *find_start_comment(int ind_maxcomment) // XXX
// Check if the comment start we found is inside a string.
// If it is then restrict the search to below this line and try again.
- if (!is_pos_in_string((char_u *)ml_get(pos->lnum), pos->col)) {
+ if (!is_pos_in_string(ml_get(pos->lnum), pos->col)) {
break;
}
cur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1;
@@ -117,7 +117,7 @@ static pos_T *find_start_rawstring(int ind_maxcomment) // XXX
// Check if the raw string start we found is inside a string.
// If it is then restrict the search to below this line and try again.
- if (!is_pos_in_string((char_u *)ml_get(pos->lnum), pos->col)) {
+ if (!is_pos_in_string(ml_get(pos->lnum), pos->col)) {
break;
}
cur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1;
@@ -165,8 +165,8 @@ static const char *skip_string(const char *p)
}
} else if (p[0] == 'R' && p[1] == '"') {
// Raw string: R"[delim](...)[delim]"
- const char *delim = (char *)p + 2;
- const char *paren = vim_strchr((char *)delim, '(');
+ const char *delim = p + 2;
+ const char *paren = vim_strchr(delim, '(');
if (paren != NULL) {
const ptrdiff_t delim_len = paren - delim;
@@ -192,12 +192,12 @@ static const char *skip_string(const char *p)
}
/// @returns true if "line[col]" is inside a C string.
-int is_pos_in_string(const char_u *line, colnr_T col)
+int is_pos_in_string(const char *line, colnr_T col)
{
- const char_u *p;
+ const char *p;
for (p = line; *p && (colnr_T)(p - line) < col; p++) {
- p = (char_u *)skip_string((char *)p);
+ p = skip_string(p);
}
return !((colnr_T)(p - line) <= col);
}
@@ -214,7 +214,7 @@ bool cin_is_cinword(const char *line)
size_t cinw_len = strlen(curbuf->b_p_cinw) + 1;
char *cinw_buf = xmalloc(cinw_len);
- line = skipwhite((char *)line);
+ line = skipwhite(line);
for (char *cinw = curbuf->b_p_cinw; *cinw;) {
size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
@@ -232,17 +232,17 @@ bool cin_is_cinword(const char *line)
// Skip over white space and C comments within the line.
// Also skip over Perl/shell comments if desired.
-static const char_u *cin_skipcomment(const char_u *s)
+static const char *cin_skipcomment(const char *s)
{
while (*s) {
- const char_u *prev_s = s;
+ const char *prev_s = s;
- s = (char_u *)skipwhite((char *)s);
+ s = skipwhite(s);
// Perl/shell # comment comment continues until eol. Require a space
// before # to avoid recognizing $#array.
if (curbuf->b_ind_hash_comment != 0 && s != prev_s && *s == '#') {
- s += strlen((char *)s);
+ s += strlen(s);
break;
}
if (*s != '/') {
@@ -250,7 +250,7 @@ static const char_u *cin_skipcomment(const char_u *s)
}
s++;
if (*s == '/') { // slash-slash comment continues till eol
- s += strlen((char *)s);
+ s += strlen(s);
break;
}
if (*s != '*') {
@@ -268,7 +268,7 @@ static const char_u *cin_skipcomment(const char_u *s)
/// Return true if there is no code at *s. White space and comments are
/// not considered code.
-static int cin_nocode(const char_u *s)
+static int cin_nocode(const char *s)
{
return *cin_skipcomment(s) == NUL;
}
@@ -277,13 +277,13 @@ static int cin_nocode(const char_u *s)
static pos_T *find_line_comment(void) // XXX
{
static pos_T pos;
- char_u *line;
- char_u *p;
+ char *line;
+ char *p;
pos = curwin->w_cursor;
while (--pos.lnum > 0) {
- line = (char_u *)ml_get(pos.lnum);
- p = (char_u *)skipwhite((char *)line);
+ line = ml_get(pos.lnum);
+ p = skipwhite(line);
if (cin_islinecomment(p)) {
pos.col = (int)(p - line);
return &pos;
@@ -296,9 +296,9 @@ static pos_T *find_line_comment(void) // XXX
}
/// Checks if `text` starts with "key:".
-static bool cin_has_js_key(const char_u *text)
+static bool cin_has_js_key(const char *text)
{
- const char *s = skipwhite((char *)text);
+ const char *s = skipwhite(text);
char quote = 0;
if (*s == '\'' || *s == '"') {
@@ -317,7 +317,7 @@ static bool cin_has_js_key(const char_u *text)
s++;
}
- s = (char *)cin_skipcomment((char_u *)s);
+ s = cin_skipcomment(s);
// "::" is not a label, it's C++
return (*s == ':' && s[1] != ':');
@@ -336,7 +336,7 @@ static bool cin_islabel_skip(const char **s)
(*s)++;
}
- *s = (char *)cin_skipcomment((char_u *)(*s));
+ *s = cin_skipcomment(*s);
// "::" is not a label, it's C++
return **s == ':' && *++*s != ':';
@@ -346,14 +346,14 @@ static bool cin_islabel_skip(const char **s)
// Note: curwin->w_cursor must be where we are looking for the label.
bool cin_islabel(void) // XXX
{
- const char *s = (char *)cin_skipcomment((char_u *)get_cursor_line_ptr());
+ const char *s = cin_skipcomment(get_cursor_line_ptr());
// Exclude "default" from labels, since it should be indented
// like a switch label. Same for C++ scope declarations.
- if (cin_isdefault((char *)s)) {
+ if (cin_isdefault(s)) {
return false;
}
- if (cin_isscopedecl((char_u *)s)) {
+ if (cin_isscopedecl(s)) {
return false;
}
@@ -379,18 +379,18 @@ bool cin_islabel(void) // XXX
}
line = get_cursor_line_ptr();
- if (cin_ispreproc((char_u *)line)) { // ignore #defines, #if, etc.
+ if (cin_ispreproc(line)) { // ignore #defines, #if, etc.
continue;
}
- if (*(line = (char *)cin_skipcomment((char_u *)line)) == NUL) {
+ if (*(line = cin_skipcomment(line)) == NUL) {
continue;
}
curwin->w_cursor = cursor_save;
- if (cin_isterminated((char_u *)line, true, false)
- || cin_isscopedecl((char_u *)line)
- || cin_iscase((char_u *)line, true)
- || (cin_islabel_skip(&line) && cin_nocode((char_u *)line))) {
+ if (cin_isterminated(line, true, false)
+ || cin_isscopedecl(line)
+ || cin_iscase(line, true)
+ || (cin_islabel_skip(&line) && cin_nocode(line))) {
return true;
}
return false;
@@ -404,12 +404,12 @@ bool cin_islabel(void) // XXX
// "[typedef] [static|public|protected|private] = {"
static int cin_isinit(void)
{
- const char_u *s;
+ const char *s;
static char *skip[] = { "static", "public", "protected", "private" };
- s = cin_skipcomment((char_u *)get_cursor_line_ptr());
+ s = cin_skipcomment(get_cursor_line_ptr());
- if (cin_starts_with((char *)s, "typedef")) {
+ if (cin_starts_with(s, "typedef")) {
s = cin_skipcomment(s + 7);
}
@@ -418,7 +418,7 @@ static int cin_isinit(void)
for (i = 0; i < (int)ARRAY_SIZE(skip); i++) {
l = (int)strlen(skip[i]);
- if (cin_starts_with((char *)s, skip[i])) {
+ if (cin_starts_with(s, skip[i])) {
s = cin_skipcomment(s + l);
l = 0;
break;
@@ -429,11 +429,11 @@ static int cin_isinit(void)
}
}
- if (cin_starts_with((char *)s, "enum")) {
+ if (cin_starts_with(s, "enum")) {
return true;
}
- if (cin_ends_in((char *)s, "=", "{")) {
+ if (cin_ends_in(s, "=", "{")) {
return true;
}
@@ -443,10 +443,10 @@ static int cin_isinit(void)
/// Recognize a switch label: "case .*:" or "default:".
///
/// @param strict Allow relaxed check of case statement for JS
-bool cin_iscase(const char_u *s, bool strict)
+bool cin_iscase(const char *s, bool strict)
{
s = cin_skipcomment(s);
- if (cin_starts_with((char *)s, "case")) {
+ if (cin_starts_with(s, "case")) {
for (s += 4; *s; s++) {
s = cin_skipcomment(s);
if (*s == NUL) {
@@ -474,7 +474,7 @@ bool cin_iscase(const char_u *s, bool strict)
return false;
}
- if (cin_isdefault((char *)s)) {
+ if (cin_isdefault(s)) {
return true;
}
return false;
@@ -484,14 +484,14 @@ bool cin_iscase(const char_u *s, bool strict)
static int cin_isdefault(const char *s)
{
return strncmp(s, "default", 7) == 0
- && *(s = (char *)cin_skipcomment((char_u *)s + 7)) == ':'
+ && *(s = cin_skipcomment(s + 7)) == ':'
&& s[1] != ':';
}
/// Recognize a scope declaration label set in 'cinscopedecls'.
-bool cin_isscopedecl(const char_u *p)
+bool cin_isscopedecl(const char *p)
{
- const char *s = (char *)cin_skipcomment(p);
+ const char *s = cin_skipcomment(p);
const size_t cinsd_len = strlen(curbuf->b_p_cinsd) + 1;
char *cinsd_buf = xmalloc(cinsd_len);
@@ -501,7 +501,7 @@ bool cin_isscopedecl(const char_u *p)
for (char *cinsd = curbuf->b_p_cinsd; *cinsd;) {
const size_t len = copy_option_part(&cinsd, cinsd_buf, cinsd_len, ",");
if (strncmp(s, cinsd_buf, len) == 0) {
- const char_u *skip = cin_skipcomment((char_u *)s + len);
+ const char *skip = cin_skipcomment(s + len);
if (*skip == ':' && skip[1] != ':') {
found = true;
break;
@@ -524,18 +524,18 @@ static bool cin_is_cpp_namespace(const char *s)
bool has_name = false;
bool has_name_start = false;
- s = (char *)cin_skipcomment((char_u *)s);
+ s = cin_skipcomment(s);
if (strncmp(s, "inline", 6) == 0 && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) {
- s = (char *)cin_skipcomment((char_u *)skipwhite((char *)s + 6));
+ s = cin_skipcomment(skipwhite(s + 6));
}
if (strncmp(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc((uint8_t)s[9]))) {
- p = (char *)cin_skipcomment((char_u *)skipwhite((char *)s + 9));
+ p = cin_skipcomment(skipwhite(s + 9));
while (*p != NUL) {
if (ascii_iswhite(*p)) {
has_name = true; // found end of a name
- p = (char *)cin_skipcomment((char_u *)skipwhite((char *)p));
+ p = cin_skipcomment(skipwhite(p));
} else if (*p == '{') {
break;
} else if (vim_iswordc((uint8_t)(*p))) {
@@ -563,7 +563,7 @@ static bool cin_is_cpp_namespace(const char *s)
// Return NULL if not found.
// case 234: a = b;
// ^
-static const char_u *after_label(const char_u *l)
+static const char *after_label(const char *l)
{
for (; *l; l++) {
if (*l == ':') {
@@ -590,12 +590,12 @@ static const char_u *after_label(const char_u *l)
// Return 0 if there is nothing after the label.
static int get_indent_nolabel(linenr_T lnum) // XXX
{
- const char_u *l;
+ const char *l;
pos_T fp;
colnr_T col;
- const char_u *p;
+ const char *p;
- l = (char_u *)ml_get(lnum);
+ l = ml_get(lnum);
p = after_label(l);
if (p == NULL) {
return 0;
@@ -621,9 +621,9 @@ static int skip_label(linenr_T lnum, const char **pp)
curwin->w_cursor.lnum = lnum;
l = get_cursor_line_ptr();
// XXX
- if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l) || cin_islabel()) {
+ if (cin_iscase(l, false) || cin_isscopedecl(l) || cin_islabel()) {
amount = get_indent_nolabel(lnum);
- l = (char *)after_label((char_u *)get_cursor_line_ptr());
+ l = after_label(get_cursor_line_ptr());
if (l == NULL) { // just in case
l = get_cursor_line_ptr();
}
@@ -671,7 +671,7 @@ static int cin_first_id_amount(void)
}
}
for (len = 0; vim_isIDc((uint8_t)p[len]); len++) {}
- if (len == 0 || !ascii_iswhite(p[len]) || cin_nocode((char_u *)p)) {
+ if (len == 0 || !ascii_iswhite(p[len]) || cin_nocode(p)) {
return 0;
}
@@ -691,19 +691,19 @@ static int cin_first_id_amount(void)
// here";
static int cin_get_equal_amount(linenr_T lnum)
{
- const char_u *line;
- const char_u *s;
+ const char *line;
+ const char *s;
colnr_T col;
pos_T fp;
if (lnum > 1) {
- line = (char_u *)ml_get(lnum - 1);
- if (*line != NUL && line[strlen((char *)line) - 1] == '\\') {
+ line = ml_get(lnum - 1);
+ if (*line != NUL && line[strlen(line) - 1] == '\\') {
return -1;
}
}
- s = (char_u *)ml_get(lnum);
+ s = ml_get(lnum);
line = s;
while (*s != NUL && vim_strchr("=;{}\"'", *s) == NULL) {
if (cin_iscomment(s)) { // ignore comments
@@ -716,7 +716,7 @@ static int cin_get_equal_amount(linenr_T lnum)
return 0;
}
- s = (char_u *)skipwhite((char *)s + 1);
+ s = skipwhite(s + 1);
if (cin_nocode(s)) {
return 0;
}
@@ -732,9 +732,9 @@ static int cin_get_equal_amount(linenr_T lnum)
}
// Recognize a preprocessor statement: Any line that starts with '#'.
-static int cin_ispreproc(const char_u *s)
+static int cin_ispreproc(const char *s)
{
- if (*skipwhite((char *)s) == '#') {
+ if (*skipwhite(s) == '#') {
return true;
}
return false;
@@ -746,12 +746,12 @@ static int cin_ispreproc(const char_u *s)
/// Put the amount of indent in "*amount".
static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount)
{
- const char_u *line = (char_u *)(*pp);
+ const char *line = *pp;
linenr_T lnum = *lnump;
int retval = false;
int candidate_amount = *amount;
- if (*line != NUL && line[strlen((char *)line) - 1] == '\\') {
+ if (*line != NUL && line[strlen(line) - 1] == '\\') {
candidate_amount = get_indent_lnum(lnum);
}
@@ -764,8 +764,8 @@ static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount)
if (lnum == 1) {
break;
}
- line = (char_u *)ml_get(--lnum);
- if (*line == NUL || line[strlen((char *)line) - 1] != '\\') {
+ line = ml_get(--lnum);
+ if (*line == NUL || line[strlen(line) - 1] != '\\') {
break;
}
}
@@ -780,13 +780,13 @@ static int cin_ispreproc_cont(const char **pp, linenr_T *lnump, int *amount)
}
// Recognize the start of a C or C++ comment.
-static int cin_iscomment(const char_u *p)
+static int cin_iscomment(const char *p)
{
return p[0] == '/' && (p[1] == '*' || p[1] == '/');
}
// Recognize the start of a "//" comment.
-static int cin_islinecomment(const char_u *p)
+static int cin_islinecomment(const char *p)
{
return p[0] == '/' && p[1] == '/';
}
@@ -802,25 +802,25 @@ static int cin_islinecomment(const char_u *p)
///
/// @return the character terminating the line (ending char's have precedence if
/// both apply in order to determine initializations).
-static char_u cin_isterminated(const char_u *s, int incl_open, int incl_comma)
+static char cin_isterminated(const char *s, int incl_open, int incl_comma)
{
- char_u found_start = 0;
+ char found_start = 0;
unsigned n_open = 0;
int is_else = false;
s = cin_skipcomment(s);
- if (*s == '{' || (*s == '}' && !cin_iselse((char *)s))) {
+ if (*s == '{' || (*s == '}' && !cin_iselse(s))) {
found_start = *s;
}
if (!found_start) {
- is_else = cin_iselse((char *)s);
+ is_else = cin_iselse(s);
}
while (*s) {
// skip over comments, "" strings and 'c'haracters
- s = (char_u *)skip_string((char *)cin_skipcomment(s));
+ s = skip_string(cin_skipcomment(s));
if (*s == '}' && n_open > 0) {
n_open--;
}
@@ -855,7 +855,7 @@ static char_u cin_isterminated(const char_u *s, int incl_open, int incl_comma)
/// @param[in] min_lnum The line before which we will not be looking.
static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnum)
{
- const char_u *s;
+ const char *s;
linenr_T lnum = first_lnum;
linenr_T save_lnum = curwin->w_cursor.lnum;
int retval = false;
@@ -863,9 +863,9 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu
int just_started = true;
if (sp == NULL) {
- s = (char_u *)ml_get(lnum);
+ s = ml_get(lnum);
} else {
- s = (char_u *)(*sp);
+ s = *sp;
}
curwin->w_cursor.lnum = lnum;
@@ -876,7 +876,7 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu
curwin->w_cursor.lnum = save_lnum;
return false;
}
- s = (char_u *)ml_get(lnum);
+ s = ml_get(lnum);
}
curwin->w_cursor.lnum = save_lnum;
@@ -915,8 +915,8 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu
// #if defined(x) && {backslash}
// defined(y)
lnum = first_lnum - 1;
- s = (char_u *)ml_get(lnum);
- if (*s == NUL || s[strlen((char *)s) - 1] != '\\') {
+ s = ml_get(lnum);
+ if (*s == NUL || s[strlen(s) - 1] != '\\') {
retval = true;
}
goto done;
@@ -932,7 +932,7 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu
if (lnum >= curbuf->b_ml.ml_line_count) {
break;
}
- s = (char_u *)ml_get(++lnum);
+ s = ml_get(++lnum);
if (!cin_ispreproc(s)) {
break;
}
@@ -942,7 +942,7 @@ static int cin_isfuncdecl(const char **sp, linenr_T first_lnum, linenr_T min_lnu
}
// Require a comma at end of the line or a comma or ')' at the
// start of next line.
- s = (char_u *)skipwhite((char *)s);
+ s = skipwhite(s);
if (!just_started && (!comma && *s != ',' && *s != ')')) {
break;
}
@@ -971,7 +971,7 @@ static int cin_isif(const char *p)
static int cin_iselse(const char *p)
{
if (*p == '}') { // accept "} else"
- p = (char *)cin_skipcomment((char_u *)p + 1);
+ p = cin_skipcomment(p + 1);
}
return strncmp(p, "else", 4) == 0 && !vim_isIDc((uint8_t)p[4]);
}
@@ -984,7 +984,7 @@ static int cin_isdo(const char *p)
// Check if this is a "while" that should have a matching "do".
// We only accept a "while (condition) ;", with only white space between the
// ')' and ';'. The condition may be spread over several lines.
-static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX
+static int cin_iswhileofdo(const char *p, linenr_T lnum) // XXX
{
pos_T cursor_save;
pos_T *trypos;
@@ -994,17 +994,17 @@ static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX
if (*p == '}') { // accept "} while (cond);"
p = cin_skipcomment(p + 1);
}
- if (cin_starts_with((char *)p, "while")) {
+ if (cin_starts_with(p, "while")) {
cursor_save = curwin->w_cursor;
curwin->w_cursor.lnum = lnum;
curwin->w_cursor.col = 0;
- p = (char_u *)get_cursor_line_ptr();
+ p = get_cursor_line_ptr();
while (*p && *p != 'w') { // skip any '}', until the 'w' of the "while"
p++;
curwin->w_cursor.col++;
}
if ((trypos = findmatchlimit(NULL, 0, 0, curbuf->b_ind_maxparen)) != NULL
- && *cin_skipcomment((char_u *)ml_get_pos(trypos) + 1) == ';') {
+ && *cin_skipcomment(ml_get_pos(trypos) + 1) == ';') {
retval = true;
}
curwin->w_cursor = cursor_save;
@@ -1063,9 +1063,9 @@ probablyFound:
/// Adjust the cursor to the line with "while".
static int cin_iswhileofdo_end(int terminated)
{
- const char_u *line;
- const char_u *p;
- const char_u *s;
+ const char *line;
+ const char *p;
+ const char *s;
pos_T *trypos;
int i;
@@ -1073,11 +1073,11 @@ static int cin_iswhileofdo_end(int terminated)
return false;
}
- p = line = (char_u *)get_cursor_line_ptr();
+ p = line = get_cursor_line_ptr();
while (*p != NUL) {
p = cin_skipcomment(p);
if (*p == ')') {
- s = (char_u *)skipwhite((char *)p + 1);
+ s = skipwhite(p + 1);
if (*s == ';' && cin_nocode(s + 1)) {
// Found ");" at end of the line, now check there is "while"
// before the matching '('. XXX
@@ -1085,18 +1085,18 @@ static int cin_iswhileofdo_end(int terminated)
curwin->w_cursor.col = i;
trypos = find_match_paren(curbuf->b_ind_maxparen);
if (trypos != NULL) {
- s = cin_skipcomment((char_u *)ml_get(trypos->lnum));
+ s = cin_skipcomment(ml_get(trypos->lnum));
if (*s == '}') { // accept "} while (cond);"
s = cin_skipcomment(s + 1);
}
- if (cin_starts_with((char *)s, "while")) {
+ if (cin_starts_with(s, "while")) {
curwin->w_cursor.lnum = trypos->lnum;
return true;
}
}
// Searching may have made "line" invalid, get it again.
- line = (char_u *)get_cursor_line_ptr();
+ line = get_cursor_line_ptr();
p = line + i;
}
}
@@ -1141,7 +1141,7 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
if (*s == '#') { // skip #define FOO x ? (x) : x
return false;
}
- s = (char *)cin_skipcomment((char_u *)s);
+ s = cin_skipcomment(s);
if (*s == NUL) {
return false;
}
@@ -1167,9 +1167,9 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
break;
}
while (*s != NUL) {
- s = (char *)cin_skipcomment((char_u *)s);
+ s = cin_skipcomment(s);
if (*s == '{' || *s == '}'
- || (*s == ';' && cin_nocode((char_u *)s + 1))) {
+ || (*s == ';' && cin_nocode(s + 1))) {
break;
}
if (*s != NUL) {
@@ -1196,32 +1196,32 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
}
if (s == line) {
// don't recognize "case (foo):" as a baseclass */
- if (cin_iscase((char_u *)s, false)) {
+ if (cin_iscase(s, false)) {
break;
}
- s = (char *)cin_skipcomment((char_u *)line);
+ s = cin_skipcomment(line);
if (*s == NUL) {
continue;
}
}
if (s[0] == '"' || (s[0] == 'R' && s[1] == '"')) {
- s = (char *)skip_string(s) + 1;
+ s = skip_string(s) + 1;
} else if (s[0] == ':') {
if (s[1] == ':') {
// skip double colon. It can't be a constructor
// initialization any more
lookfor_ctor_init = false;
- s = (char *)cin_skipcomment((char_u *)s + 2);
+ s = cin_skipcomment(s + 2);
} else if (lookfor_ctor_init || class_or_struct) {
// we have something found, that looks like the start of
// cpp-base-class-declaration or constructor-initialization
cpp_base_class = true;
lookfor_ctor_init = class_or_struct = false;
pos->col = 0;
- s = (char *)cin_skipcomment((char_u *)s + 1);
+ s = cin_skipcomment(s + 1);
} else {
- s = (char *)cin_skipcomment((char_u *)s + 1);
+ s = cin_skipcomment(s + 1);
}
} else if ((strncmp(s, "class", 5) == 0 && !vim_isIDc((uint8_t)s[5]))
|| (strncmp(s, "struct", 6) == 0 && !vim_isIDc((uint8_t)s[6]))) {
@@ -1229,9 +1229,9 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
lookfor_ctor_init = false;
if (*s == 'c') {
- s = (char *)cin_skipcomment((char_u *)s + 5);
+ s = cin_skipcomment(s + 5);
} else {
- s = (char *)cin_skipcomment((char_u *)s + 6);
+ s = cin_skipcomment(s + 6);
}
} else {
if (s[0] == '{' || s[0] == '}' || s[0] == ';') {
@@ -1259,11 +1259,11 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
}
// When the line ends in a comma don't align with it.
- if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode((char_u *)s + 1)) {
+ if (lnum == curwin->w_cursor.lnum && *s == ',' && cin_nocode(s + 1)) {
pos->col = 0;
}
- s = (char *)cin_skipcomment((char_u *)s + 1);
+ s = cin_skipcomment(s + 1);
}
}
@@ -1282,7 +1282,7 @@ static int get_baseclass_amount(int col)
if (col == 0) {
amount = get_indent();
- if (find_last_paren((char_u *)get_cursor_line_ptr(), '(', ')')
+ if (find_last_paren(get_cursor_line_ptr(), '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
amount = get_indent_lnum(trypos->lnum); // XXX
}
@@ -1305,18 +1305,18 @@ static int get_baseclass_amount(int col)
/// Ignore "ignore" after "find" if it's not NULL.
static int cin_ends_in(const char *s, const char *find, const char *ignore)
{
- const char *p = (char *)s;
+ const char *p = s;
const char *r;
- int len = (int)strlen((char *)find);
+ int len = (int)strlen(find);
while (*p != NUL) {
- p = (char *)cin_skipcomment((char_u *)p);
+ p = cin_skipcomment(p);
if (strncmp(p, find, (size_t)len) == 0) {
- r = skipwhite((char *)p + len);
- if (ignore != NULL && strncmp(r, ignore, strlen((char *)ignore)) == 0) {
- r = skipwhite((char *)r + strlen((char *)ignore));
+ r = skipwhite(p + len);
+ if (ignore != NULL && strncmp(r, ignore, strlen(ignore)) == 0) {
+ r = skipwhite(r + strlen(ignore));
}
- if (cin_nocode((char_u *)r)) {
+ if (cin_nocode(r)) {
return true;
}
}
@@ -1338,15 +1338,15 @@ static int cin_starts_with(const char *s, const char *word)
/// Recognize a `extern "C"` or `extern "C++"` linkage specifications.
static int cin_is_cpp_extern_c(const char *s)
{
- const char_u *p;
+ const char *p;
int has_string_literal = false;
- s = (char *)cin_skipcomment((char_u *)s);
+ s = cin_skipcomment(s);
if (strncmp(s, "extern", 6) == 0 && (s[6] == NUL || !vim_iswordc((uint8_t)s[6]))) {
- p = cin_skipcomment((char_u *)skipwhite((char *)s + 6));
+ p = cin_skipcomment(skipwhite(s + 6));
while (*p != NUL) {
if (ascii_iswhite(*p)) {
- p = cin_skipcomment((char_u *)skipwhite((char *)p));
+ p = cin_skipcomment(skipwhite(p));
} else if (*p == '{') {
break;
} else if (p[0] == '"' && p[1] == 'C' && p[2] == '"') {
@@ -1375,17 +1375,17 @@ static int cin_is_cpp_extern_c(const char *s)
// Return the column found.
static int cin_skip2pos(pos_T *trypos)
{
- const char_u *line;
- const char_u *p;
- const char_u *new_p;
+ const char *line;
+ const char *p;
+ const char *new_p;
- line = (char_u *)ml_get(trypos->lnum);
+ line = ml_get(trypos->lnum);
p = line;
while (*p && (colnr_T)(p - line) < trypos->col) {
if (cin_iscomment(p)) {
p = cin_skipcomment(p);
} else {
- new_p = (char_u *)skip_string((char *)p);
+ new_p = skip_string(p);
if (new_p == p) {
p++;
} else {
@@ -1437,7 +1437,7 @@ static pos_T *find_match_paren(int ind_maxparen)
return find_match_char('(', ind_maxparen);
}
-static pos_T *find_match_char(char_u c, int ind_maxparen)
+static pos_T *find_match_char(char c, int ind_maxparen)
{
pos_T cursor_save;
pos_T *trypos;
@@ -1447,7 +1447,7 @@ static pos_T *find_match_char(char_u c, int ind_maxparen)
cursor_save = curwin->w_cursor;
ind_maxp_wk = ind_maxparen;
retry:
- if ((trypos = findmatchlimit(NULL, c, 0, ind_maxp_wk)) != NULL) {
+ if ((trypos = findmatchlimit(NULL, (uint8_t)c, 0, ind_maxp_wk)) != NULL) {
// check if the ( is in a // comment
if ((colnr_T)cin_skip2pos(trypos) > trypos->col) {
ind_maxp_wk = ind_maxparen - (cursor_save.lnum - trypos->lnum);
@@ -1515,7 +1515,7 @@ static int corr_ind_maxparen(pos_T *startpos)
// Set w_cursor.col to the column number of the last unmatched ')' or '{' in
// line "l". "l" must point to the start of the line.
-static int find_last_paren(const char_u *l, int start, int end)
+static int find_last_paren(const char *l, char start, char end)
{
int i;
int retval = false;
@@ -1525,7 +1525,7 @@ static int find_last_paren(const char_u *l, int start, int end)
for (i = 0; l[i] != NUL; i++) {
i = (int)(cin_skipcomment(l + i) - l); // ignore parens in comments
- i = (int)(skip_string((char *)l + i) - (char *)l); // ignore parens in quotes
+ i = (int)(skip_string(l + i) - l); // ignore parens in quotes
if (l[i] == start) {
open_count++;
} else if (l[i] == end) {
@@ -1852,7 +1852,7 @@ int get_c_indent(void)
pos_T *tryposBrace = NULL;
pos_T tryposCopy;
pos_T our_paren_pos;
- char_u *start;
+ char *start;
int start_brace;
#define BRACE_IN_COL0 1 // '{' is in column 0
#define BRACE_AT_START 2 // '{' is at start of line
@@ -1860,7 +1860,7 @@ int get_c_indent(void)
linenr_T ourscope;
const char *l;
const char *look;
- char_u terminated;
+ char terminated;
int lookfor;
#define LOOKFOR_INITIAL 0
#define LOOKFOR_IF 1
@@ -1955,7 +1955,7 @@ int get_c_indent(void)
}
// If we're inside a "//" comment and there is a "//" comment in a
// previous line, lineup with that one.
- if (cin_islinecomment((char_u *)theline)) {
+ if (cin_islinecomment(theline)) {
pos_T linecomment_pos;
trypos = find_line_comment(); // XXX
@@ -1977,7 +1977,7 @@ int get_c_indent(void)
}
// If we're inside a comment and not looking at the start of the
// comment, try using the 'comments' option.
- if (!cin_iscomment((char_u *)theline) && comment_pos != NULL) { // XXX
+ if (!cin_iscomment(theline) && comment_pos != NULL) { // XXX
int lead_start_len = 2;
int lead_middle_len = 1;
char lead_start[COM_MAX_LEN]; // start-comment string
@@ -2096,10 +2096,10 @@ int get_c_indent(void)
}
if (amount == -1) { // use the comment opener
if (!curbuf->b_ind_in_comment2) {
- start = (char_u *)ml_get(comment_pos->lnum);
- look = (char *)start + comment_pos->col + 2; // skip / and *
+ start = ml_get(comment_pos->lnum);
+ look = start + comment_pos->col + 2; // skip / and *
if (*look != NUL) { // if something after it
- comment_pos->col = (colnr_T)((char_u *)skipwhite((char *)look) - start);
+ comment_pos->col = (colnr_T)(skipwhite(look) - start);
}
}
getvcol(curwin, comment_pos, &col, NULL, NULL);
@@ -2147,7 +2147,7 @@ int get_c_indent(void)
amount = -1;
for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; lnum--) {
l = skipwhite(ml_get(lnum));
- if (cin_nocode((char_u *)l)) { // skip comment lines
+ if (cin_nocode(l)) { // skip comment lines
continue;
}
if (cin_ispreproc_cont(&l, &lnum, &amount)) {
@@ -2192,7 +2192,7 @@ int get_c_indent(void)
pos_T cursor_save = curwin->w_cursor;
pos_T outermost;
- char_u *line;
+ char *line;
trypos = &our_paren_pos;
do {
@@ -2205,24 +2205,24 @@ int get_c_indent(void)
curwin->w_cursor = cursor_save;
- line = (char_u *)ml_get(outermost.lnum);
+ line = ml_get(outermost.lnum);
is_if_for_while =
- cin_is_if_for_while_before_offset((char *)line, &outermost.col);
+ cin_is_if_for_while_before_offset(line, &outermost.col);
}
amount = skip_label(our_paren_pos.lnum, &look);
- look = skipwhite((char *)look);
+ look = skipwhite(look);
if (*look == '(') {
linenr_T save_lnum = curwin->w_cursor.lnum;
- char_u *line;
+ char *line;
int look_col;
// Ignore a '(' in front of the line that has a match before
// our matching '('.
curwin->w_cursor.lnum = our_paren_pos.lnum;
- line = (char_u *)get_cursor_line_ptr();
- look_col = (int)(look - (char *)line);
+ line = get_cursor_line_ptr();
+ look_col = (int)(look - line);
curwin->w_cursor.col = look_col + 1;
if ((trypos = findmatchlimit(NULL, ')', 0,
curbuf->b_ind_maxparen))
@@ -2353,7 +2353,7 @@ int get_c_indent(void)
}
// add extra indent for a comment
- if (cin_iscomment((char_u *)theline)) {
+ if (cin_iscomment(theline)) {
amount += curbuf->b_ind_comment;
}
} else {
@@ -2365,13 +2365,13 @@ int get_c_indent(void)
tryposBrace = &tryposCopy;
trypos = tryposBrace;
ourscope = trypos->lnum;
- start = (char_u *)ml_get(ourscope);
+ start = ml_get(ourscope);
// Now figure out how indented the line is in general.
// If the brace was at the start of the line, we use that;
// otherwise, check out the indentation of the line as
// a whole and then add the "imaginary indent" to that.
- look = skipwhite((char *)start);
+ look = skipwhite(start);
if (*look == '{') {
getvcol(curwin, trypos, &col, NULL, NULL);
amount = col;
@@ -2398,7 +2398,7 @@ int get_c_indent(void)
// ldfd) {
// }
if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label)
- && cin_iscase((char_u *)skipwhite(get_cursor_line_ptr()), false)) {
+ && cin_iscase(skipwhite(get_cursor_line_ptr()), false)) {
amount = get_indent();
} else if (curbuf->b_ind_js) {
amount = get_indent_lnum(lnum);
@@ -2410,7 +2410,7 @@ int get_c_indent(void)
}
// For Javascript check if the line starts with "key:".
- bool js_cur_has_key = curbuf->b_ind_js ? cin_has_js_key((char_u *)theline) : false;
+ bool js_cur_has_key = curbuf->b_ind_js ? cin_has_js_key(theline) : false;
// If we're looking at a closing brace, that's where
// we want to be. Otherwise, add the amount of room
@@ -2427,7 +2427,7 @@ int get_c_indent(void)
lookfor = LOOKFOR_INITIAL;
if (cin_iselse(theline)) {
lookfor = LOOKFOR_IF;
- } else if (cin_iswhileofdo((char_u *)theline, cur_curpos.lnum)) { // XXX
+ } else if (cin_iswhileofdo(theline, cur_curpos.lnum)) { // XXX
lookfor = LOOKFOR_DO;
}
if (lookfor != LOOKFOR_INITIAL) {
@@ -2458,7 +2458,7 @@ int get_c_indent(void)
amount += curbuf->b_ind_open_imag;
l = skipwhite(get_cursor_line_ptr());
- if (cin_is_cpp_namespace((char *)l)) {
+ if (cin_is_cpp_namespace(l)) {
amount += curbuf->b_ind_cpp_namespace;
} else if (cin_is_cpp_extern_c(l)) {
amount += curbuf->b_ind_cpp_extern_c;
@@ -2474,10 +2474,10 @@ int get_c_indent(void)
lookfor_break = false;
- if (cin_iscase((char_u *)theline, false)) { // it's a switch() label
+ if (cin_iscase(theline, false)) { // it's a switch() label
lookfor = LOOKFOR_CASE; // find a previous switch() label
amount += curbuf->b_ind_case;
- } else if (cin_isscopedecl((char_u *)theline)) { // private:, ...
+ } else if (cin_isscopedecl(theline)) { // private:, ...
lookfor = LOOKFOR_SCOPEDECL; // class decl is this block
amount += curbuf->b_ind_scopedecl;
} else {
@@ -2548,11 +2548,11 @@ int get_c_indent(void)
continue;
}
- if (cin_nocode((char_u *)l)) {
+ if (cin_nocode(l)) {
continue;
}
- terminated = cin_isterminated((char_u *)l, false, true);
+ terminated = cin_isterminated(l, false, true);
// If we are at top level and the line looks like a
// function declaration, we are done
@@ -2587,11 +2587,11 @@ int get_c_indent(void)
// will take us back to the start of the line.
// XXX
trypos = NULL;
- if (find_last_paren((char_u *)l, '(', ')')) {
+ if (find_last_paren(l, '(', ')')) {
trypos = find_match_paren(curbuf->b_ind_maxparen);
}
- if (trypos == NULL && find_last_paren((char_u *)l, '{', '}')) {
+ if (trypos == NULL && find_last_paren(l, '{', '}')) {
trypos = find_start_brace();
}
@@ -2658,7 +2658,7 @@ int get_c_indent(void)
}
// Finally the actual check for "namespace".
- if (cin_is_cpp_namespace((char *)l)) {
+ if (cin_is_cpp_namespace(l)) {
amount += curbuf->b_ind_cpp_namespace
- added_to_amount;
break;
@@ -2667,7 +2667,7 @@ int get_c_indent(void)
break;
}
- if (cin_nocode((char_u *)l)) {
+ if (cin_nocode(l)) {
continue;
}
}
@@ -2688,8 +2688,8 @@ int get_c_indent(void)
// If this is a switch() label, may line up relative to that.
// If this is a C++ scope declaration, do the same.
- bool iscase = cin_iscase((char_u *)l, false);
- if (iscase || cin_isscopedecl((char_u *)l)) {
+ bool iscase = cin_iscase(l, false);
+ if (iscase || cin_isscopedecl(l)) {
// we are only looking for cpp base class
// declaration/initialization any longer
if (lookfor == LOOKFOR_CPP_BASECLASS) {
@@ -2758,8 +2758,8 @@ int get_c_indent(void)
// -> y = y + 1;
if (n) {
amount = n;
- l = (char *)after_label((char_u *)get_cursor_line_ptr());
- if (l != NULL && cin_is_cinword((char *)l)) {
+ l = after_label(get_cursor_line_ptr());
+ if (l != NULL && cin_is_cinword(l)) {
if (theline[0] == '{') {
amount += curbuf->b_ind_open_extra;
} else {
@@ -2787,7 +2787,7 @@ int get_c_indent(void)
// Looking for a switch() label or C++ scope declaration,
// ignore other lines, skip {}-blocks.
if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL) {
- if (find_last_paren((char_u *)l, '{', '}')
+ if (find_last_paren(l, '{', '}')
&& (trypos = find_start_brace()) != NULL) {
curwin->w_cursor.lnum = trypos->lnum + 1;
curwin->w_cursor.col = 0;
@@ -2797,8 +2797,8 @@ int get_c_indent(void)
// Ignore jump labels with nothing after them.
if (!curbuf->b_ind_js && cin_islabel()) {
- l = (char *)after_label((char_u *)get_cursor_line_ptr());
- if (l == NULL || cin_nocode((char_u *)l)) {
+ l = after_label(get_cursor_line_ptr());
+ if (l == NULL || cin_nocode(l)) {
continue;
}
}
@@ -2809,7 +2809,7 @@ int get_c_indent(void)
// unlocked it)
l = get_cursor_line_ptr();
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)
- || cin_nocode((char_u *)l)) {
+ || cin_nocode(l)) {
continue;
}
@@ -2841,7 +2841,7 @@ int get_c_indent(void)
} else if (lookfor == LOOKFOR_CPP_BASECLASS) {
// only look, whether there is a cpp base class
// declaration or initialization before the opening brace.
- if (cin_isterminated((char_u *)l, true, false)) {
+ if (cin_isterminated(l, true, false)) {
break;
} else {
continue;
@@ -2857,7 +2857,7 @@ int get_c_indent(void)
// Otherwise check whether it is an enumeration or structure
// initialisation (not indented) or a variable declaration
// (indented).
- terminated = cin_isterminated((char_u *)l, false, true);
+ terminated = cin_isterminated(l, false, true);
if (js_cur_has_key) {
js_cur_has_key = false; // only check the first line
@@ -2872,7 +2872,7 @@ int get_c_indent(void)
lookfor = LOOKFOR_JS_KEY;
}
}
- if (lookfor == LOOKFOR_JS_KEY && cin_has_js_key((char_u *)l)) {
+ if (lookfor == LOOKFOR_JS_KEY && cin_has_js_key(l)) {
amount = get_indent();
break;
}
@@ -2898,7 +2898,7 @@ int get_c_indent(void)
if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
&& terminated == ',')) {
if (lookfor != LOOKFOR_ENUM_OR_INIT
- && (*skipwhite((char *)l) == '[' || l[strlen((char *)l) - 1] == '[')) {
+ && (*skipwhite(l) == '[' || l[strlen(l) - 1] == '[')) {
amount += ind_continuation;
}
// If we're in the middle of a paren thing, Go back to the line
@@ -2909,7 +2909,7 @@ int get_c_indent(void)
// Position the cursor over the rightmost paren, so that
// matching it will take us back to the start of the line.
// Ignore a match before the start of the block.
- (void)find_last_paren((char_u *)l, '(', ')');
+ (void)find_last_paren(l, '(', ')');
trypos = find_match_paren(corr_ind_maxparen(&cur_curpos));
if (trypos != NULL && (trypos->lnum < tryposBrace->lnum
|| (trypos->lnum == tryposBrace->lnum
@@ -2920,7 +2920,7 @@ int get_c_indent(void)
// If we are looking for ',', we also look for matching
// braces.
if (trypos == NULL && terminated == ','
- && find_last_paren((char_u *)l, '{', '}')) {
+ && find_last_paren(l, '{', '}')) {
trypos = find_start_brace();
}
@@ -2931,7 +2931,7 @@ int get_c_indent(void)
// asdf)
curwin->w_cursor = *trypos;
l = get_cursor_line_ptr();
- if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l)) {
+ if (cin_iscase(l, false) || cin_isscopedecl(l)) {
curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0;
continue;
@@ -2946,7 +2946,7 @@ int get_c_indent(void)
if (terminated == ',') {
while (curwin->w_cursor.lnum > 1) {
l = ml_get(curwin->w_cursor.lnum - 1);
- if (*l == NUL || l[strlen((char *)l) - 1] != '\\') {
+ if (*l == NUL || l[strlen(l) - 1] != '\\') {
break;
}
curwin->w_cursor.lnum--;
@@ -2974,7 +2974,7 @@ int get_c_indent(void)
// in the same line (scope is the same). Probably:
// { 1, 2 },
// -> { 3, 4 }
- if (*skipwhite((char *)l) != '{') {
+ if (*skipwhite(l) != '{') {
amount += curbuf->b_ind_open_extra;
}
@@ -2989,7 +2989,7 @@ int get_c_indent(void)
// Check if we are after an "if", "while", etc.
// Also allow " } else".
- if (cin_is_cinword((char *)l) || cin_iselse(skipwhite((char *)l))) {
+ if (cin_is_cinword(l) || cin_iselse(skipwhite(l))) {
// Found an unterminated line after an if (), line up
// with the last one.
// if (cond)
@@ -3032,7 +3032,7 @@ int get_c_indent(void)
// x = 1;
// -> here
l = skipwhite(get_cursor_line_ptr());
- if (cin_isdo((char *)l)) {
+ if (cin_isdo(l)) {
if (whilelevel == 0) {
break;
}
@@ -3043,7 +3043,7 @@ int get_c_indent(void)
// one between the "if" and the matching "else".
// Need to use the scope of this "else". XXX
// If whilelevel != 0 continue looking for a "do {".
- if (cin_iselse((char *)l) && whilelevel == 0) {
+ if (cin_iselse(l) && whilelevel == 0) {
// If we're looking at "} else", let's make sure we
// find the opening brace of the enclosing scope,
// not the one from "if () {".
@@ -3105,9 +3105,9 @@ int get_c_indent(void)
l = get_cursor_line_ptr();
amount = cur_amount;
- n = (int)strlen((char *)l);
+ n = (int)strlen(l);
if (terminated == ','
- && (*skipwhite((char *)l) == ']'
+ && (*skipwhite(l) == ']'
|| (n >= 2 && l[n - 2] == ']'))) {
break;
}
@@ -3134,7 +3134,7 @@ int get_c_indent(void)
// 4 *
// 5,
// 6,
- if (cin_iscomment((char_u *)skipwhite((char *)l))) {
+ if (cin_iscomment(skipwhite(l))) {
break;
}
lookfor = LOOKFOR_COMMA;
@@ -3154,7 +3154,7 @@ int get_c_indent(void)
} else {
if (lookfor == LOOKFOR_INITIAL
&& *l != NUL
- && l[strlen((char *)l) - 1] == '\\') {
+ && l[strlen(l) - 1] == '\\') {
// XXX
cont_amount = cin_get_equal_amount(curwin->w_cursor.lnum);
}
@@ -3169,7 +3169,7 @@ int get_c_indent(void)
}
// Check if we are after a while (cond);
// If so: Ignore until the matching "do".
- } else if (cin_iswhileofdo_end(terminated)) { // XXX
+ } else if (cin_iswhileofdo_end((uint8_t)terminated)) { // XXX
// Found an unterminated line after a while ();, line up
// with the last one.
// while (cond);
@@ -3210,8 +3210,8 @@ int get_c_indent(void)
// Handle "do {" line.
if (whilelevel > 0) {
- l = (char *)cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (cin_isdo((char *)l)) {
+ l = cin_skipcomment(get_cursor_line_ptr());
+ if (cin_isdo(l)) {
amount = get_indent(); // XXX
whilelevel--;
continue;
@@ -3261,7 +3261,7 @@ int get_c_indent(void)
// here;
term_again:
l = get_cursor_line_ptr();
- if (find_last_paren((char_u *)l, '(', ')')
+ if (find_last_paren(l, '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
// Check if we are on a case label now. This is
// handled above.
@@ -3269,7 +3269,7 @@ term_again:
// asdf)
curwin->w_cursor = *trypos;
l = get_cursor_line_ptr();
- if (cin_iscase((char_u *)l, false) || cin_isscopedecl((char_u *)l)) {
+ if (cin_iscase(l, false) || cin_isscopedecl(l)) {
curwin->w_cursor.lnum++;
curwin->w_cursor.col = 0;
continue;
@@ -3284,7 +3284,7 @@ term_again:
// case 2:
// stat;
// }
- iscase = curbuf->b_ind_keep_case_label && cin_iscase((char_u *)l, false);
+ iscase = curbuf->b_ind_keep_case_label && cin_iscase(l, false);
// Get indent and pointer to text for current line,
// ignoring any jump label.
@@ -3294,7 +3294,7 @@ term_again:
amount += curbuf->b_ind_open_extra;
}
// See remark above: "Only add b_ind_open_extra.."
- l = skipwhite((char *)l);
+ l = skipwhite(l);
if (*l == '{') {
amount -= curbuf->b_ind_open_extra;
}
@@ -3308,7 +3308,7 @@ term_again:
// If whilelevel != 0 continue looking for a "do {".
if (lookfor == LOOKFOR_TERM
&& *l != '}'
- && cin_iselse((char *)l)
+ && cin_iselse(l)
&& whilelevel == 0) {
if ((trypos = find_start_brace()) == NULL
|| find_match(LOOKFOR_IF, trypos->lnum)
@@ -3321,13 +3321,13 @@ term_again:
// If we're at the end of a block, skip to the start of
// that block.
l = get_cursor_line_ptr();
- if (find_last_paren((char_u *)l, '{', '}') // XXX
+ if (find_last_paren(l, '{', '}') // XXX
&& (trypos = find_start_brace()) != NULL) {
curwin->w_cursor = *trypos;
// if not "else {" check for terminated again
// but skip block for "} else {"
- l = (char *)cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (*l == '}' || !cin_iselse((char *)l)) {
+ l = cin_skipcomment(get_cursor_line_ptr());
+ if (*l == '}' || !cin_iselse(l)) {
goto term_again;
}
curwin->w_cursor.lnum++;
@@ -3340,7 +3340,7 @@ term_again:
}
// add extra indent for a comment
- if (cin_iscomment((char_u *)theline)) {
+ if (cin_iscomment(theline)) {
amount += curbuf->b_ind_comment;
}
// subtract extra left-shift for jump labels
@@ -3372,13 +3372,13 @@ term_again:
// current line is terminated, ie. ends in ';', or if the current line
// contains { or }: "void f() {\n if (1)"
if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
- && !cin_nocode((char_u *)theline)
+ && !cin_nocode(theline)
&& vim_strchr(theline, '{') == NULL
&& vim_strchr(theline, '}') == NULL
&& !cin_ends_in(theline, ":", NULL)
&& !cin_ends_in(theline, ",", NULL)
&& cin_isfuncdecl(NULL, cur_curpos.lnum + 1, cur_curpos.lnum + 1)
- && !cin_isterminated((char_u *)theline, false, true)) {
+ && !cin_isterminated(theline, false, true)) {
amount = curbuf->b_ind_func_type;
goto theend;
}
@@ -3421,7 +3421,7 @@ term_again:
continue;
}
- if (cin_nocode((char_u *)l)) {
+ if (cin_nocode(l)) {
continue;
}
@@ -3436,9 +3436,9 @@ term_again:
// } foo,
// bar;
if (cin_ends_in(l, ",", NULL)
- || (*l != NUL && (n = (uint8_t)l[strlen((char *)l) - 1]) == '\\')) {
+ || (*l != NUL && (n = (uint8_t)l[strlen(l) - 1]) == '\\')) {
// take us back to opening paren
- if (find_last_paren((char_u *)l, '(', ')')
+ if (find_last_paren(l, '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
curwin->w_cursor = *trypos;
}
@@ -3450,7 +3450,7 @@ term_again:
// here;
while (n == 0 && curwin->w_cursor.lnum > 1) {
l = ml_get(curwin->w_cursor.lnum - 1);
- if (*l == NUL || l[strlen((char *)l) - 1] != '\\') {
+ if (*l == NUL || l[strlen(l) - 1] != '\\') {
break;
}
curwin->w_cursor.lnum--;
@@ -3477,7 +3477,7 @@ term_again:
// Finding the closing '}' of a previous function. Put
// current line at the left margin. For when 'cino' has "fs".
- if (*skipwhite((char *)l) == '}') {
+ if (*skipwhite(l) == '}') {
break;
}
@@ -3502,12 +3502,12 @@ term_again:
// Find a line only has a semicolon that belongs to a previous
// line ending in '}', e.g. before an #endif. Don't increase
// indent then.
- if (*(look = skipwhite((char *)l)) == ';' && cin_nocode((char_u *)look + 1)) {
+ if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1)) {
pos_T curpos_save = curwin->w_cursor;
while (curwin->w_cursor.lnum > 1) {
look = ml_get(--curwin->w_cursor.lnum);
- if (!(cin_nocode((char_u *)look)
+ if (!(cin_nocode(look)
|| cin_ispreproc_cont(&look, &curwin->w_cursor.lnum, &amount))) {
break;
}
@@ -3536,7 +3536,7 @@ term_again:
if (cin_ends_in(l, ";", NULL)) {
l = ml_get(curwin->w_cursor.lnum - 1);
if (cin_ends_in(l, ",", NULL)
- || (*l != NUL && l[strlen((char *)l) - 1] == '\\')) {
+ || (*l != NUL && l[strlen(l) - 1] == '\\')) {
break;
}
l = get_cursor_line_ptr();
@@ -3547,7 +3547,7 @@ term_again:
//
// Position the cursor over the rightmost paren, so that
// matching it will take us back to the start of the line.
- (void)find_last_paren((char_u *)l, '(', ')');
+ (void)find_last_paren(l, '(', ')');
if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
curwin->w_cursor = *trypos;
@@ -3557,7 +3557,7 @@ term_again:
}
// add extra indent for a comment
- if (cin_iscomment((char_u *)theline)) {
+ if (cin_iscomment(theline)) {
amount += curbuf->b_ind_comment;
}
@@ -3568,7 +3568,7 @@ term_again:
// here";
if (cur_curpos.lnum > 1) {
l = ml_get(cur_curpos.lnum - 1);
- if (*l != NUL && l[strlen((char *)l) - 1] == '\\') {
+ if (*l != NUL && l[strlen(l) - 1] == '\\') {
cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1);
if (cur_amount > 0) {
amount = cur_amount;
@@ -3594,9 +3594,9 @@ laterend:
static int find_match(int lookfor, linenr_T ourscope)
{
- const char_u *look;
+ const char *look;
pos_T *theirscope;
- const char_u *mightbeif;
+ const char *mightbeif;
int elselevel;
int whilelevel;
@@ -3614,10 +3614,10 @@ static int find_match(int lookfor, linenr_T ourscope)
curwin->w_cursor.lnum--;
curwin->w_cursor.col = 0;
- look = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (!cin_iselse((char *)look)
- && !cin_isif((char *)look)
- && !cin_isdo((char *)look) // XXX
+ look = cin_skipcomment(get_cursor_line_ptr());
+ if (!cin_iselse(look)
+ && !cin_isif(look)
+ && !cin_isdo(look) // XXX
&& !cin_iswhileofdo(look, curwin->w_cursor.lnum)) {
continue;
}
@@ -3646,10 +3646,10 @@ static int find_match(int lookfor, linenr_T ourscope)
// if it was an "else" (that's not an "else if")
// then we need to go back to another if, so
// increment elselevel
- look = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (cin_iselse((char *)look)) {
+ look = cin_skipcomment(get_cursor_line_ptr());
+ if (cin_iselse(look)) {
mightbeif = cin_skipcomment(look + 4);
- if (!cin_isif((char *)mightbeif)) {
+ if (!cin_isif(mightbeif)) {
elselevel++; // NOLINT(readability/braces)
}
continue;
@@ -3663,8 +3663,8 @@ static int find_match(int lookfor, linenr_T ourscope)
}
// If it's an "if" decrement elselevel
- look = cin_skipcomment((char_u *)get_cursor_line_ptr());
- if (cin_isif((char *)look)) {
+ look = cin_skipcomment(get_cursor_line_ptr());
+ if (cin_isif(look)) {
elselevel--; // NOLINT(readability/braces)
// When looking for an "if" ignore "while"s that
// get in the way.
@@ -3674,7 +3674,7 @@ static int find_match(int lookfor, linenr_T ourscope)
}
// If it's a "do" decrement whilelevel
- if (cin_isdo((char *)look)) {
+ if (cin_isdo(look)) {
whilelevel--;
}
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index af3f1e3679..b057f8d0e4 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -683,7 +683,7 @@ static void fname2fnum(xfmark_T *fm)
// Used for marks that come from the .shada file.
void fmarks_check_names(buf_T *buf)
{
- char_u *name = (char_u *)buf->b_ffname;
+ char *name = buf->b_ffname;
int i;
if (buf->b_ffname == NULL) {
@@ -691,12 +691,12 @@ void fmarks_check_names(buf_T *buf)
}
for (i = 0; i < NGLOBALMARKS; i++) {
- fmarks_check_one(&namedfm[i], (char *)name, buf);
+ fmarks_check_one(&namedfm[i], name, buf);
}
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
for (i = 0; i < wp->w_jumplistlen; i++) {
- fmarks_check_one(&wp->w_jumplist[i], (char *)name, buf);
+ fmarks_check_one(&wp->w_jumplist[i], name, buf);
}
}
}
@@ -781,12 +781,12 @@ void clrallmarks(buf_T *const buf)
// Get name of file from a filemark.
// When it's in the current buffer, return the text at the mark.
// Returns an allocated string.
-char_u *fm_getname(fmark_T *fmark, int lead_len)
+char *fm_getname(fmark_T *fmark, int lead_len)
{
if (fmark->fnum == curbuf->b_fnum) { // current buffer
- return (char_u *)mark_line(&(fmark->mark), lead_len);
+ return mark_line(&(fmark->mark), lead_len);
}
- return (char_u *)buflist_nr2name(fmark->fnum, false, true);
+ return buflist_nr2name(fmark->fnum, false, true);
}
/// Return the line at mark "mp". Truncate to fit in window.
@@ -818,9 +818,9 @@ static char *mark_line(pos_T *mp, int lead_len)
// print the marks
void ex_marks(exarg_T *eap)
{
- char_u *arg = (char_u *)eap->arg;
+ char *arg = eap->arg;
int i;
- char_u *name;
+ char *name;
pos_T *posp, *startp, *endp;
if (arg != NULL && *arg == NUL) {
@@ -833,9 +833,9 @@ void ex_marks(exarg_T *eap)
}
for (i = 0; i < NGLOBALMARKS; i++) {
if (namedfm[i].fmark.fnum != 0) {
- name = fm_getname(&namedfm[i].fmark, 15);
+ name = (char *)fm_getname(&namedfm[i].fmark, 15);
} else {
- name = (char_u *)namedfm[i].fname;
+ name = namedfm[i].fname;
}
if (name != NULL) {
show_one_mark(i >= NMARKS ? i - NMARKS + '0' : i + 'A',
@@ -867,11 +867,11 @@ void ex_marks(exarg_T *eap)
}
/// @param current in current file
-static void show_one_mark(int c, char_u *arg, pos_T *p, char_u *name_arg, int current)
+static void show_one_mark(int c, char *arg, pos_T *p, char *name_arg, int current)
{
static bool did_title = false;
bool mustfree = false;
- char_u *name = name_arg;
+ char *name = name_arg;
if (c == -1) { // finish up
if (did_title) {
@@ -884,14 +884,14 @@ static void show_one_mark(int c, char_u *arg, pos_T *p, char_u *name_arg, int cu
}
}
} else if (!got_int
- && (arg == NULL || vim_strchr((char *)arg, c) != NULL)
+ && (arg == NULL || vim_strchr(arg, c) != NULL)
&& p->lnum != 0) {
// don't output anything if 'q' typed at --more-- prompt
if (name == NULL && current) {
- name = (char_u *)mark_line(p, 15);
+ name = mark_line(p, 15);
mustfree = true;
}
- if (!message_filtered((char *)name)) {
+ if (!message_filtered(name)) {
if (!did_title) {
// Highlight title
msg_puts_title(_("\nmark line col file/text"));
@@ -902,7 +902,7 @@ static void show_one_mark(int c, char_u *arg, pos_T *p, char_u *name_arg, int cu
snprintf(IObuff, IOSIZE, " %c %6" PRIdLINENR " %4d ", c, p->lnum, p->col);
msg_outtrans(IObuff);
if (name != NULL) {
- msg_outtrans_attr((char *)name, current ? HL_ATTR(HLF_D) : 0);
+ msg_outtrans_attr(name, current ? HL_ATTR(HLF_D) : 0);
}
}
}
@@ -1050,7 +1050,7 @@ void ex_clearjumps(exarg_T *eap)
void ex_changes(exarg_T *eap)
{
int i;
- char_u *name;
+ char *name;
// Highlight title
msg_puts_title(_("\nchange line col text"));
@@ -1067,8 +1067,8 @@ void ex_changes(exarg_T *eap)
(long)curbuf->b_changelist[i].mark.lnum,
curbuf->b_changelist[i].mark.col);
msg_outtrans(IObuff);
- name = (char_u *)mark_line(&curbuf->b_changelist[i].mark, 17);
- msg_outtrans_attr((char *)name, HL_ATTR(HLF_D));
+ name = mark_line(&curbuf->b_changelist[i].mark, 17);
+ msg_outtrans_attr(name, HL_ATTR(HLF_D));
xfree(name);
os_breakcheck();
}
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index ec3ceca5bc..03ce345b78 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -335,7 +335,7 @@ static void shift_block(oparg_T *oap, int amount)
{
const bool left = (oap->op_type == OP_LSHIFT);
const int oldstate = State;
- char_u *newp;
+ char *newp;
const int oldcol = curwin->w_cursor.col;
const int sw_val = (int)get_sw_value_indent(curbuf);
const int ts_val = (int)curbuf->b_p_ts;
@@ -406,7 +406,7 @@ static void shift_block(oparg_T *oap, int amount)
const int len = (int)strlen(bd.textstart) + 1;
int col = bd.textcol + i + j + len;
assert(col >= 0);
- newp = (char_u *)xmalloc((size_t)col);
+ newp = xmalloc((size_t)col);
memset(newp, NUL, (size_t)col);
memmove(newp, oldp, (size_t)bd.textcol);
startcol = bd.textcol;
@@ -502,7 +502,7 @@ static void shift_block(oparg_T *oap, int amount)
// - the rest of the line, pointed to by non_white.
new_line_len = verbatim_diff + fill + strlen(non_white) + 1;
- newp = (char_u *)xmalloc(new_line_len);
+ newp = xmalloc(new_line_len);
startcol = (int)verbatim_diff;
oldlen = bd.textcol + (int)(non_white - bd.textstart) - (int)verbatim_diff;
newlen = (int)fill;
@@ -511,7 +511,7 @@ static void shift_block(oparg_T *oap, int amount)
STRMOVE(newp + verbatim_diff + fill, non_white);
}
// replace the line
- ml_replace(curwin->w_cursor.lnum, (char *)newp, false);
+ ml_replace(curwin->w_cursor.lnum, newp, false);
changed_bytes(curwin->w_cursor.lnum, bd.textcol);
extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, startcol,
oldlen, newlen,
@@ -636,7 +636,7 @@ static void block_insert(oparg_T *oap, char *s, int b_insert, struct block_def *
void op_reindent(oparg_T *oap, Indenter how)
{
long i = 0;
- char_u *l;
+ char *l;
int amount;
linenr_T first_changed = 0;
linenr_T last_changed = 0;
@@ -666,7 +666,7 @@ void op_reindent(oparg_T *oap, Indenter how)
// indented, unless there is only one line.
if (i != oap->line_count - 1 || oap->line_count == 1
|| how != get_lisp_indent) {
- l = (char_u *)skipwhite(get_cursor_line_ptr());
+ l = skipwhite(get_cursor_line_ptr());
if (*l == NUL) { // empty or blank line
amount = 0;
} else {
@@ -721,16 +721,16 @@ static char *expr_line = NULL;
/// @return '=' when OK, NUL otherwise.
int get_expr_register(void)
{
- char_u *new_line;
+ char *new_line;
- new_line = getcmdline('=', 0L, 0, true);
+ new_line = (char *)getcmdline('=', 0L, 0, true);
if (new_line == NULL) {
return NUL;
}
if (*new_line == NUL) { // use previous line
xfree(new_line);
} else {
- set_expr_line((char *)new_line);
+ set_expr_line(new_line);
}
return '=';
}
@@ -902,7 +902,7 @@ bool yank_register_mline(int regname)
/// @return FAIL for failure, OK otherwise.
int do_record(int c)
{
- char_u *p;
+ char *p;
static int regname;
yankreg_T *old_y_previous;
int retval;
@@ -927,10 +927,10 @@ int do_record(int c)
dict_T *dict = get_v_event(&save_v_event);
// The recorded text contents.
- p = get_recorded();
+ p = (char *)get_recorded();
if (p != NULL) {
// Remove escaping for K_SPECIAL in multi-byte chars.
- vim_unescape_ks(p);
+ vim_unescape_ks((char_u *)p);
(void)tv_dict_add_str(dict, S_LEN("regcontents"), (const char *)p);
}
@@ -960,7 +960,7 @@ int do_record(int c)
// restore the current register name.
old_y_previous = y_previous;
- retval = stuff_yank(regname, (char *)p);
+ retval = stuff_yank(regname, p);
y_previous = old_y_previous;
}
@@ -996,13 +996,13 @@ static int stuff_yank(int regname, char *p)
yankreg_T *reg = get_yank_register(regname, YREG_YANK);
if (is_append_register(regname) && reg->y_array != NULL) {
char **pp = &(reg->y_array[reg->y_size - 1]);
- char_u *lp = xmalloc(strlen(*pp) + strlen(p) + 1);
+ char *lp = xmalloc(strlen(*pp) + strlen(p) + 1);
STRCPY(lp, *pp);
// TODO(philix): use xstpcpy() in stuff_yank()
STRCAT(lp, p);
xfree(p);
xfree(*pp);
- *pp = (char *)lp;
+ *pp = lp;
} else {
free_register(reg);
set_yreg_additional_data(reg, NULL);
@@ -1037,13 +1037,13 @@ static char_u *execreg_line_continuation(char **lines, size_t *idx)
garray_T ga;
ga_init(&ga, (int)sizeof(char_u), 400);
- char_u *p;
+ char *p;
// search backwards to find the first line of this command.
// Any line not starting with \ or "\ is the start of the
// command.
while (--i > 0) {
- p = (char_u *)skipwhite(lines[i]);
+ p = skipwhite(lines[i]);
if (*p != '\\' && (p[0] != '"' || p[1] != '\\' || p[2] != ' ')) {
break;
}
@@ -1053,14 +1053,14 @@ static char_u *execreg_line_continuation(char **lines, size_t *idx)
// join all the lines
ga_concat(&ga, lines[cmd_start]);
for (size_t j = cmd_start + 1; j <= cmd_end; j++) {
- p = (char_u *)skipwhite(lines[j]);
+ p = skipwhite(lines[j]);
if (*p == '\\') {
// Adjust the growsize to the current length to
// speed up concatenating many lines.
if (ga.ga_len > 400) {
ga_set_growsize(&ga, MIN(ga.ga_len, 8000));
}
- ga_concat(&ga, (char *)(p + 1));
+ ga_concat(&ga, p + 1);
}
}
ga_append(&ga, NUL);
@@ -1159,16 +1159,16 @@ int do_execreg(int regname, int colon, int addcr, int silent)
}
// Handle line-continuation for :@<register>
- char_u *str = (char_u *)reg->y_array[i];
+ char *str = reg->y_array[i];
bool free_str = false;
if (colon && i > 0) {
- p = skipwhite((char *)str);
+ p = skipwhite(str);
if (*p == '\\' || (p[0] == '"' && p[1] == '\\' && p[2] == ' ')) {
- str = execreg_line_continuation(reg->y_array, &i);
+ str = (char *)execreg_line_continuation(reg->y_array, &i);
free_str = true;
}
}
- escaped = vim_strsave_escape_ks((char *)str);
+ escaped = vim_strsave_escape_ks(str);
if (free_str) {
xfree(str);
}
@@ -1822,7 +1822,7 @@ static int op_replace(oparg_T *oap, int c)
char *newp, *oldp;
colnr_T oldlen;
struct block_def bd;
- char_u *after_p = NULL;
+ char *after_p = NULL;
int had_ctrl_v_cr = false;
if ((curbuf->b_ml.ml_flags & ML_EMPTY) || oap->empty) {
@@ -1934,7 +1934,7 @@ static int op_replace(oparg_T *oap, int c)
} else {
// Replacing with \r or \n means splitting the line.
after_p_len = (size_t)col;
- after_p = (char_u *)xmalloc(after_p_len);
+ after_p = xmalloc(after_p_len);
memmove(after_p, oldp, after_p_len);
newrows = 1;
}
@@ -1943,7 +1943,7 @@ static int op_replace(oparg_T *oap, int c)
curbuf_splice_pending++;
linenr_T baselnum = curwin->w_cursor.lnum;
if (after_p != NULL) {
- ml_append(curwin->w_cursor.lnum++, (char *)after_p, (int)after_p_len, false);
+ ml_append(curwin->w_cursor.lnum++, after_p, (int)after_p_len, false);
appended_lines_mark(curwin->w_cursor.lnum, 1L);
oap->end.lnum++;
xfree(after_p);
@@ -2438,7 +2438,7 @@ int op_change(oparg_T *oap)
long ins_len;
long pre_textlen = 0;
long pre_indent = 0;
- char_u *newp;
+ char *newp;
char *firstline;
char *ins_text;
char *oldp;
@@ -2538,7 +2538,7 @@ int op_change(oparg_T *oap)
offset += ins_len;
oldp += bd.textcol;
STRMOVE(newp + offset, oldp);
- ml_replace(linenr, (char *)newp, false);
+ ml_replace(linenr, newp, false);
extmark_splice_cols(curbuf, (int)linenr - 1, bd.textcol,
0, vpos.coladd + (int)ins_len, kExtmarkUndo);
}
@@ -2619,7 +2619,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
size_t yanklines = (size_t)oap->line_count;
linenr_T yankendlnum = oap->end.lnum;
char *p;
- char_u *pnew;
+ char *pnew;
struct block_def bd;
yankreg_T *curr = reg; // copy of current register
@@ -2760,7 +2760,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
STRCAT(pnew, reg->y_array[0]);
xfree(curr->y_array[j]);
xfree(reg->y_array[0]);
- curr->y_array[j++] = (char *)pnew;
+ curr->y_array[j++] = pnew;
y_idx = 1;
} else {
y_idx = 0;
@@ -2826,8 +2826,8 @@ static void yank_copy_line(yankreg_T *reg, struct block_def *bd, size_t y_idx,
}
int size = bd->startspaces + bd->endspaces + bd->textlen;
assert(size >= 0);
- char_u *pnew = xmallocz((size_t)size);
- reg->y_array[y_idx] = (char *)pnew;
+ char *pnew = xmallocz((size_t)size);
+ reg->y_array[y_idx] = pnew;
memset(pnew, ' ', (size_t)bd->startspaces);
pnew += bd->startspaces;
memmove(pnew, bd->textstart, (size_t)bd->textlen);
@@ -3007,11 +3007,11 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
// strlen(ml_get(curwin->w_cursor.lnum)). With 'virtualedit' and the
// cursor past the end of the line, curwin->w_cursor.coladd is
// incremented instead of curwin->w_cursor.col.
- char_u *cursor_pos = (char_u *)get_cursor_pos_ptr();
+ char *cursor_pos = get_cursor_pos_ptr();
bool one_past_line = (*cursor_pos == NUL);
bool eol = false;
if (!one_past_line) {
- eol = (*(cursor_pos + utfc_ptr2len((char *)cursor_pos)) == NUL);
+ eol = (*(cursor_pos + utfc_ptr2len(cursor_pos)) == NUL);
}
bool ve_allows = (cur_ve_flags == VE_ALL || cur_ve_flags == VE_ONEMORE);
@@ -3763,10 +3763,10 @@ int get_unname_register(void)
/// ":dis" and ":registers": Display the contents of the yank registers.
void ex_display(exarg_T *eap)
{
- char_u *p;
+ char *p;
yankreg_T *yb;
int name;
- char_u *arg = (char_u *)eap->arg;
+ char *arg = eap->arg;
int clen;
int type;
@@ -3788,7 +3788,7 @@ void ex_display(exarg_T *eap)
type = 'b'; break;
}
- if (arg != NULL && vim_strchr((char *)arg, name) == NULL) {
+ if (arg != NULL && vim_strchr(arg, name) == NULL) {
continue; // did not ask for this register
}
@@ -3832,10 +3832,10 @@ void ex_display(exarg_T *eap)
msg_puts_attr("^J", attr);
n -= 2;
}
- for (p = (char_u *)yb->y_array[j];
- *p != NUL && (n -= ptr2cells((char *)p)) >= 0; p++) { // -V1019
- clen = utfc_ptr2len((char *)p);
- msg_outtrans_len((char *)p, clen);
+ for (p = yb->y_array[j];
+ *p != NUL && (n -= ptr2cells(p)) >= 0; p++) { // -V1019
+ clen = utfc_ptr2len(p);
+ msg_outtrans_len(p, clen);
p += clen - 1;
}
}
@@ -3848,15 +3848,15 @@ void ex_display(exarg_T *eap)
}
// display last inserted text
- if ((p = get_last_insert()) != NULL
- && (arg == NULL || vim_strchr((char *)arg, '.') != NULL) && !got_int
- && !message_filtered((char *)p)) {
+ if ((p = (char *)get_last_insert()) != NULL
+ && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int
+ && !message_filtered(p)) {
msg_puts("\n c \". ");
- dis_msg((char *)p, true);
+ dis_msg(p, true);
}
// display last command line
- if (last_cmdline != NULL && (arg == NULL || vim_strchr((char *)arg, ':') != NULL)
+ if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL)
&& !got_int && !message_filtered(last_cmdline)) {
msg_puts("\n c \": ");
dis_msg(last_cmdline, false);
@@ -3864,14 +3864,14 @@ void ex_display(exarg_T *eap)
// display current file name
if (curbuf->b_fname != NULL
- && (arg == NULL || vim_strchr((char *)arg, '%') != NULL) && !got_int
+ && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int
&& !message_filtered(curbuf->b_fname)) {
msg_puts("\n c \"% ");
dis_msg(curbuf->b_fname, false);
}
// display alternate file name
- if ((arg == NULL || vim_strchr((char *)arg, '%') != NULL) && !got_int) {
+ if ((arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int) {
char *fname;
linenr_T dummy;
@@ -3883,14 +3883,14 @@ void ex_display(exarg_T *eap)
// display last search pattern
if (last_search_pat() != NULL
- && (arg == NULL || vim_strchr((char *)arg, '/') != NULL) && !got_int
+ && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int
&& !message_filtered((char *)last_search_pat())) {
msg_puts("\n c \"/ ");
dis_msg((char *)last_search_pat(), false);
}
// display last used expression
- if (expr_line != NULL && (arg == NULL || vim_strchr((char *)arg, '=') != NULL)
+ if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL)
&& !got_int && !message_filtered(expr_line)) {
msg_puts("\n c \"= ");
dis_msg(expr_line, false);
diff --git a/src/nvim/path.c b/src/nvim/path.c
index c78b899636..e4c75f67a8 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1113,7 +1113,7 @@ const char *gettail_dir(const char *const fname)
/// Returns the total number of matches.
///
/// @param flags EW_* flags
-static int expand_in_path(garray_T *const gap, char_u *const pattern, const int flags)
+static int expand_in_path(garray_T *const gap, char *const pattern, const int flags)
{
garray_T path_ga;
@@ -1127,7 +1127,7 @@ static int expand_in_path(garray_T *const gap, char_u *const pattern, const int
return 0;
}
- char_u *const paths = ga_concat_strings(&path_ga);
+ char *const paths = (char *)ga_concat_strings(&path_ga);
ga_clear_strings(&path_ga);
int glob_flags = 0;
@@ -1137,7 +1137,7 @@ static int expand_in_path(garray_T *const gap, char_u *const pattern, const int
if (flags & EW_ADDSLASH) {
glob_flags |= WILD_ADD_SLASH;
}
- globpath((char *)paths, (char *)pattern, gap, glob_flags);
+ globpath(paths, pattern, gap, glob_flags);
xfree(paths);
return gap->ga_len;
@@ -1208,7 +1208,7 @@ static bool has_special_wildchar(char_u *p)
int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, int flags)
{
garray_T ga;
- char_u *p;
+ char *p;
static bool recursive = false;
int add_pat;
bool did_expand_in_path = false;
@@ -1245,10 +1245,10 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
for (int i = 0; i < num_pat && !got_int; i++) {
add_pat = -1;
- p = (char_u *)pat[i];
+ p = pat[i];
- if (vim_backtick((char *)p)) {
- add_pat = expand_backtick(&ga, (char *)p, flags);
+ if (vim_backtick(p)) {
+ add_pat = expand_backtick(&ga, p, flags);
if (add_pat == -1) {
recursive = false;
ga_clear_strings(&ga);
@@ -1258,16 +1258,16 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
}
} else {
// First expand environment variables, "~/" and "~user/".
- if ((has_env_var(p) && !(flags & EW_NOTENV)) || *p == '~') {
- p = expand_env_save_opt(p, true);
+ if ((has_env_var((char_u *)p) && !(flags & EW_NOTENV)) || *p == '~') {
+ p = (char *)expand_env_save_opt((char_u *)p, true);
if (p == NULL) {
- p = (char_u *)pat[i];
+ p = pat[i];
} else {
#ifdef UNIX
// On Unix, if expand_env() can't expand an environment
// variable, use the shell to do that. Discard previously
// found file names and start all over again.
- if (has_env_var(p) || *p == '~') {
+ if (has_env_var((char_u *)p) || *p == '~') {
xfree(p);
ga_clear_strings(&ga);
i = os_expand_wildcards(num_pat, pat, num_file, file,
@@ -1284,9 +1284,9 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
// there is no match, and EW_NOTFOUND is given, add the pattern.
// Otherwise: Add the file name if it exists or when EW_NOTFOUND is
// given.
- if (path_has_exp_wildcard(p) || (flags & EW_ICASE)) {
+ if (path_has_exp_wildcard((char_u *)p) || (flags & EW_ICASE)) {
if ((flags & EW_PATH)
- && !path_is_absolute(p)
+ && !path_is_absolute((char_u *)p)
&& !(p[0] == '.'
&& (vim_ispathsep(p[1])
|| (p[1] == '.'
@@ -1298,7 +1298,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
recursive = true;
did_expand_in_path = true;
} else {
- size_t tmp_add_pat = path_expand(&ga, p, flags);
+ size_t tmp_add_pat = path_expand(&ga, (char_u *)p, flags);
assert(tmp_add_pat <= INT_MAX);
add_pat = (int)tmp_add_pat;
}
@@ -1306,14 +1306,14 @@ 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))) {
- char_u *t = (char_u *)backslash_halve_save((char *)p);
+ char *t = backslash_halve_save(p);
// When EW_NOTFOUND is used, always add files and dirs. Makes
// "vim c:/" work.
if (flags & EW_NOTFOUND) {
- addfile(&ga, (char *)t, flags | EW_DIR | EW_FILE);
+ addfile(&ga, t, flags | EW_DIR | EW_FILE);
} else {
- addfile(&ga, (char *)t, flags);
+ addfile(&ga, t, flags);
}
if (t != p) {
@@ -1322,9 +1322,9 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
}
if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & EW_PATH)) {
- uniquefy_paths(&ga, (char *)p);
+ uniquefy_paths(&ga, p);
}
- if (p != (char_u *)pat[i]) {
+ if (p != pat[i]) {
xfree(p);
}
}
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 73a62429bd..4cfbab8dba 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -2254,7 +2254,7 @@ int check_linecomment(const char *line)
}
} else if (!in_str && ((p - line) < 2
|| (*(p - 1) != '\\' && *(p - 2) != '#'))
- && !is_pos_in_string((char_u *)line, (colnr_T)(p - line))) {
+ && !is_pos_in_string(line, (colnr_T)(p - line))) {
break; // found!
}
p++;
@@ -2268,7 +2268,7 @@ int check_linecomment(const char *line)
// because * / / * is an end and start of a C comment. Only
// accept the position if it is not inside a string.
if (p[1] == '/' && (p == line || p[-1] != '*' || p[2] != '*')
- && !is_pos_in_string((char_u *)line, (colnr_T)(p - line))) {
+ && !is_pos_in_string(line, (colnr_T)(p - line))) {
break;
}
p++;
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 87d537559a..8ff93477f9 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -740,8 +740,8 @@ static int syn_match_linecont(linenr_T lnum)
if (syn_block->b_syn_linecont_prog != NULL) {
regmmatch_T regmatch;
// chartab array for syn iskeyword
- char_u buf_chartab[32];
- save_chartab((char *)buf_chartab);
+ char buf_chartab[32];
+ save_chartab(buf_chartab);
regmatch.rmm_ic = syn_block->b_syn_linecont_ic;
regmatch.regprog = syn_block->b_syn_linecont_prog;
@@ -749,7 +749,7 @@ static int syn_match_linecont(linenr_T lnum)
IF_SYN_TIME(&syn_block->b_syn_linecont_time));
syn_block->b_syn_linecont_prog = regmatch.regprog;
- restore_chartab((char *)buf_chartab);
+ restore_chartab(buf_chartab);
return r;
}
return false;
@@ -1507,8 +1507,8 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
regmmatch_T regmatch;
lpos_T pos;
reg_extmatch_T *cur_extmatch = NULL;
- char_u buf_chartab[32]; // chartab array for syn iskeyword
- char_u *line; // current line. NOTE: becomes invalid after
+ char buf_chartab[32]; // chartab array for syn iskeyword
+ char *line; // current line. NOTE: becomes invalid after
// looking for a pattern match!
// variables for zero-width matches that have a "nextgroup" argument
@@ -1518,7 +1518,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
// No character, no attributes! Past end of line?
// Do try matching with an empty line (could be the start of a region).
- line = (char_u *)syn_getcurline();
+ line = syn_getcurline();
if (line[current_col] == NUL && current_col != 0) {
// If we found a match after the last column, use it.
if (next_match_idx >= 0 && next_match_col >= (int)current_col
@@ -1555,7 +1555,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
ga_init(&zero_width_next_ga, (int)sizeof(int), 10);
// use syntax iskeyword option
- save_chartab((char *)buf_chartab);
+ save_chartab(buf_chartab);
// Repeat matching keywords and patterns, to find contained items at the
// same column. This stops when there are no extra matches at the current
@@ -1581,14 +1581,14 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
// 2. Check for keywords, if on a keyword char after a non-keyword
// char. Don't do this when syncing.
if (do_keywords) {
- line = (char_u *)syn_getcurline();
- const char_u *cur_pos = line + current_col;
- if (vim_iswordp_buf((char *)cur_pos, syn_buf)
+ line = syn_getcurline();
+ const char *cur_pos = line + current_col;
+ if (vim_iswordp_buf(cur_pos, syn_buf)
&& (current_col == 0
- || !vim_iswordp_buf((char *)cur_pos - 1 -
- utf_head_off((char *)line, (char *)cur_pos - 1),
+ || !vim_iswordp_buf(cur_pos - 1 -
+ utf_head_off(line, cur_pos - 1),
syn_buf))) {
- syn_id = check_keyword_id((char *)line, (int)current_col, &endcol, &flags,
+ syn_id = check_keyword_id(line, (int)current_col, &endcol, &flags,
&next_list, cur_si, &cchar);
if (syn_id != 0) {
push_current_state(KEYWORD_IDX);
@@ -1827,7 +1827,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
// - this is an empty line and the "skipempty" option was given
// - we are on white space and the "skipwhite" option was given
if (!found_match) {
- line = (char_u *)syn_getcurline();
+ line = syn_getcurline();
if (((current_next_flags & HL_SKIPWHITE)
&& ascii_iswhite(line[current_col]))
|| ((current_next_flags & HL_SKIPEMPTY)
@@ -1850,7 +1850,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
}
} while (found_match);
- restore_chartab((char *)buf_chartab);
+ restore_chartab(buf_chartab);
// Use attributes from the current state, if within its highlighting.
// If not, use attributes from the current-but-one state, etc.
@@ -1944,7 +1944,7 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
// nextgroup ends at end of line, unless "skipnl" or "skipempty" present
if (current_next_list != NULL
- && (line = (char_u *)syn_getcurline())[current_col] != NUL
+ && (line = syn_getcurline())[current_col] != NUL
&& line[current_col + 1] == NUL
&& !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))) {
current_next_list = NULL;
@@ -2362,7 +2362,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_
lpos_T pos;
char *line;
bool had_match = false;
- char_u buf_chartab[32]; // chartab array for syn option iskeyword
+ char buf_chartab[32]; // chartab array for syn option iskeyword
// just in case we are invoked for a keyword
if (idx < 0) {
@@ -2404,7 +2404,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_
best_regmatch.startpos[0].col = 0; // avoid compiler warning
// use syntax iskeyword option
- save_chartab((char *)buf_chartab);
+ save_chartab(buf_chartab);
for (;;) {
// Find end pattern that matches first after "matchcol".
@@ -2545,7 +2545,7 @@ static void find_endpos(int idx, lpos_T *startpos, lpos_T *m_endpos, lpos_T *hl_
m_endpos->lnum = 0;
}
- restore_chartab((char *)buf_chartab);
+ restore_chartab(buf_chartab);
// Remove external matches.
unref_extmatch(re_extmatch_in);
@@ -2584,8 +2584,8 @@ static void syn_add_end_off(lpos_T *result, regmmatch_T *regmatch, synpat_T *spp
{
int col;
int off;
- char_u *base;
- char_u *p;
+ char *base;
+ char *p;
if (spp->sp_off_flags & (1 << idx)) {
result->lnum = regmatch->startpos[0].lnum;
@@ -2601,7 +2601,7 @@ static void syn_add_end_off(lpos_T *result, regmmatch_T *regmatch, synpat_T *spp
if (result->lnum > syn_buf->b_ml.ml_line_count) {
col = 0;
} else if (off != 0) {
- base = (char_u *)ml_get_buf(syn_buf, result->lnum, false);
+ base = ml_get_buf(syn_buf, result->lnum, false);
p = base + col;
if (off > 0) {
while (off-- > 0 && *p != NUL) {
@@ -2628,8 +2628,8 @@ static void syn_add_start_off(lpos_T *result, regmmatch_T *regmatch, synpat_T *s
{
int col;
int off;
- char_u *base;
- char_u *p;
+ char *base;
+ char *p;
if (spp->sp_off_flags & (1 << (idx + SPO_COUNT))) {
result->lnum = regmatch->endpos[0].lnum;
@@ -2646,7 +2646,7 @@ static void syn_add_start_off(lpos_T *result, regmmatch_T *regmatch, synpat_T *s
col = (int)strlen(ml_get_buf(syn_buf, result->lnum, false));
}
if (off != 0) {
- base = (char_u *)ml_get_buf(syn_buf, result->lnum, false);
+ base = ml_get_buf(syn_buf, result->lnum, false);
p = base + col;
if (off > 0) {
while (off-- && *p != NUL) {
@@ -2795,15 +2795,15 @@ static keyentry_T *match_keyword(char *keyword, hashtab_T *ht, stateitem_T *cur_
// Handle ":syntax conceal" command.
static void syn_cmd_conceal(exarg_T *eap, int syncing)
{
- char_u *arg = (char_u *)eap->arg;
- char_u *next;
+ char *arg = eap->arg;
+ char *next;
- eap->nextcmd = find_nextcmd((char *)arg);
+ eap->nextcmd = find_nextcmd(arg);
if (eap->skip) {
return;
}
- next = (char_u *)skiptowhite((char *)arg);
+ next = skiptowhite(arg);
if (*arg == NUL) {
if (curwin->w_s->b_syn_conceal) {
msg("syntax conceal on");
@@ -2849,10 +2849,10 @@ static void syn_cmd_case(exarg_T *eap, int syncing)
/// Handle ":syntax foldlevel" command.
static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
{
- char_u *arg = (char_u *)eap->arg;
- char_u *arg_end;
+ char *arg = eap->arg;
+ char *arg_end;
- eap->nextcmd = find_nextcmd((char *)arg);
+ eap->nextcmd = find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -2869,7 +2869,7 @@ static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
return;
}
- arg_end = (char_u *)skiptowhite((char *)arg);
+ arg_end = skiptowhite(arg);
if (STRNICMP(arg, "start", 5) == 0 && arg_end - arg == 5) {
curwin->w_s->b_syn_foldlevel = SYNFLD_START;
} else if (STRNICMP(arg, "minimum", 7) == 0 && arg_end - arg == 7) {
@@ -2879,7 +2879,7 @@ static void syn_cmd_foldlevel(exarg_T *eap, int syncing)
return;
}
- arg = (char_u *)skipwhite((char *)arg_end);
+ arg = skipwhite(arg_end);
if (*arg != NUL) {
semsg(_(e_illegal_arg), arg);
}
@@ -3216,10 +3216,10 @@ void syn_maybe_enable(void)
/// @param syncing when true: list syncing items
static void syn_cmd_list(exarg_T *eap, int syncing)
{
- char_u *arg = (char_u *)eap->arg;
- char_u *arg_end;
+ char *arg = eap->arg;
+ char *arg_end;
- eap->nextcmd = find_nextcmd((char *)arg);
+ eap->nextcmd = find_nextcmd(arg);
if (eap->skip) {
return;
}
@@ -3272,26 +3272,26 @@ static void syn_cmd_list(exarg_T *eap, int syncing)
} else {
// List the group IDs and syntax clusters that are in the argument.
while (!ends_excmd(*arg) && !got_int) {
- arg_end = (char_u *)skiptowhite((char *)arg);
+ arg_end = skiptowhite(arg);
if (*arg == '@') {
- int id = syn_scl_namen2id((char *)arg + 1, (int)(arg_end - arg - 1));
+ int id = syn_scl_namen2id(arg + 1, (int)(arg_end - arg - 1));
if (id == 0) {
semsg(_("E392: No such syntax cluster: %s"), arg);
} else {
syn_list_cluster(id - SYNID_CLUSTER);
}
} else {
- int id = syn_name2id_len((char *)arg, (size_t)(arg_end - arg));
+ int id = syn_name2id_len(arg, (size_t)(arg_end - arg));
if (id == 0) {
semsg(_(e_nogroup), arg);
} else {
syn_list_one(id, syncing, true);
}
}
- arg = (char_u *)skipwhite((char *)arg_end);
+ arg = skipwhite(arg_end);
}
}
- eap->nextcmd = check_nextcmd((char *)arg);
+ eap->nextcmd = check_nextcmd(arg);
}
static void syn_lines_msg(void)
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 42de9e1152..825bd523bc 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -64,18 +64,18 @@
typedef struct tag_pointers {
// filled in by parse_tag_line():
char *tagname; // start of tag name (skip "file:")
- char_u *tagname_end; // char after tag name
- char_u *fname; // first char of file name
- char_u *fname_end; // char after file name
+ char *tagname_end; // char after tag name
+ char *fname; // first char of file name
+ char *fname_end; // char after file name
char *command; // first char of command
// filled in by parse_match():
- char_u *command_end; // first char after command
+ char *command_end; // first char after command
char *tag_fname; // file name of the tags file. This is used
// when 'tr' is set.
- char_u *tagkind; // "kind:" value
- char_u *tagkind_end; // end of tagkind
+ char *tagkind; // "kind:" value
+ char *tagkind_end; // end of tagkind
char *user_data; // user_data string
- char_u *user_data_end; // end of user_data
+ char *user_data_end; // end of user_data
linenr_T tagline; // "line:" value
} tagptrs_T;
@@ -188,12 +188,10 @@ typedef struct {
# include "tag.c.generated.h"
#endif
-static char_u *bottommsg = (char_u *)N_("E555: at bottom of tag stack");
-static char_u *topmsg = (char_u *)N_("E556: at top of tag stack");
-static char_u *recurmsg
- = (char_u *)N_("E986: cannot modify the tag stack within tagfunc");
-static char_u *tfu_inv_ret_msg
- = (char_u *)N_("E987: invalid return value from tagfunc");
+static char *bottommsg = N_("E555: at bottom of tag stack");
+static char *topmsg = N_("E556: at top of tag stack");
+static char *recurmsg = N_("E986: cannot modify the tag stack within tagfunc");
+static char *tfu_inv_ret_msg = N_("E987: invalid return value from tagfunc");
static char e_window_unexpectedly_close_while_searching_for_tags[]
= N_("E1299: Window unexpectedly closed while searching for tags");
@@ -294,7 +292,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
char **new_matches;
int use_tagstack;
int skip_msg = false;
- char_u *buf_ffname = (char_u *)curbuf->b_ffname; // name for priority computation
+ char *buf_ffname = curbuf->b_ffname; // name for priority computation
int use_tfu = 1;
char *tofree = NULL;
@@ -537,7 +535,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
buf_T *buf = buflist_findnr(cur_fnum);
if (buf != NULL) {
- buf_ffname = (char_u *)buf->b_ffname;
+ buf_ffname = buf->b_ffname;
}
}
@@ -592,7 +590,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
}
if (find_tags(name, &new_num_matches, &new_matches, flags,
- max_num_matches, (char *)buf_ffname) == OK
+ max_num_matches, buf_ffname) == OK
&& new_num_matches < max_num_matches) {
max_num_matches = MAXCOL; // If less than max_num_matches
// found: all matches found.
@@ -622,11 +620,11 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
for (i = idx; i < new_num_matches; i++) {
parse_match(new_matches[i], &tagp2);
if (strcmp(tagp.tagname, tagp2.tagname) == 0) {
- char_u *p = (char_u *)new_matches[i];
+ char *p = new_matches[i];
for (k = i; k > idx; k--) {
new_matches[k] = new_matches[k - 1];
}
- new_matches[idx++] = (char *)p;
+ new_matches[idx++] = p;
break;
}
}
@@ -653,7 +651,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
print_tag_list(new_tag, use_tagstack, num_matches, matches);
ask_for_selection = true;
} else if (type == DT_LTAG) {
- if (add_llist_tags((char_u *)tag, num_matches, matches) == FAIL) {
+ if (add_llist_tags(tag, num_matches, matches) == FAIL) {
goto end_do_tag;
}
@@ -700,7 +698,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
&& tagp2.user_data) {
XFREE_CLEAR(tagstack[tagstackidx].user_data);
tagstack[tagstackidx].user_data =
- xstrnsave(tagp2.user_data, (size_t)(tagp2.user_data_end - (char_u *)tagp2.user_data));
+ xstrnsave(tagp2.user_data, (size_t)(tagp2.user_data_end - tagp2.user_data));
}
tagstackidx++;
@@ -801,7 +799,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
int tagstackidx = curwin->w_tagstackidx;
int i;
char *p;
- char_u *command_end;
+ char *command_end;
tagptrs_T tagp;
int taglen;
int attr;
@@ -809,7 +807,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
// Assume that the first match indicates how long the tags can
// be, and align the file names to that.
parse_match(matches[0], &tagp);
- taglen = (int)(tagp.tagname_end - (char_u *)tagp.tagname + 2);
+ taglen = (int)(tagp.tagname_end - tagp.tagname + 2);
if (taglen < 18) {
taglen = 18;
}
@@ -841,19 +839,19 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
mt_names[matches[i][0] & MT_MASK]);
msg_puts(IObuff);
if (tagp.tagkind != NULL) {
- msg_outtrans_len((char *)tagp.tagkind,
+ msg_outtrans_len(tagp.tagkind,
(int)(tagp.tagkind_end - tagp.tagkind));
}
msg_advance(13);
msg_outtrans_len_attr(tagp.tagname,
- (int)(tagp.tagname_end - (char_u *)tagp.tagname),
+ (int)(tagp.tagname_end - tagp.tagname),
HL_ATTR(HLF_T));
msg_putchar(' ');
taglen_advance(taglen);
// Find out the actual file name. If it is long, truncate
// it and put "..." in the middle
- p = (char *)tag_full_fname(&tagp);
+ p = tag_full_fname(&tagp);
if (p != NULL) {
msg_outtrans_attr(p, HL_ATTR(HLF_D));
XFREE_CLEAR(p);
@@ -869,7 +867,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
// print any extra fields
command_end = tagp.command_end;
if (command_end != NULL) {
- p = (char *)command_end + 3;
+ p = command_end + 3;
while (*p && *p != '\r' && *p != '\n') {
while (*p == TAB) {
p++;
@@ -881,10 +879,10 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
continue;
}
// skip "kind:<kind>" and "<kind>"
- if (p == (char *)tagp.tagkind
- || (p + 5 == (char *)tagp.tagkind
+ if (p == tagp.tagkind
+ || (p + 5 == tagp.tagkind
&& strncmp(p, "kind:", 5) == 0)) {
- p = (char *)tagp.tagkind_end;
+ p = tagp.tagkind_end;
continue;
}
// print all other extra fields
@@ -918,7 +916,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
for (p = tagp.command;
*p && *p != '\r' && *p != '\n';
p++) {}
- command_end = (char_u *)p;
+ command_end = p;
}
// Put the info (in several lines) at column 15.
@@ -931,11 +929,11 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
}
}
// Remove leading whitespace from pattern
- while (p != (char *)command_end && ascii_isspace(*p)) {
+ while (p != command_end && ascii_isspace(*p)) {
p++;
}
- while (p != (char *)command_end) {
+ while (p != command_end) {
if (msg_col + (*p == TAB ? 1 : ptr2cells(p)) > Columns) {
msg_putchar('\n');
}
@@ -959,12 +957,12 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
}
// don't display the "$/;\"" and "$?;\""
- if (p == (char *)command_end - 2 && *p == '$'
+ if (p == command_end - 2 && *p == '$'
&& *(p + 1) == *tagp.command) {
break;
}
// don't display matching '/' or '?'
- if (p == (char *)command_end - 1 && *p == *tagp.command
+ if (p == command_end - 1 && *p == *tagp.command
&& (*p == '/' || *p == '?')) {
break;
}
@@ -981,7 +979,7 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
/// Add the matching tags to the location list for the current
/// window.
-static int add_llist_tags(char_u *tag, int num_matches, char **matches)
+static int add_llist_tags(char *tag, int num_matches, char **matches)
{
list_T *list;
char tag_name[128 + 1];
@@ -1003,7 +1001,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char **matches)
parse_match(matches[i], &tagp);
// Save the tag name
- len = (int)(tagp.tagname_end - (char_u *)tagp.tagname);
+ len = (int)(tagp.tagname_end - tagp.tagname);
if (len > 128) {
len = 128;
}
@@ -1011,7 +1009,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char **matches)
tag_name[len] = NUL;
// Save the tag file name
- p = (char *)tag_full_fname(&tagp);
+ p = tag_full_fname(&tagp);
if (p == NULL) {
continue;
}
@@ -1025,17 +1023,17 @@ static int add_llist_tags(char_u *tag, int num_matches, char **matches)
// Line number is used to locate the tag
lnum = atol(tagp.command);
} else {
- char_u *cmd_start, *cmd_end;
+ char *cmd_start, *cmd_end;
// Search pattern is used to locate the tag
// Locate the end of the command
- cmd_start = (char_u *)tagp.command;
+ cmd_start = tagp.command;
cmd_end = tagp.command_end;
if (cmd_end == NULL) {
for (p = tagp.command;
*p && *p != '\r' && *p != '\n'; p++) {}
- cmd_end = (char_u *)p;
+ cmd_end = p;
}
// Now, cmd_end points to the character after the
@@ -1129,7 +1127,7 @@ static void taglen_advance(int l)
void do_tags(exarg_T *eap)
{
int i;
- char_u *name;
+ char *name;
taggy_T *tagstack = curwin->w_tagstack;
int tagstackidx = curwin->w_tagstackidx;
int tagstacklen = curwin->w_tagstacklen;
@@ -1151,7 +1149,7 @@ void do_tags(exarg_T *eap)
tagstack[i].tagname,
tagstack[i].fmark.mark.lnum);
msg_outtrans(IObuff);
- msg_outtrans_attr((char *)name, tagstack[i].fmark.fnum == curbuf->b_fnum
+ msg_outtrans_attr(name, tagstack[i].fmark.fnum == curbuf->b_fnum
? HL_ATTR(HLF_D) : 0);
xfree(name);
}
@@ -1229,8 +1227,7 @@ static void prepare_pats(pat_T *pats, int has_re)
/// @param match_count here the number of tags found will be placed
/// @param flags flags from find_tags (TAG_*)
/// @param buf_ffname name of buffer for priority
-static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int flags,
- char_u *buf_ffname)
+static int find_tagfunc_tags(char *pat, garray_T *ga, int *match_count, int flags, char *buf_ffname)
{
pos_T save_pos;
list_T *taglist;
@@ -1238,7 +1235,7 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
int result = FAIL;
typval_T args[4];
typval_T rettv;
- char_u flagString[4];
+ char flagString[4];
taggy_T *tag = NULL;
if (curwin->w_tagstacklen > 0) {
@@ -1254,9 +1251,9 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
}
args[0].v_type = VAR_STRING;
- args[0].vval.v_string = (char *)pat;
+ args[0].vval.v_string = pat;
args[1].v_type = VAR_STRING;
- args[1].vval.v_string = (char *)flagString;
+ args[1].vval.v_string = flagString;
// create 'info' dict argument
dict_T *const d = tv_dict_alloc_lock(VAR_FIXED);
@@ -1273,7 +1270,7 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
args[3].v_type = VAR_UNKNOWN;
- vim_snprintf((char *)flagString, sizeof(flagString),
+ vim_snprintf(flagString, sizeof(flagString),
"%s%s%s",
g_tag_at_cursor ? "c": "",
flags & TAG_INS_COMP ? "i": "",
@@ -1300,9 +1297,9 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
TV_LIST_ITER_CONST(taglist, li, {
char *res_name;
- char_u *res_fname;
- char_u *res_cmd;
- char_u *res_kind;
+ char *res_fname;
+ char *res_cmd;
+ char *res_kind;
int has_extra = 0;
int name_only = flags & TAG_NAMES;
@@ -1331,16 +1328,16 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
continue;
}
if (!strcmp(dict_key, "filename")) {
- res_fname = (char_u *)tv->vval.v_string;
+ res_fname = tv->vval.v_string;
continue;
}
if (!strcmp(dict_key, "cmd")) {
- res_cmd = (char_u *)tv->vval.v_string;
+ res_cmd = tv->vval.v_string;
continue;
}
has_extra = 1;
if (!strcmp(dict_key, "kind")) {
- res_kind = (char_u *)tv->vval.v_string;
+ res_kind = tv->vval.v_string;
continue;
}
// Other elements will be stored as "\tKEY:VALUE"
@@ -1543,8 +1540,8 @@ static int findtags_apply_tfu(findtags_state_T *st, char *pat, char *buf_ffname)
}
tfu_in_use = true;
- int retval = find_tagfunc_tags((char_u *)pat, st->ga_match, &st->match_count,
- st->flags, (char_u *)buf_ffname);
+ int retval = find_tagfunc_tags(pat, st->ga_match, &st->match_count,
+ st->flags, buf_ffname);
tfu_in_use = false;
return retval;
@@ -1748,7 +1745,7 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta
if (st->orgpat->headlen) {
CLEAR_FIELD(*tagpp);
tagpp->tagname = st->lbuf;
- tagpp->tagname_end = (char_u *)vim_strchr(st->lbuf, TAB);
+ tagpp->tagname_end = vim_strchr(st->lbuf, TAB);
if (tagpp->tagname_end == NULL) {
// Corrupted tag line.
return TAG_MATCH_FAIL;
@@ -1756,7 +1753,7 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta
// Skip this line if the length of the tag is different and
// there is no regexp, or the tag is too short.
- cmplen = (int)(tagpp->tagname_end - (char_u *)tagpp->tagname);
+ cmplen = (int)(tagpp->tagname_end - tagpp->tagname);
if (p_tl != 0 && cmplen > p_tl) { // adjust for 'taglength'
cmplen = (int)p_tl;
}
@@ -1854,15 +1851,15 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta
// Can be a matching tag, isolate the file name and command.
tagpp->fname = tagpp->tagname_end + 1;
- tagpp->fname_end = (char_u *)vim_strchr((char *)tagpp->fname, TAB);
+ tagpp->fname_end = vim_strchr(tagpp->fname, TAB);
if (tagpp->fname_end == NULL) {
status = FAIL;
} else {
- tagpp->command = (char *)tagpp->fname_end + 1;
+ tagpp->command = tagpp->fname_end + 1;
status = OK;
}
} else {
- status = parse_tag_line((char_u *)st->lbuf, tagpp);
+ status = parse_tag_line(st->lbuf, tagpp);
}
if (status == FAIL) {
@@ -1893,7 +1890,7 @@ static bool findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp, findtags_
// First try matching with the pattern literally (also when it is
// a regexp).
- int cmplen = (int)(tagpp->tagname_end - (char_u *)tagpp->tagname);
+ int cmplen = (int)(tagpp->tagname_end - tagpp->tagname);
if (p_tl != 0 && cmplen > p_tl) { // adjust for 'taglength'
cmplen = (int)p_tl;
}
@@ -1915,7 +1912,7 @@ static bool findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp, findtags_
// Has a regexp: Also find tags matching regexp.
margs->match_re = false;
if (!match && st->orgpat->regmatch.regprog != NULL) {
- int cc = *tagpp->tagname_end;
+ char cc = *tagpp->tagname_end;
*tagpp->tagname_end = NUL;
match = vim_regexec(&st->orgpat->regmatch, tagpp->tagname, (colnr_T)0);
if (match) {
@@ -1927,7 +1924,7 @@ static bool findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp, findtags_
st->orgpat->regmatch.rm_ic = true;
}
}
- *tagpp->tagname_end = (char_u)cc;
+ *tagpp->tagname_end = cc;
margs->match_re = true;
}
@@ -1968,10 +1965,10 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_
bool is_static; // current tag line is static
char *mfp;
char *p;
- char_u *s;
+ char *s;
// Decide in which array to store this match.
- is_current = test_for_current((char *)tagpp->fname, (char *)tagpp->fname_end,
+ is_current = test_for_current(tagpp->fname, tagpp->fname_end,
st->tag_fname, buf_ffname);
is_static = test_for_static(tagpp);
@@ -2006,7 +2003,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_
// detecting duplicates.
// The format is {tagname}@{lang}NUL{heuristic}NUL
*tagpp->tagname_end = NUL;
- len = (size_t)(tagpp->tagname_end - (char_u *)tagpp->tagname);
+ len = (size_t)(tagpp->tagname_end - tagpp->tagname);
mfp = xmalloc(sizeof(char) + len + 10 + ML_EXTRA + 1);
p = mfp;
@@ -2040,7 +2037,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_
}
st->get_searchpat = false;
} else {
- len = (size_t)((char *)tagpp->tagname_end - tagpp->tagname);
+ len = (size_t)(tagpp->tagname_end - tagpp->tagname);
mfp = xmalloc(sizeof(char) + len + 1);
xstrlcpy(mfp, tagpp->tagname, len + 1);
@@ -2069,7 +2066,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_
slash_adjust(p + 1);
#endif
p[tag_fname_len + 1] = TAG_SEP;
- s = (char_u *)p + 1 + tag_fname_len + 1;
+ s = p + 1 + tag_fname_len + 1;
STRCPY(s, st->lbuf);
}
@@ -2583,7 +2580,7 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
tnp->tn_did_filefind_init = false;
} else {
- char_u *filename = NULL;
+ char *filename = NULL;
// Stop when used all parts of 'tags'.
if (*tnp->tn_np == NUL) {
@@ -2599,11 +2596,11 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
r_ptr = (char *)vim_findfile_stopdir((char_u *)buf);
// move the filename one char forward and truncate the
// filepath with a NUL
- filename = (char_u *)path_tail(buf);
- STRMOVE(filename + 1, (char *)filename);
+ filename = path_tail(buf);
+ STRMOVE(filename + 1, filename);
*filename++ = NUL;
- tnp->tn_search_ctx = vim_findfile_init(buf, (char *)filename,
+ tnp->tn_search_ctx = vim_findfile_init(buf, filename,
r_ptr, 100,
false, // don't free visited list
FINDFILE_FILE, // we search for a file
@@ -2636,13 +2633,13 @@ void tagname_free(tagname_T *tnp)
/// @param lbuf line to be parsed
///
/// @return FAIL if there is a format error in this line, OK otherwise.
-static int parse_tag_line(char_u *lbuf, tagptrs_T *tagp)
+static int parse_tag_line(char *lbuf, tagptrs_T *tagp)
{
- char_u *p;
+ char *p;
// Isolate the tagname, from lbuf up to the first white
- tagp->tagname = (char *)lbuf;
- p = (char_u *)vim_strchr((char *)lbuf, TAB);
+ tagp->tagname = lbuf;
+ p = vim_strchr(lbuf, TAB);
if (p == NULL) {
return FAIL;
}
@@ -2653,7 +2650,7 @@ static int parse_tag_line(char_u *lbuf, tagptrs_T *tagp)
p++;
}
tagp->fname = p;
- p = (char_u *)vim_strchr((char *)p, TAB);
+ p = vim_strchr(p, TAB);
if (p == NULL) {
return FAIL;
}
@@ -2666,7 +2663,7 @@ static int parse_tag_line(char_u *lbuf, tagptrs_T *tagp)
if (*p == NUL) {
return FAIL;
}
- tagp->command = (char *)p;
+ tagp->command = p;
return OK;
}
@@ -2730,7 +2727,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
lbuf += strlen(tagp->tag_fname) + 2;
// Find search pattern and the file name for non-etags.
- retval = parse_tag_line((char_u *)lbuf, tagp);
+ retval = parse_tag_line(lbuf, tagp);
tagp->tagkind = NULL;
tagp->user_data = NULL;
@@ -2741,9 +2738,9 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
// Try to find a kind field: "kind:<kind>" or just "<kind>"
p = tagp->command;
if (find_extra(&p) == OK) {
- tagp->command_end = (char_u *)p;
+ tagp->command_end = p;
if (p > tagp->command && p[-1] == '|') {
- tagp->command_end = (char_u *)p - 1; // drop trailing bar
+ tagp->command_end = p - 1; // drop trailing bar
}
p += 2; // skip ";\""
if (*p++ == TAB) {
@@ -2751,7 +2748,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
// character.
while (ASCII_ISALPHA(*p) || utfc_ptr2len(p) > 1) {
if (strncmp(p, "kind:", 5) == 0) {
- tagp->tagkind = (char_u *)p + 5;
+ tagp->tagkind = p + 5;
} else if (strncmp(p, "user_data:", 10) == 0) {
tagp->user_data = p + 10;
} else if (strncmp(p, "line:", 5) == 0) {
@@ -2764,7 +2761,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
pc = vim_strchr(p, ':');
pt = vim_strchr(p, '\t');
if (pc == NULL || (pt != NULL && pc > pt)) {
- tagp->tagkind = (char_u *)p;
+ tagp->tagkind = p;
}
if (pt == NULL) {
break;
@@ -2775,16 +2772,16 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
}
}
if (tagp->tagkind != NULL) {
- for (p = (char *)tagp->tagkind;
+ for (p = tagp->tagkind;
*p && *p != '\t' && *p != '\r' && *p != '\n';
MB_PTR_ADV(p)) {}
- tagp->tagkind_end = (char_u *)p;
+ tagp->tagkind_end = p;
}
if (tagp->user_data != NULL) {
for (p = tagp->user_data;
*p && *p != '\t' && *p != '\r' && *p != '\n';
MB_PTR_ADV(p)) {}
- tagp->user_data_end = (char_u *)p;
+ tagp->user_data_end = p;
}
}
return retval;
@@ -2793,13 +2790,12 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
// Find out the actual file name of a tag. Concatenate the tags file name
// with the matching tag file name.
// Returns an allocated string.
-static char_u *tag_full_fname(tagptrs_T *tagp)
+static char *tag_full_fname(tagptrs_T *tagp)
{
- int c = *tagp->fname_end;
+ char c = *tagp->fname_end;
*tagp->fname_end = NUL;
- char_u *fullname =
- (char_u *)expand_tag_fname((char *)tagp->fname, tagp->tag_fname, false);
- *tagp->fname_end = (char_u)c;
+ char *fullname = expand_tag_fname(tagp->fname, tagp->tag_fname, false);
+ *tagp->fname_end = c;
return fullname;
}
@@ -2843,7 +2839,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
// truncate the file name, so it can be used as a string
*tagp.fname_end = NUL;
- fname = (char *)tagp.fname;
+ fname = tagp.fname;
// copy the command to pbuf[], remove trailing CR/NL
str = tagp.command;
@@ -2999,7 +2995,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
retval = OK;
} else {
int found = 1;
- int cc;
+ char cc;
// try again, ignore case now
p_ic = true;
@@ -3019,7 +3015,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
found = 0;
}
}
- *tagp.tagname_end = (char_u)cc;
+ *tagp.tagname_end = cc;
}
if (found == 0) {
emsg(_("E434: Can't find tag pattern"));
@@ -3159,18 +3155,18 @@ static char *expand_tag_fname(char *fname, char *const tag_fname, const bool exp
/// file.
static int test_for_current(char *fname, char *fname_end, char *tag_fname, char *buf_ffname)
{
- int c;
+ char c;
int retval = false;
if (buf_ffname != NULL) { // if the buffer has a name
{
- c = (unsigned char)(*fname_end);
+ c = *fname_end;
*fname_end = NUL;
}
char *fullname = expand_tag_fname(fname, tag_fname, true);
retval = (path_full_compare(fullname, buf_ffname, true, true) & kEqualFiles);
xfree(fullname);
- *fname_end = (char)c;
+ *fname_end = c;
}
return retval;
@@ -3231,7 +3227,7 @@ int expand_tags(int tagnames, char *pat, int *num_file, char ***file)
{
int i;
int extra_flag;
- char_u *name_buf;
+ char *name_buf;
size_t name_buf_size = 100;
tagptrs_T t_p;
int ret;
@@ -3259,9 +3255,9 @@ int expand_tags(int tagnames, char *pat, int *num_file, char ***file)
size_t len;
parse_match((*file)[i], &t_p);
- len = (size_t)(t_p.tagname_end - (char_u *)t_p.tagname);
+ len = (size_t)(t_p.tagname_end - t_p.tagname);
if (len > name_buf_size - 3) {
- char_u *buf;
+ char *buf;
name_buf_size = len + 3;
buf = xrealloc(name_buf, name_buf_size);
@@ -3354,12 +3350,12 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
dict = tv_dict_alloc();
tv_list_append_dict(list, dict);
- full_fname = (char *)tag_full_fname(&tp);
- if (add_tag_field(dict, "name", tp.tagname, (char *)tp.tagname_end) == FAIL
+ full_fname = tag_full_fname(&tp);
+ if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL
|| add_tag_field(dict, "filename", full_fname, NULL) == FAIL
- || add_tag_field(dict, "cmd", tp.command, (char *)tp.command_end) == FAIL
- || add_tag_field(dict, "kind", (char *)tp.tagkind,
- tp.tagkind ? (char *)tp.tagkind_end : NULL) == FAIL
+ || add_tag_field(dict, "cmd", tp.command, tp.command_end) == FAIL
+ || add_tag_field(dict, "kind", tp.tagkind,
+ tp.tagkind ? tp.tagkind_end : NULL) == FAIL
|| tv_dict_add_nr(dict, S_LEN("static"), is_static) == FAIL) {
ret = FAIL;
}
@@ -3367,13 +3363,13 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
xfree(full_fname);
if (tp.command_end != NULL) {
- for (char *p = (char *)tp.command_end + 3;
+ for (char *p = tp.command_end + 3;
*p != NUL && *p != '\n' && *p != '\r';
MB_PTR_ADV(p)) {
- if (p == (char *)tp.tagkind
- || (p + 5 == (char *)tp.tagkind && strncmp(p, "kind:", 5) == 0)) {
+ if (p == tp.tagkind
+ || (p + 5 == tp.tagkind && strncmp(p, "kind:", 5) == 0)) {
// skip "kind:<kind>" and "<kind>"
- p = (char *)tp.tagkind_end - 1;
+ p = tp.tagkind_end - 1;
} else if (strncmp(p, "file:", 5) == 0) {
// skip "file:" (static tag)
p += 4;
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index 0109c048ec..e175bd5b61 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -653,7 +653,7 @@ int parse_compl_arg(const char *value, int vallen, int *complp, uint32_t *argt,
}
static int uc_scan_attr(char *attr, size_t len, uint32_t *argt, long *def, int *flags, int *complp,
- char_u **compl_arg, cmd_addr_T *addr_type_arg)
+ char **compl_arg, cmd_addr_T *addr_type_arg)
FUNC_ATTR_NONNULL_ALL
{
char *p;
@@ -764,7 +764,7 @@ invalid_count:
return FAIL;
}
- if (parse_compl_arg(val, (int)vallen, complp, argt, (char **)compl_arg)
+ if (parse_compl_arg(val, (int)vallen, complp, argt, compl_arg)
== FAIL) {
return FAIL;
}
@@ -941,7 +941,7 @@ void ex_command(exarg_T *eap)
while (*p == '-') {
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, &compl_arg,
&addr_type_arg) == FAIL) {
goto theend;
}