aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
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 /src/nvim
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
Diffstat (limited to 'src/nvim')
-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();<