mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: replace char_u with char 20 (#21714)
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
parent
2f1fd15554
commit
f2141de9e4
@ -126,7 +126,7 @@ static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files,
|
||||
for (i = 0; i < numfiles; i++) {
|
||||
// for ":set path=" we need to escape spaces twice
|
||||
if (xp->xp_backslash == XP_BS_THREE) {
|
||||
p = (char *)vim_strsave_escaped((char_u *)files[i], (char_u *)" ");
|
||||
p = vim_strsave_escaped(files[i], " ");
|
||||
xfree(files[i]);
|
||||
files[i] = p;
|
||||
#if defined(BACKSLASH_IN_FILENAME)
|
||||
@ -161,7 +161,7 @@ static void ExpandEscape(expand_T *xp, char_u *str, int numfiles, char **files,
|
||||
// Insert a backslash before characters in a tag name that
|
||||
// would terminate the ":tag" command.
|
||||
for (i = 0; i < numfiles; i++) {
|
||||
p = (char *)vim_strsave_escaped((char_u *)files[i], (char_u *)"\\|\"");
|
||||
p = vim_strsave_escaped(files[i], "\\|\"");
|
||||
xfree(files[i]);
|
||||
files[i] = p;
|
||||
}
|
||||
@ -2542,7 +2542,7 @@ static void ExpandGeneric(expand_T *xp, regmatch_T *regmatch, int *num_file, cha
|
||||
}
|
||||
if (vim_regexec(regmatch, str, (colnr_T)0)) {
|
||||
if (escaped) {
|
||||
str = (char *)vim_strsave_escaped((char_u *)str, (char_u *)" \t\\.");
|
||||
str = vim_strsave_escaped(str, " \t\\.");
|
||||
} else {
|
||||
str = xstrdup(str);
|
||||
}
|
||||
|
@ -1656,8 +1656,8 @@ static void registerdigraph(int char1, int char2, int n)
|
||||
bool check_digraph_chars_valid(int char1, int char2)
|
||||
{
|
||||
if (char2 == 0) {
|
||||
char_u msg[MB_MAXBYTES + 1];
|
||||
msg[utf_char2bytes(char1, (char *)msg)] = NUL;
|
||||
char msg[MB_MAXBYTES + 1];
|
||||
msg[utf_char2bytes(char1, msg)] = NUL;
|
||||
semsg(_(e_digraph_must_be_just_two_characters_str), msg);
|
||||
return false;
|
||||
}
|
||||
|
@ -616,16 +616,15 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
int c_extra = NUL; // extra chars, all the same
|
||||
int c_final = NUL; // final char, mandatory if set
|
||||
int extra_attr = 0; // attributes when n_extra != 0
|
||||
static char_u *at_end_str = (char_u *)""; // used for p_extra when displaying
|
||||
// curwin->w_p_lcs_chars.eol at
|
||||
// end-of-line
|
||||
static char *at_end_str = ""; // used for p_extra when displaying curwin->w_p_lcs_chars.eol
|
||||
// at end-of-line
|
||||
int lcs_eol_one = wp->w_p_lcs_chars.eol; // 'eol' until it's been used
|
||||
int lcs_prec_todo = wp->w_p_lcs_chars.prec; // 'prec' until it's been used
|
||||
bool has_fold = foldinfo.fi_level != 0 && foldinfo.fi_lines > 0;
|
||||
|
||||
// saved "extra" items for when draw_state becomes WL_LINE (again)
|
||||
int saved_n_extra = 0;
|
||||
char_u *saved_p_extra = NULL;
|
||||
char *saved_p_extra = NULL;
|
||||
int saved_c_extra = 0;
|
||||
int saved_c_final = 0;
|
||||
int saved_char_attr = 0;
|
||||
@ -699,7 +698,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
bool has_decor = false; // this buffer has decoration
|
||||
int win_col_offset = 0; // offset for window columns
|
||||
|
||||
char_u buf_fold[FOLD_TEXT_LEN]; // Hold value returned by get_foldtext
|
||||
char buf_fold[FOLD_TEXT_LEN]; // Hold value returned by get_foldtext
|
||||
|
||||
bool area_active = false;
|
||||
|
||||
@ -1299,10 +1298,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
}
|
||||
if (wp->w_p_rl) { // reverse line numbers
|
||||
// like rl_mirror(), but keep the space at the end
|
||||
char_u *p2 = (char_u *)skipwhite((char *)extra);
|
||||
p2 = (char_u *)skiptowhite((char *)p2) - 1;
|
||||
for (char_u *p1 = (char_u *)skipwhite((char *)extra); p1 < p2; p1++, p2--) {
|
||||
const char_u t = *p1;
|
||||
char *p2 = skipwhite((char *)extra);
|
||||
p2 = skiptowhite(p2) - 1;
|
||||
for (char *p1 = skipwhite((char *)extra); p1 < p2; p1++, p2--) {
|
||||
const char t = *p1;
|
||||
*p1 = *p2;
|
||||
*p2 = t;
|
||||
}
|
||||
@ -1452,7 +1451,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
n_extra = saved_n_extra;
|
||||
c_extra = saved_c_extra;
|
||||
c_final = saved_c_final;
|
||||
p_extra = (char *)saved_p_extra;
|
||||
p_extra = saved_p_extra;
|
||||
char_attr = saved_char_attr;
|
||||
} else {
|
||||
char_attr = 0;
|
||||
@ -1494,10 +1493,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
|
||||
linenr_T lnume = lnum + foldinfo.fi_lines - 1;
|
||||
memset(buf_fold, ' ', FOLD_TEXT_LEN);
|
||||
p_extra = get_foldtext(wp, lnum, lnume, foldinfo, (char *)buf_fold);
|
||||
p_extra = get_foldtext(wp, lnum, lnume, foldinfo, buf_fold);
|
||||
n_extra = (int)strlen(p_extra);
|
||||
|
||||
if (p_extra != (char *)buf_fold) {
|
||||
if (p_extra != buf_fold) {
|
||||
xfree(p_extra_free);
|
||||
p_extra_free = p_extra;
|
||||
}
|
||||
@ -2072,7 +2071,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
if (!wp->w_p_lbr || !wp->w_p_list) {
|
||||
n_extra = tab_len;
|
||||
} else {
|
||||
char_u *p;
|
||||
char *p;
|
||||
int i;
|
||||
int saved_nextra = n_extra;
|
||||
|
||||
@ -2101,7 +2100,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
memset(p, ' ', (size_t)len);
|
||||
p[len] = NUL;
|
||||
xfree(p_extra_free);
|
||||
p_extra_free = (char *)p;
|
||||
p_extra_free = p;
|
||||
for (i = 0; i < tab_len; i++) {
|
||||
if (*p == NUL) {
|
||||
tab_len = i;
|
||||
@ -2113,7 +2112,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
if (wp->w_p_lcs_chars.tab3 && i == tab_len - 1) {
|
||||
lcs = wp->w_p_lcs_chars.tab3;
|
||||
}
|
||||
p += utf_char2bytes(lcs, (char *)p);
|
||||
p += utf_char2bytes(lcs, p);
|
||||
n_extra += utf_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
|
||||
}
|
||||
p_extra = p_extra_free;
|
||||
@ -2187,7 +2186,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
&& tocol != MAXCOL && vcol < tocol) {
|
||||
n_extra = 0;
|
||||
} else {
|
||||
p_extra = (char *)at_end_str;
|
||||
p_extra = at_end_str;
|
||||
n_extra = 1;
|
||||
c_extra = NUL;
|
||||
c_final = NUL;
|
||||
@ -2215,17 +2214,17 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
c_extra = NUL;
|
||||
c_final = NUL;
|
||||
if (wp->w_p_lbr) {
|
||||
char_u *p;
|
||||
char *p;
|
||||
|
||||
c = (uint8_t)(*p_extra);
|
||||
p = xmalloc((size_t)n_extra + 1);
|
||||
memset(p, ' ', (size_t)n_extra);
|
||||
strncpy((char *)p, // NOLINT(runtime/printf)
|
||||
strncpy(p, // NOLINT(runtime/printf)
|
||||
p_extra + 1,
|
||||
(size_t)strlen(p_extra) - 1);
|
||||
p[n_extra] = NUL;
|
||||
xfree(p_extra_free);
|
||||
p_extra_free = p_extra = (char *)p;
|
||||
p_extra_free = p_extra = p;
|
||||
} else {
|
||||
n_extra = byte2cells(c) - 1;
|
||||
c = (uint8_t)(*p_extra++);
|
||||
@ -2740,7 +2739,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
|| *ptr != NUL
|
||||
|| filler_todo > 0
|
||||
|| (wp->w_p_list && wp->w_p_lcs_chars.eol != NUL
|
||||
&& p_extra != (char *)at_end_str)
|
||||
&& p_extra != at_end_str)
|
||||
|| (n_extra != 0
|
||||
&& (c_extra != NUL || *p_extra != NUL)))) {
|
||||
bool wrap = wp->w_p_wrap // Wrapping enabled.
|
||||
@ -2810,7 +2809,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
// reset the drawing state for the start of a wrapped line
|
||||
draw_state = WL_START;
|
||||
saved_n_extra = n_extra;
|
||||
saved_p_extra = (char_u *)p_extra;
|
||||
saved_p_extra = p_extra;
|
||||
saved_c_extra = c_extra;
|
||||
saved_c_final = c_final;
|
||||
saved_char_attr = char_attr;
|
||||
|
@ -2213,7 +2213,7 @@ static int eval_func(char **const arg, char *const name, const int name_len, typ
|
||||
// If "s" is the name of a variable of type VAR_FUNC
|
||||
// use its contents.
|
||||
partial_T *partial;
|
||||
s = (char *)deref_func_name((const char *)s, &len, &partial, !evaluate);
|
||||
s = deref_func_name((const char *)s, &len, &partial, !evaluate);
|
||||
|
||||
// Need to make a copy, in case evaluating the arguments makes
|
||||
// the name invalid.
|
||||
@ -2226,7 +2226,7 @@ static int eval_func(char **const arg, char *const name, const int name_len, typ
|
||||
funcexe.fe_evaluate = evaluate;
|
||||
funcexe.fe_partial = partial;
|
||||
funcexe.fe_basetv = basetv;
|
||||
int ret = get_func_tv((char_u *)s, len, rettv, arg, &funcexe);
|
||||
int ret = get_func_tv(s, len, rettv, arg, &funcexe);
|
||||
|
||||
xfree(s);
|
||||
|
||||
@ -3221,7 +3221,7 @@ static int call_func_rettv(char **const arg, typval_T *const rettv, const bool e
|
||||
funcexe.fe_partial = pt;
|
||||
funcexe.fe_selfdict = selfdict;
|
||||
funcexe.fe_basetv = basetv;
|
||||
const int ret = get_func_tv((char_u *)funcname, is_lua ? (int)(*arg - funcname) : -1, rettv,
|
||||
const int ret = get_func_tv(funcname, is_lua ? (int)(*arg - funcname) : -1, rettv,
|
||||
arg, &funcexe);
|
||||
|
||||
// Clear the funcref afterwards, so that deleting it while
|
||||
@ -5050,7 +5050,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref)
|
||||
if (tv_list_len(list) == 0) {
|
||||
arg_idx = 0;
|
||||
} else if (tv_list_len(list) > MAX_FUNC_ARGS) {
|
||||
emsg_funcname((char *)e_toomanyarg, (char_u *)s);
|
||||
emsg_funcname((char *)e_toomanyarg, s);
|
||||
xfree(name);
|
||||
goto theend;
|
||||
}
|
||||
@ -7675,8 +7675,7 @@ int store_session_globals(FILE *fd)
|
||||
&& var_flavour((char *)this_var->di_key) == VAR_FLAVOUR_SESSION) {
|
||||
// Escape special characters with a backslash. Turn a LF and
|
||||
// CR into \n and \r.
|
||||
char *const p = (char *)vim_strsave_escaped((const char_u *)tv_get_string(&this_var->di_tv),
|
||||
(const char_u *)"\\\"\n\r");
|
||||
char *const p = (char *)vim_strsave_escaped(tv_get_string(&this_var->di_tv), "\\\"\n\r");
|
||||
for (char *t = p; *t != NUL; t++) {
|
||||
if (*t == '\n') {
|
||||
*t = 'n';
|
||||
|
@ -1522,9 +1522,8 @@ static void f_escape(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
char buf[NUMBUFLEN];
|
||||
|
||||
rettv->vval.v_string = (char *)vim_strsave_escaped((const char_u *)tv_get_string(&argvars[0]),
|
||||
(const char_u *)tv_get_string_buf(&argvars[1],
|
||||
buf));
|
||||
rettv->vval.v_string = vim_strsave_escaped(tv_get_string(&argvars[0]),
|
||||
tv_get_string_buf(&argvars[1], buf));
|
||||
rettv->v_type = VAR_STRING;
|
||||
}
|
||||
|
||||
@ -2245,7 +2244,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
const char *const what = tv_get_string(&argvars[1]);
|
||||
|
||||
if (strcmp(what, "func") == 0 || strcmp(what, "name") == 0) {
|
||||
const char *name = (const char *)partial_name(pt);
|
||||
const char *name = partial_name(pt);
|
||||
rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING);
|
||||
assert(name != NULL);
|
||||
if (rettv->v_type == VAR_FUNC) {
|
||||
@ -2253,7 +2252,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
if (*what == 'n' && pt->pt_name == NULL && pt->pt_func != NULL) {
|
||||
// use <SNR> instead of the byte code
|
||||
name = (const char *)printable_func_name(pt->pt_func);
|
||||
name = printable_func_name(pt->pt_func);
|
||||
}
|
||||
rettv->vval.v_string = xstrdup(name);
|
||||
} else if (strcmp(what, "dict") == 0) {
|
||||
|
@ -93,10 +93,10 @@ static int get_function_args(char **argp, char_u endchar, garray_T *newargs, int
|
||||
int i;
|
||||
|
||||
if (newargs != NULL) {
|
||||
ga_init(newargs, (int)sizeof(char_u *), 3);
|
||||
ga_init(newargs, (int)sizeof(char *), 3);
|
||||
}
|
||||
if (default_args != NULL) {
|
||||
ga_init(default_args, (int)sizeof(char_u *), 3);
|
||||
ga_init(default_args, (int)sizeof(char *), 3);
|
||||
}
|
||||
|
||||
if (varargs != NULL) {
|
||||
@ -312,7 +312,7 @@ int get_lambda_tv(char **arg, typval_T *rettv, bool evaluate)
|
||||
fp = xcalloc(1, offsetof(ufunc_T, uf_name) + strlen(name) + 1);
|
||||
pt = xcalloc(1, sizeof(partial_T));
|
||||
|
||||
ga_init(&newlines, (int)sizeof(char_u *), 1);
|
||||
ga_init(&newlines, (int)sizeof(char *), 1);
|
||||
ga_grow(&newlines, 1);
|
||||
|
||||
// Add "return " before the expression.
|
||||
@ -330,7 +330,7 @@ int get_lambda_tv(char **arg, typval_T *rettv, bool evaluate)
|
||||
set_ufunc_name(fp, name);
|
||||
hash_add(&func_hashtab, UF2HIKEY(fp));
|
||||
fp->uf_args = newargs;
|
||||
ga_init(&fp->uf_def_args, (int)sizeof(char_u *), 1);
|
||||
ga_init(&fp->uf_def_args, (int)sizeof(char *), 1);
|
||||
fp->uf_lines = newlines;
|
||||
if (current_funccal != NULL && eval_lavars) {
|
||||
flags |= FC_CLOSURE;
|
||||
@ -383,7 +383,7 @@ errret:
|
||||
/// was not found.
|
||||
///
|
||||
/// @return name of the function.
|
||||
char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp, bool no_autoload)
|
||||
char *deref_func_name(const char *name, int *lenp, partial_T **const partialp, bool no_autoload)
|
||||
FUNC_ATTR_NONNULL_ARG(1, 2)
|
||||
{
|
||||
if (partialp != NULL) {
|
||||
@ -394,10 +394,10 @@ char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp,
|
||||
if (v != NULL && v->di_tv.v_type == VAR_FUNC) {
|
||||
if (v->di_tv.vval.v_string == NULL) { // just in case
|
||||
*lenp = 0;
|
||||
return (char_u *)"";
|
||||
return "";
|
||||
}
|
||||
*lenp = (int)strlen(v->di_tv.vval.v_string);
|
||||
return (char_u *)v->di_tv.vval.v_string;
|
||||
return v->di_tv.vval.v_string;
|
||||
}
|
||||
|
||||
if (v != NULL && v->di_tv.v_type == VAR_PARTIAL) {
|
||||
@ -405,31 +405,31 @@ char_u *deref_func_name(const char *name, int *lenp, partial_T **const partialp,
|
||||
|
||||
if (pt == NULL) { // just in case
|
||||
*lenp = 0;
|
||||
return (char_u *)"";
|
||||
return "";
|
||||
}
|
||||
if (partialp != NULL) {
|
||||
*partialp = pt;
|
||||
}
|
||||
char *s = partial_name(pt);
|
||||
*lenp = (int)strlen(s);
|
||||
return (char_u *)s;
|
||||
return s;
|
||||
}
|
||||
|
||||
return (char_u *)name;
|
||||
return (char *)name;
|
||||
}
|
||||
|
||||
/// Give an error message with a function name. Handle <SNR> things.
|
||||
///
|
||||
/// @param ermsg must be passed without translation (use N_() instead of _()).
|
||||
/// @param name function name
|
||||
void emsg_funcname(char *ermsg, const char_u *name)
|
||||
void emsg_funcname(char *ermsg, const char *name)
|
||||
{
|
||||
char_u *p;
|
||||
char *p;
|
||||
|
||||
if (*name == K_SPECIAL) {
|
||||
p = (char_u *)concat_str("<SNR>", (char *)name + 3);
|
||||
if ((uint8_t)(*name) == K_SPECIAL) {
|
||||
p = concat_str("<SNR>", name + 3);
|
||||
} else {
|
||||
p = (char_u *)name;
|
||||
p = (char *)name;
|
||||
}
|
||||
|
||||
semsg(_(ermsg), p);
|
||||
@ -447,7 +447,7 @@ void emsg_funcname(char *ermsg, const char_u *name)
|
||||
/// @param funcexe various values
|
||||
///
|
||||
/// @return OK or FAIL.
|
||||
int get_func_tv(const char_u *name, int len, typval_T *rettv, char **arg, funcexe_T *funcexe)
|
||||
int get_func_tv(const char *name, int len, typval_T *rettv, char **arg, funcexe_T *funcexe)
|
||||
{
|
||||
char *argp;
|
||||
int ret = OK;
|
||||
@ -491,7 +491,7 @@ int get_func_tv(const char_u *name, int len, typval_T *rettv, char **arg, funcex
|
||||
((typval_T **)funcargs.ga_data)[funcargs.ga_len++] = &argvars[i];
|
||||
}
|
||||
}
|
||||
ret = call_func((char *)name, len, rettv, argcount, argvars, funcexe);
|
||||
ret = call_func(name, len, rettv, argcount, argvars, funcexe);
|
||||
|
||||
funcargs.ga_len -= i;
|
||||
} else if (!aborting()) {
|
||||
@ -593,7 +593,7 @@ ufunc_T *find_func(const char_u *name)
|
||||
/// Copy the function name of "fp" to buffer "buf".
|
||||
/// "buf" must be able to hold the function name plus three bytes.
|
||||
/// Takes care of script-local function names.
|
||||
static void cat_func_name(char_u *buf, ufunc_T *fp)
|
||||
static void cat_func_name(char *buf, ufunc_T *fp)
|
||||
{
|
||||
if ((uint8_t)fp->uf_name[0] == K_SPECIAL) {
|
||||
STRCPY(buf, "<SNR>");
|
||||
@ -1439,28 +1439,25 @@ static void user_func_error(int error, const char_u *name)
|
||||
{
|
||||
switch (error) {
|
||||
case FCERR_UNKNOWN:
|
||||
emsg_funcname(N_("E117: Unknown function: %s"), name);
|
||||
emsg_funcname(N_("E117: Unknown function: %s"), (char *)name);
|
||||
break;
|
||||
case FCERR_NOTMETHOD:
|
||||
emsg_funcname(N_("E276: Cannot use function as a method: %s"), name);
|
||||
emsg_funcname(N_("E276: Cannot use function as a method: %s"), (char *)name);
|
||||
break;
|
||||
case FCERR_DELETED:
|
||||
emsg_funcname(N_("E933: Function was deleted: %s"), name);
|
||||
emsg_funcname(N_("E933: Function was deleted: %s"), (char *)name);
|
||||
break;
|
||||
case FCERR_TOOMANY:
|
||||
emsg_funcname(_(e_toomanyarg), name);
|
||||
emsg_funcname(_(e_toomanyarg), (char *)name);
|
||||
break;
|
||||
case FCERR_TOOFEW:
|
||||
emsg_funcname(N_("E119: Not enough arguments for function: %s"),
|
||||
name);
|
||||
emsg_funcname(N_("E119: Not enough arguments for function: %s"), (char *)name);
|
||||
break;
|
||||
case FCERR_SCRIPT:
|
||||
emsg_funcname(N_("E120: Using <SID> not in a script context: %s"),
|
||||
name);
|
||||
emsg_funcname(N_("E120: Using <SID> not in a script context: %s"), (char *)name);
|
||||
break;
|
||||
case FCERR_DICT:
|
||||
emsg_funcname(N_("E725: Calling dict function without Dictionary: %s"),
|
||||
name);
|
||||
emsg_funcname(N_("E725: Calling dict function without Dictionary: %s"), (char *)name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1652,9 +1649,9 @@ theend:
|
||||
return ret;
|
||||
}
|
||||
|
||||
char_u *printable_func_name(ufunc_T *fp)
|
||||
char *printable_func_name(ufunc_T *fp)
|
||||
{
|
||||
return fp->uf_name_exp != NULL ? fp->uf_name_exp : (char_u *)fp->uf_name;
|
||||
return fp->uf_name_exp != NULL ? (char *)fp->uf_name_exp : fp->uf_name;
|
||||
}
|
||||
|
||||
/// List the head of the function: "name(arg1, arg2)".
|
||||
@ -1730,8 +1727,8 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
char *name = NULL;
|
||||
const char_u *start;
|
||||
const char_u *end;
|
||||
const char *start;
|
||||
const char *end;
|
||||
int lead;
|
||||
int len;
|
||||
lval_T lv;
|
||||
@ -1739,7 +1736,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa
|
||||
if (fdp != NULL) {
|
||||
CLEAR_POINTER(fdp);
|
||||
}
|
||||
start = (char_u *)(*pp);
|
||||
start = *pp;
|
||||
|
||||
// Check for hard coded <SNR>: already translated function ID (from a user
|
||||
// command).
|
||||
@ -1752,14 +1749,14 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa
|
||||
|
||||
// A name starting with "<SID>" or "<SNR>" is local to a script. But
|
||||
// don't skip over "s:", get_lval() needs it for "s:dict.func".
|
||||
lead = eval_fname_script((const char *)start);
|
||||
lead = eval_fname_script(start);
|
||||
if (lead > 2) {
|
||||
start += lead;
|
||||
}
|
||||
|
||||
// Note that TFN_ flags use the same values as GLV_ flags.
|
||||
end = (char_u *)get_lval((char *)start, NULL, &lv, false, skip, flags | GLV_READ_ONLY,
|
||||
lead > 2 ? 0 : FNE_CHECK_START);
|
||||
end = get_lval((char *)start, NULL, &lv, false, skip, flags | GLV_READ_ONLY,
|
||||
lead > 2 ? 0 : FNE_CHECK_START);
|
||||
if (end == start) {
|
||||
if (!skip) {
|
||||
emsg(_("E129: Function name required"));
|
||||
@ -1783,7 +1780,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa
|
||||
if (lv.ll_tv != NULL) {
|
||||
if (fdp != NULL) {
|
||||
fdp->fd_dict = lv.ll_dict;
|
||||
fdp->fd_newkey = (char_u *)lv.ll_newkey;
|
||||
fdp->fd_newkey = lv.ll_newkey;
|
||||
lv.ll_newkey = NULL;
|
||||
fdp->fd_di = lv.ll_di;
|
||||
}
|
||||
@ -1793,7 +1790,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa
|
||||
} else if (lv.ll_tv->v_type == VAR_PARTIAL
|
||||
&& lv.ll_tv->vval.v_partial != NULL) {
|
||||
if (is_luafunc(lv.ll_tv->vval.v_partial) && *end == '.') {
|
||||
len = check_luafunc_name((const char *)end + 1, true);
|
||||
len = check_luafunc_name(end + 1, true);
|
||||
if (len == 0) {
|
||||
semsg(e_invexpr2, "v:lua");
|
||||
goto theend;
|
||||
@ -1830,15 +1827,14 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa
|
||||
// Check if the name is a Funcref. If so, use the value.
|
||||
if (lv.ll_exp_name != NULL) {
|
||||
len = (int)strlen(lv.ll_exp_name);
|
||||
name = (char *)deref_func_name(lv.ll_exp_name, &len, partial,
|
||||
flags & TFN_NO_AUTOLOAD);
|
||||
name = deref_func_name(lv.ll_exp_name, &len, partial,
|
||||
flags & TFN_NO_AUTOLOAD);
|
||||
if ((const char *)name == lv.ll_exp_name) {
|
||||
name = NULL;
|
||||
}
|
||||
} else if (!(flags & TFN_NO_DEREF)) {
|
||||
len = (int)(end - (char_u *)(*pp));
|
||||
name = (char *)deref_func_name((const char *)(*pp), &len, partial,
|
||||
flags & TFN_NO_AUTOLOAD);
|
||||
len = (int)(end - *pp);
|
||||
name = deref_func_name(*pp, &len, partial, flags & TFN_NO_AUTOLOAD);
|
||||
if (name == *pp) {
|
||||
name = NULL;
|
||||
}
|
||||
@ -1873,7 +1869,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa
|
||||
lv.ll_name += 2;
|
||||
lv.ll_name_len -= 2;
|
||||
}
|
||||
len = (int)((const char *)end - lv.ll_name);
|
||||
len = (int)(end - lv.ll_name);
|
||||
}
|
||||
|
||||
size_t sid_buf_len = 0;
|
||||
@ -1904,7 +1900,7 @@ char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, pa
|
||||
}
|
||||
|
||||
if (!skip && !(flags & TFN_QUIET) && !(flags & TFN_NO_DEREF)) {
|
||||
char_u *cp = xmemrchr(lv.ll_name, ':', lv.ll_name_len);
|
||||
char *cp = xmemrchr(lv.ll_name, ':', lv.ll_name_len);
|
||||
|
||||
if (cp != NULL && cp < end) {
|
||||
semsg(_("E884: Function name cannot contain a colon: %s"), start);
|
||||
@ -2162,7 +2158,7 @@ void ex_function(exarg_T *eap)
|
||||
msg_puts(eap->forceit ? "endfunction" : " endfunction");
|
||||
}
|
||||
} else {
|
||||
emsg_funcname(N_("E123: Undefined function: %s"), (char_u *)name);
|
||||
emsg_funcname(N_("E123: Undefined function: %s"), name);
|
||||
}
|
||||
}
|
||||
goto ret_free;
|
||||
@ -2182,8 +2178,8 @@ void ex_function(exarg_T *eap)
|
||||
}
|
||||
p = skipwhite(p + 1);
|
||||
|
||||
ga_init(&newargs, (int)sizeof(char_u *), 3);
|
||||
ga_init(&newlines, (int)sizeof(char_u *), 3);
|
||||
ga_init(&newargs, (int)sizeof(char *), 3);
|
||||
ga_init(&newlines, (int)sizeof(char *), 3);
|
||||
|
||||
if (!eap->skip) {
|
||||
// Check the name of the function. Unless it's a dictionary function
|
||||
@ -2191,7 +2187,7 @@ void ex_function(exarg_T *eap)
|
||||
if (name != NULL) {
|
||||
arg = name;
|
||||
} else {
|
||||
arg = (char *)fudi.fd_newkey;
|
||||
arg = fudi.fd_newkey;
|
||||
}
|
||||
if (arg != NULL && (fudi.fd_di == NULL || !tv_is_func(fudi.fd_di->di_tv))) {
|
||||
int j = ((uint8_t)(*arg) == K_SPECIAL) ? 3 : 0;
|
||||
@ -2199,7 +2195,7 @@ void ex_function(exarg_T *eap)
|
||||
j++;
|
||||
}
|
||||
if (arg[j] != NUL) {
|
||||
emsg_funcname((char *)e_invarg2, (char_u *)arg);
|
||||
emsg_funcname((char *)e_invarg2, arg);
|
||||
}
|
||||
}
|
||||
// Disallow using the g: dict.
|
||||
@ -2235,7 +2231,7 @@ void ex_function(exarg_T *eap)
|
||||
p += 7;
|
||||
if (current_funccal == NULL) {
|
||||
emsg_funcname(N_("E932: Closure function should not be at top level: %s"),
|
||||
name == NULL ? (char_u *)"" : (char_u *)name);
|
||||
name == NULL ? "" : name);
|
||||
goto erret;
|
||||
}
|
||||
} else {
|
||||
@ -2260,7 +2256,7 @@ void ex_function(exarg_T *eap)
|
||||
if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) {
|
||||
emsg(_(e_funcdict));
|
||||
} else if (name != NULL && find_func((char_u *)name) != NULL) {
|
||||
emsg_funcname(e_funcexts, (char_u *)name);
|
||||
emsg_funcname(e_funcexts, name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2509,8 +2505,7 @@ void ex_function(exarg_T *eap)
|
||||
if (fudi.fd_dict == NULL) {
|
||||
v = find_var((const char *)name, strlen(name), &ht, false);
|
||||
if (v != NULL && v->di_tv.v_type == VAR_FUNC) {
|
||||
emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
|
||||
(char_u *)name);
|
||||
emsg_funcname(N_("E707: Function name conflicts with variable: %s"), name);
|
||||
goto erret;
|
||||
}
|
||||
|
||||
@ -2521,12 +2516,11 @@ void ex_function(exarg_T *eap)
|
||||
if (!eap->forceit
|
||||
&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
|
||||
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)) {
|
||||
emsg_funcname(e_funcexts, (char_u *)name);
|
||||
emsg_funcname(e_funcexts, name);
|
||||
goto erret;
|
||||
}
|
||||
if (fp->uf_calls > 0) {
|
||||
emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"),
|
||||
(char_u *)name);
|
||||
emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"), name);
|
||||
goto erret;
|
||||
}
|
||||
if (fp->uf_refcount > 1) {
|
||||
@ -2577,13 +2571,13 @@ void ex_function(exarg_T *eap)
|
||||
if (fp == NULL) {
|
||||
if (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL) {
|
||||
int slen, plen;
|
||||
char_u *scriptname;
|
||||
char *scriptname;
|
||||
|
||||
// Check that the autoload name matches the script name.
|
||||
int j = FAIL;
|
||||
if (SOURCING_NAME != NULL) {
|
||||
scriptname = (char_u *)autoload_name((const char *)name, strlen(name));
|
||||
p = vim_strchr((char *)scriptname, '/');
|
||||
scriptname = autoload_name(name, strlen(name));
|
||||
p = vim_strchr(scriptname, '/');
|
||||
plen = (int)strlen(p);
|
||||
slen = (int)strlen(SOURCING_NAME);
|
||||
if (slen > plen && path_fnamecmp(p, SOURCING_NAME + slen - plen) == 0) {
|
||||
@ -2706,7 +2700,7 @@ bool translated_function_exists(const char *name)
|
||||
/// @return true if it exists, false otherwise.
|
||||
bool function_exists(const char *const name, bool no_deref)
|
||||
{
|
||||
const char_u *nm = (const char_u *)name;
|
||||
const char *nm = name;
|
||||
bool n = false;
|
||||
int flag = TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD;
|
||||
|
||||
@ -2714,7 +2708,7 @@ bool function_exists(const char *const name, bool no_deref)
|
||||
flag |= TFN_NO_DEREF;
|
||||
}
|
||||
char *const p = (char *)trans_function_name((char **)&nm, false, flag, NULL, NULL);
|
||||
nm = (char_u *)skipwhite((char *)nm);
|
||||
nm = skipwhite(nm);
|
||||
|
||||
// Only accept "funcname", "funcname ", "funcname (..." and
|
||||
// "funcname(...", not "funcname!...".
|
||||
@ -2758,7 +2752,7 @@ char *get_user_func_name(expand_T *xp, int idx)
|
||||
return (char *)fp->uf_name; // Prevent overflow.
|
||||
}
|
||||
|
||||
cat_func_name((char_u *)IObuff, fp);
|
||||
cat_func_name(IObuff, fp);
|
||||
if (xp->xp_context != EXPAND_USER_FUNC) {
|
||||
STRCAT(IObuff, "(");
|
||||
if (!fp->uf_varargs && GA_EMPTY(&fp->uf_args)) {
|
||||
@ -2774,12 +2768,12 @@ char *get_user_func_name(expand_T *xp, int idx)
|
||||
void ex_delfunction(exarg_T *eap)
|
||||
{
|
||||
ufunc_T *fp = NULL;
|
||||
char_u *p;
|
||||
char *p;
|
||||
char_u *name;
|
||||
funcdict_T fudi;
|
||||
|
||||
p = (char_u *)eap->arg;
|
||||
name = trans_function_name((char **)&p, eap->skip, 0, &fudi, NULL);
|
||||
p = eap->arg;
|
||||
name = trans_function_name(&p, eap->skip, 0, &fudi, NULL);
|
||||
xfree(fudi.fd_newkey);
|
||||
if (name == NULL) {
|
||||
if (fudi.fd_dict != NULL && !eap->skip) {
|
||||
@ -2787,12 +2781,12 @@ void ex_delfunction(exarg_T *eap)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!ends_excmd(*skipwhite((char *)p))) {
|
||||
if (!ends_excmd(*skipwhite(p))) {
|
||||
xfree(name);
|
||||
semsg(_(e_trailing_arg), p);
|
||||
return;
|
||||
}
|
||||
eap->nextcmd = check_nextcmd((char *)p);
|
||||
eap->nextcmd = check_nextcmd(p);
|
||||
if (eap->nextcmd != NULL) {
|
||||
*p = NUL;
|
||||
}
|
||||
@ -3043,7 +3037,7 @@ void ex_call(exarg_T *eap)
|
||||
// contents. For VAR_PARTIAL get its partial, unless we already have one
|
||||
// from trans_function_name().
|
||||
len = (int)strlen(tofree);
|
||||
name = (char *)deref_func_name(tofree, &len, partial != NULL ? NULL : &partial, false);
|
||||
name = deref_func_name(tofree, &len, partial != NULL ? NULL : &partial, false);
|
||||
|
||||
// Skip white space to allow ":call func ()". Not good, but required for
|
||||
// backward compatibility.
|
||||
@ -3077,7 +3071,7 @@ void ex_call(exarg_T *eap)
|
||||
funcexe.fe_evaluate = true;
|
||||
funcexe.fe_partial = partial;
|
||||
funcexe.fe_selfdict = fudi.fd_dict;
|
||||
if (get_func_tv((char_u *)name, -1, &rettv, &arg, &funcexe) == FAIL) {
|
||||
if (get_func_tv(name, -1, &rettv, &arg, &funcexe) == FAIL) {
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ struct funccal_entry;
|
||||
/// Structure used by trans_function_name()
|
||||
typedef struct {
|
||||
dict_T *fd_dict; ///< Dictionary used.
|
||||
char_u *fd_newkey; ///< New key in "dict" in allocated memory.
|
||||
char *fd_newkey; ///< New key in "dict" in allocated memory.
|
||||
dictitem_T *fd_di; ///< Dictionary item used.
|
||||
} funcdict_T;
|
||||
|
||||
|
@ -1112,7 +1112,7 @@ int get_var_tv(const char *name, int len, typval_T *rettv, dictitem_T **dip, boo
|
||||
/// NULL when it doesn't exist.
|
||||
///
|
||||
/// @see tv_get_string() for how long the pointer remains valid.
|
||||
char_u *get_var_value(const char *const name)
|
||||
char *get_var_value(const char *const name)
|
||||
{
|
||||
dictitem_T *v;
|
||||
|
||||
@ -1120,7 +1120,7 @@ char_u *get_var_value(const char *const name)
|
||||
if (v == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return (char_u *)tv_get_string(&v->di_tv);
|
||||
return (char *)tv_get_string(&v->di_tv);
|
||||
}
|
||||
|
||||
/// Clean up a list of internal variables.
|
||||
|
@ -766,7 +766,7 @@ void f_winnr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
/// "winrestcmd()" function
|
||||
void f_winrestcmd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
char_u buf[50];
|
||||
char buf[50];
|
||||
|
||||
garray_T ga;
|
||||
ga_init(&ga, (int)sizeof(char), 70);
|
||||
@ -775,12 +775,12 @@ void f_winrestcmd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int winnr = 1;
|
||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||
snprintf((char *)buf, sizeof(buf), "%dresize %d|", winnr,
|
||||
snprintf(buf, sizeof(buf), "%dresize %d|", winnr,
|
||||
wp->w_height);
|
||||
ga_concat(&ga, (char *)buf);
|
||||
snprintf((char *)buf, sizeof(buf), "vert %dresize %d|", winnr,
|
||||
ga_concat(&ga, buf);
|
||||
snprintf(buf, sizeof(buf), "vert %dresize %d|", winnr,
|
||||
wp->w_width);
|
||||
ga_concat(&ga, (char *)buf);
|
||||
ga_concat(&ga, buf);
|
||||
winnr++;
|
||||
}
|
||||
}
|
||||
|
@ -1025,7 +1025,7 @@ void do_bang(int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out
|
||||
// If % or # appears in the command, it must have been escaped.
|
||||
// Reescape them, so that redoing them does not substitute them by the
|
||||
// buffername.
|
||||
char *cmd = (char *)vim_strsave_escaped((char_u *)prevcmd, (char_u *)"%#");
|
||||
char *cmd = vim_strsave_escaped(prevcmd, "%#");
|
||||
|
||||
AppendToRedobuffLit(cmd, -1);
|
||||
xfree(cmd);
|
||||
|
@ -721,7 +721,7 @@ void ex_compiler(exarg_T *eap)
|
||||
// plugin will then skip the settings. Afterwards set
|
||||
// "b:current_compiler" and restore "current_compiler".
|
||||
// Explicitly prepend "g:" to make it work in a function.
|
||||
old_cur_comp = (char *)get_var_value("g:current_compiler");
|
||||
old_cur_comp = get_var_value("g:current_compiler");
|
||||
if (old_cur_comp != NULL) {
|
||||
old_cur_comp = xstrdup(old_cur_comp);
|
||||
}
|
||||
@ -743,7 +743,7 @@ void ex_compiler(exarg_T *eap)
|
||||
do_cmdline_cmd(":delcommand CompilerSet");
|
||||
|
||||
// Set "b:current_compiler" from "current_compiler".
|
||||
p = (char *)get_var_value("g:current_compiler");
|
||||
p = get_var_value("g:current_compiler");
|
||||
if (p != NULL) {
|
||||
set_internal_string_var("b:current_compiler", p);
|
||||
}
|
||||
|
@ -3802,7 +3802,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp)
|
||||
|
||||
for (l = repl; *l; l++) {
|
||||
if (vim_strchr((char *)ESCAPE_CHARS, *l) != NULL) {
|
||||
l = (char *)vim_strsave_escaped((char_u *)repl, ESCAPE_CHARS);
|
||||
l = vim_strsave_escaped(repl, (char *)ESCAPE_CHARS);
|
||||
xfree(repl);
|
||||
repl = l;
|
||||
break;
|
||||
@ -3817,7 +3817,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp)
|
||||
&& strpbrk(repl, "!") != NULL) {
|
||||
char *l;
|
||||
|
||||
l = (char *)vim_strsave_escaped((char_u *)repl, (char_u *)"!");
|
||||
l = vim_strsave_escaped(repl, "!");
|
||||
xfree(repl);
|
||||
repl = l;
|
||||
}
|
||||
@ -7263,7 +7263,7 @@ static void ex_terminal(exarg_T *eap)
|
||||
char ex_cmd[1024];
|
||||
|
||||
if (*eap->arg != NUL) { // Run {cmd} in 'shell'.
|
||||
char *name = (char *)vim_strsave_escaped((char_u *)eap->arg, (char_u *)"\"\\");
|
||||
char *name = vim_strsave_escaped(eap->arg, "\"\\");
|
||||
snprintf(ex_cmd, sizeof(ex_cmd),
|
||||
":enew%s | call termopen(\"%s\")",
|
||||
eap->forceit ? "!" : "", name);
|
||||
|
@ -3964,18 +3964,16 @@ char *vim_strsave_fnameescape(const char *const fname, const int what)
|
||||
char *p = (char *)vim_strsave_escaped((const char_u *)fname,
|
||||
(const char_u *)buf);
|
||||
#else
|
||||
# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
|
||||
# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
|
||||
# define BUFFER_ESC_CHARS ((char_u *)" \t\n*?[`$\\%#'\"|!<")
|
||||
char *p =
|
||||
(char *)vim_strsave_escaped((const char_u *)fname,
|
||||
what == VSE_SHELL ? SHELL_ESC_CHARS
|
||||
: what == VSE_BUFFER ? BUFFER_ESC_CHARS : PATH_ESC_CHARS);
|
||||
# define PATH_ESC_CHARS " \t\n*?[{`$\\%#'\"|!<"
|
||||
# define SHELL_ESC_CHARS " \t\n*?[{`$\\%#'\"|!<>();&"
|
||||
# define BUFFER_ESC_CHARS " \t\n*?[`$\\%#'\"|!<"
|
||||
char *p = vim_strsave_escaped(fname,
|
||||
what == VSE_SHELL ? SHELL_ESC_CHARS : what ==
|
||||
VSE_BUFFER ? BUFFER_ESC_CHARS : PATH_ESC_CHARS);
|
||||
if (what == VSE_SHELL && csh_like_shell()) {
|
||||
// For csh and similar shells need to put two backslashes before '!'.
|
||||
// One is taken by Vim, one by the shell.
|
||||
char *s = (char *)vim_strsave_escaped((const char_u *)p,
|
||||
(const char_u *)"!");
|
||||
char *s = vim_strsave_escaped(p, "!");
|
||||
xfree(p);
|
||||
p = s;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
|
||||
}
|
||||
|
||||
size_t dircount = 1;
|
||||
search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *));
|
||||
search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char *));
|
||||
|
||||
do {
|
||||
char *helper;
|
||||
@ -355,7 +355,7 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
|
||||
|
||||
helper = walker;
|
||||
ptr = xrealloc(search_ctx->ffsc_stopdirs_v,
|
||||
(dircount + 1) * sizeof(char_u *));
|
||||
(dircount + 1) * sizeof(char *));
|
||||
search_ctx->ffsc_stopdirs_v = ptr;
|
||||
walker = vim_strchr(walker, ';');
|
||||
if (walker) {
|
||||
@ -447,11 +447,11 @@ void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, i
|
||||
add_pathsep(ff_expand_buffer);
|
||||
{
|
||||
size_t eb_len = strlen(ff_expand_buffer);
|
||||
char_u *buf = xmalloc(eb_len + strlen(search_ctx->ffsc_fix_path) + 1);
|
||||
char *buf = xmalloc(eb_len + strlen(search_ctx->ffsc_fix_path) + 1);
|
||||
|
||||
STRCPY(buf, ff_expand_buffer);
|
||||
STRCPY(buf + eb_len, search_ctx->ffsc_fix_path);
|
||||
if (os_isdir((char *)buf)) {
|
||||
if (os_isdir(buf)) {
|
||||
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
|
||||
add_pathsep(ff_expand_buffer);
|
||||
} else {
|
||||
@ -555,7 +555,7 @@ char_u *vim_findfile(void *search_ctx_arg)
|
||||
{
|
||||
char *file_path;
|
||||
char *rest_of_wildcards;
|
||||
char_u *path_end = NULL;
|
||||
char *path_end = NULL;
|
||||
ff_stack_T *stackp = NULL;
|
||||
size_t len;
|
||||
char *p;
|
||||
@ -574,7 +574,7 @@ char_u *vim_findfile(void *search_ctx_arg)
|
||||
|
||||
// store the end of the start dir -- needed for upward search
|
||||
if (search_ctx->ffsc_start_dir != NULL) {
|
||||
path_end = (char_u *)&search_ctx->ffsc_start_dir[strlen(search_ctx->ffsc_start_dir)];
|
||||
path_end = &search_ctx->ffsc_start_dir[strlen(search_ctx->ffsc_start_dir)];
|
||||
}
|
||||
|
||||
// upward search loop
|
||||
@ -886,16 +886,16 @@ char_u *vim_findfile(void *search_ctx_arg)
|
||||
|
||||
// is the last starting directory in the stop list?
|
||||
if (ff_path_in_stoplist(search_ctx->ffsc_start_dir,
|
||||
(int)(path_end - (char_u *)search_ctx->ffsc_start_dir),
|
||||
(int)(path_end - search_ctx->ffsc_start_dir),
|
||||
search_ctx->ffsc_stopdirs_v) == true) {
|
||||
break;
|
||||
}
|
||||
|
||||
// cut of last dir
|
||||
while (path_end > (char_u *)search_ctx->ffsc_start_dir && vim_ispathsep(*path_end)) {
|
||||
while (path_end > search_ctx->ffsc_start_dir && vim_ispathsep(*path_end)) {
|
||||
path_end--;
|
||||
}
|
||||
while (path_end > (char_u *)search_ctx->ffsc_start_dir && !vim_ispathsep(path_end[-1])) {
|
||||
while (path_end > search_ctx->ffsc_start_dir && !vim_ispathsep(path_end[-1])) {
|
||||
path_end--;
|
||||
}
|
||||
*path_end = 0;
|
||||
@ -1025,7 +1025,7 @@ static ff_visited_list_hdr_T *ff_get_visited_list(char *filename,
|
||||
/// - char by char comparison is OK
|
||||
/// - the only differences are in the counters behind a '**', so
|
||||
/// '**\20' is equal to '**\24'
|
||||
static bool ff_wc_equal(char_u *s1, char_u *s2)
|
||||
static bool ff_wc_equal(char *s1, char *s2)
|
||||
{
|
||||
int i, j;
|
||||
int c1 = NUL;
|
||||
@ -1042,8 +1042,8 @@ static bool ff_wc_equal(char_u *s1, char_u *s2)
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; s1[i] != NUL && s2[j] != NUL;) {
|
||||
c1 = utf_ptr2char((char *)s1 + i);
|
||||
c2 = utf_ptr2char((char *)s2 + j);
|
||||
c1 = utf_ptr2char(s1 + i);
|
||||
c2 = utf_ptr2char(s2 + j);
|
||||
|
||||
if ((p_fic ? mb_tolower(c1) != mb_tolower(c2) : c1 != c2)
|
||||
&& (prev1 != '*' || prev2 != '*')) {
|
||||
@ -1052,8 +1052,8 @@ static bool ff_wc_equal(char_u *s1, char_u *s2)
|
||||
prev2 = prev1;
|
||||
prev1 = c1;
|
||||
|
||||
i += utfc_ptr2len((char *)s1 + i);
|
||||
j += utfc_ptr2len((char *)s2 + j);
|
||||
i += utfc_ptr2len(s1 + i);
|
||||
j += utfc_ptr2len(s2 + j);
|
||||
}
|
||||
return s1[i] == s2[j];
|
||||
}
|
||||
@ -1086,7 +1086,7 @@ static int ff_check_visited(ff_visited_T **visited_list, char *fname, char *wc_p
|
||||
|| (!url && vp->file_id_valid
|
||||
&& os_fileid_equal(&(vp->file_id), &file_id))) {
|
||||
// are the wildcard parts equal
|
||||
if (ff_wc_equal((char_u *)vp->ffv_wc_path, (char_u *)wc_path)) {
|
||||
if (ff_wc_equal(vp->ffv_wc_path, wc_path)) {
|
||||
// already visited
|
||||
return FAIL;
|
||||
}
|
||||
@ -1453,7 +1453,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch
|
||||
|
||||
did_findfile_init = false;
|
||||
} else {
|
||||
char_u *r_ptr;
|
||||
char *r_ptr;
|
||||
|
||||
if (dir == NULL || *dir == NUL) {
|
||||
// We searched all paths of the option, now we can free the search context.
|
||||
@ -1469,9 +1469,9 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch
|
||||
copy_option_part(&dir, buf, MAXPATHL, " ,");
|
||||
|
||||
// get the stopdir string
|
||||
r_ptr = vim_findfile_stopdir((char_u *)buf);
|
||||
r_ptr = (char *)vim_findfile_stopdir((char_u *)buf);
|
||||
fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find,
|
||||
(char *)r_ptr, 100, false, find_what,
|
||||
r_ptr, 100, false, find_what,
|
||||
fdip_search_ctx, false, rel_fname);
|
||||
if (fdip_search_ctx != NULL) {
|
||||
did_findfile_init = true;
|
||||
|
@ -601,7 +601,7 @@ void init_highlight(bool both, bool reset)
|
||||
|
||||
// Try finding the color scheme file. Used when a color file was loaded
|
||||
// and 'background' or 't_Co' is changed.
|
||||
char *p = (char *)get_var_value("g:colors_name");
|
||||
char *p = get_var_value("g:colors_name");
|
||||
if (p != NULL) {
|
||||
// Value of g:colors_name could be freed in load_colors() and make
|
||||
// p invalid, so copy it.
|
||||
|
@ -1327,7 +1327,7 @@ static void ins_compl_dictionaries(char_u *dict_start, char_u *pat, int flags, i
|
||||
// to only match at the start of a line. Otherwise just match the
|
||||
// pattern. Also need to double backslashes.
|
||||
if (ctrl_x_mode_line_or_eval()) {
|
||||
char *pat_esc = (char *)vim_strsave_escaped(pat, (char_u *)"\\");
|
||||
char *pat_esc = vim_strsave_escaped((char *)pat, "\\");
|
||||
|
||||
size_t len = strlen(pat_esc) + 10;
|
||||
ptr = xmalloc(len);
|
||||
|
@ -960,10 +960,10 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
||||
// If "mapleader" or "maplocalleader" isn't set use a backslash.
|
||||
if (end - src >= 7 && STRNICMP(src, "<Leader>", 8) == 0) {
|
||||
len = 8;
|
||||
p = (char *)get_var_value("g:mapleader");
|
||||
p = get_var_value("g:mapleader");
|
||||
} else if (end - src >= 12 && STRNICMP(src, "<LocalLeader>", 13) == 0) {
|
||||
len = 13;
|
||||
p = (char *)get_var_value("g:maplocalleader");
|
||||
p = get_var_value("g:maplocalleader");
|
||||
} else {
|
||||
len = 0;
|
||||
p = NULL;
|
||||
|
@ -242,10 +242,10 @@ int main(int argc, char **argv)
|
||||
|
||||
argv0 = argv[0];
|
||||
|
||||
char_u *fname = NULL; // file name from command line
|
||||
char *fname = NULL; // file name from command line
|
||||
mparm_T params; // various parameters passed between
|
||||
// main() and other functions.
|
||||
char_u *cwd = NULL; // current working dir on startup
|
||||
char *cwd = NULL; // current working dir on startup
|
||||
time_init();
|
||||
|
||||
// Many variables are in `params` so that we can pass them around easily.
|
||||
@ -551,7 +551,7 @@ int main(int argc, char **argv)
|
||||
|
||||
// Need to jump to the tag before executing the '-c command'.
|
||||
// Makes "vim -c '/return' -t main" work.
|
||||
handle_tag((char_u *)params.tagname);
|
||||
handle_tag(params.tagname);
|
||||
|
||||
// Execute any "+", "-c" and "-S" arguments.
|
||||
if (params.n_commands > 0) {
|
||||
@ -1206,7 +1206,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
break;
|
||||
case 'w': // "-w{number}" set window height
|
||||
// "-w {scriptout}" write to script
|
||||
if (ascii_isdigit(((char_u *)argv[0])[argv_idx])) {
|
||||
if (ascii_isdigit((argv[0])[argv_idx])) {
|
||||
n = get_number_arg(argv[0], &argv_idx, 10);
|
||||
set_option_value_give_err("window", n, NULL, 0);
|
||||
break;
|
||||
@ -1347,7 +1347,7 @@ scripterror:
|
||||
|
||||
case 'w': // "-w {nr}" 'window' value
|
||||
// "-w {scriptout}" append to script file
|
||||
if (ascii_isdigit(*((char_u *)argv[0]))) {
|
||||
if (ascii_isdigit(*(argv[0]))) {
|
||||
argv_idx = 0;
|
||||
n = get_number_arg(argv[0], &argv_idx, 10);
|
||||
set_option_value_give_err("window", n, NULL, 0);
|
||||
@ -1480,9 +1480,9 @@ static void init_path(const char *exename)
|
||||
}
|
||||
|
||||
/// Get filename from command line, if any.
|
||||
static char_u *get_fname(mparm_T *parmp, char_u *cwd)
|
||||
static char *get_fname(mparm_T *parmp, char *cwd)
|
||||
{
|
||||
return (char_u *)alist_name(&GARGLIST[0]);
|
||||
return alist_name(&GARGLIST[0]);
|
||||
}
|
||||
|
||||
// Decide about window layout for diff mode after reading vimrc.
|
||||
@ -1516,7 +1516,7 @@ static void handle_quickfix(mparm_T *paramp)
|
||||
|
||||
// Need to jump to the tag before executing the '-c command'.
|
||||
// Makes "vim -c '/return' -t main" work.
|
||||
static void handle_tag(char_u *tagname)
|
||||
static void handle_tag(char *tagname)
|
||||
{
|
||||
if (tagname != NULL) {
|
||||
swap_exists_did_quit = false;
|
||||
@ -1704,7 +1704,7 @@ static void create_windows(mparm_T *parmp)
|
||||
|
||||
/// If opened more than one window, start editing files in the other
|
||||
/// windows. make_windows() has already opened the windows.
|
||||
static void edit_buffers(mparm_T *parmp, char_u *cwd)
|
||||
static void edit_buffers(mparm_T *parmp, char *cwd)
|
||||
{
|
||||
int arg_idx; // index in argument list
|
||||
int i;
|
||||
@ -1725,7 +1725,7 @@ static void edit_buffers(mparm_T *parmp, char_u *cwd)
|
||||
arg_idx = 1;
|
||||
for (i = 1; i < parmp->window_count; i++) {
|
||||
if (cwd != NULL) {
|
||||
os_chdir((char *)cwd);
|
||||
os_chdir(cwd);
|
||||
}
|
||||
// When w_arg_idx is -1 remove the window (see create_windows()).
|
||||
if (curwin->w_arg_idx == -1) {
|
||||
@ -1944,13 +1944,13 @@ static bool do_user_initialization(void)
|
||||
return do_exrc;
|
||||
}
|
||||
|
||||
char_u *init_lua_path = (char_u *)stdpaths_user_conf_subpath("init.lua");
|
||||
char_u *user_vimrc = (char_u *)stdpaths_user_conf_subpath("init.vim");
|
||||
char *init_lua_path = stdpaths_user_conf_subpath("init.lua");
|
||||
char *user_vimrc = stdpaths_user_conf_subpath("init.vim");
|
||||
|
||||
// init.lua
|
||||
if (os_path_exists((char *)init_lua_path)
|
||||
&& do_source((char *)init_lua_path, true, DOSO_VIMRC)) {
|
||||
if (os_path_exists((char *)user_vimrc)) {
|
||||
if (os_path_exists(init_lua_path)
|
||||
&& do_source(init_lua_path, true, DOSO_VIMRC)) {
|
||||
if (os_path_exists(user_vimrc)) {
|
||||
semsg(_("E5422: Conflicting configs: \"%s\" \"%s\""), init_lua_path,
|
||||
user_vimrc);
|
||||
}
|
||||
@ -1963,10 +1963,10 @@ static bool do_user_initialization(void)
|
||||
xfree(init_lua_path);
|
||||
|
||||
// init.vim
|
||||
if (do_source((char *)user_vimrc, true, DOSO_VIMRC) != FAIL) {
|
||||
if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) {
|
||||
do_exrc = p_exrc;
|
||||
if (do_exrc) {
|
||||
do_exrc = (path_full_compare(VIMRC_FILE, (char *)user_vimrc, false, true) != kEqualFiles);
|
||||
do_exrc = (path_full_compare(VIMRC_FILE, user_vimrc, false, true) != kEqualFiles);
|
||||
}
|
||||
xfree(user_vimrc);
|
||||
return do_exrc;
|
||||
|
@ -297,10 +297,10 @@ static void set_maparg_rhs(const char *const orig_rhs, const size_t orig_rhs_len
|
||||
|
||||
if (rhs_lua == LUA_NOREF) {
|
||||
mapargs->orig_rhs_len = orig_rhs_len;
|
||||
mapargs->orig_rhs = xcalloc(mapargs->orig_rhs_len + 1, sizeof(char_u));
|
||||
mapargs->orig_rhs = xcalloc(mapargs->orig_rhs_len + 1, sizeof(char));
|
||||
xstrlcpy(mapargs->orig_rhs, orig_rhs, mapargs->orig_rhs_len + 1);
|
||||
if (STRICMP(orig_rhs, "<nop>") == 0) { // "<Nop>" means nothing
|
||||
mapargs->rhs = xcalloc(1, sizeof(char_u)); // single NUL-char
|
||||
mapargs->rhs = xcalloc(1, sizeof(char)); // single NUL-char
|
||||
mapargs->rhs_len = 0;
|
||||
mapargs->rhs_is_noop = true;
|
||||
} else {
|
||||
@ -316,7 +316,7 @@ static void set_maparg_rhs(const char *const orig_rhs, const size_t orig_rhs_len
|
||||
} else {
|
||||
char tmp_buf[64];
|
||||
// orig_rhs is not used for Lua mappings, but still needs to be a string.
|
||||
mapargs->orig_rhs = xcalloc(1, sizeof(char_u));
|
||||
mapargs->orig_rhs = xcalloc(1, sizeof(char));
|
||||
mapargs->orig_rhs_len = 0;
|
||||
// stores <lua>ref_no<cr> in map_str
|
||||
mapargs->rhs_len = (size_t)vim_snprintf(S_LEN(tmp_buf), "%c%c%c%d\r", K_SPECIAL,
|
||||
@ -344,53 +344,53 @@ static void set_maparg_rhs(const char *const orig_rhs, const size_t orig_rhs_len
|
||||
/// @param[out] mapargs MapArguments struct holding all extracted argument
|
||||
/// values.
|
||||
/// @return 0 on success, 1 if invalid arguments are detected.
|
||||
static int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs)
|
||||
static int str_to_mapargs(const char *strargs, bool is_unmap, MapArguments *mapargs)
|
||||
{
|
||||
const char *to_parse = (char *)strargs;
|
||||
to_parse = skipwhite((char *)to_parse);
|
||||
const char *to_parse = strargs;
|
||||
to_parse = skipwhite(to_parse);
|
||||
CLEAR_POINTER(mapargs);
|
||||
|
||||
// Accept <buffer>, <nowait>, <silent>, <expr>, <script>, and <unique> in
|
||||
// any order.
|
||||
while (true) {
|
||||
if (strncmp(to_parse, "<buffer>", 8) == 0) {
|
||||
to_parse = skipwhite((char *)to_parse + 8);
|
||||
to_parse = skipwhite(to_parse + 8);
|
||||
mapargs->buffer = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(to_parse, "<nowait>", 8) == 0) {
|
||||
to_parse = skipwhite((char *)to_parse + 8);
|
||||
to_parse = skipwhite(to_parse + 8);
|
||||
mapargs->nowait = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(to_parse, "<silent>", 8) == 0) {
|
||||
to_parse = skipwhite((char *)to_parse + 8);
|
||||
to_parse = skipwhite(to_parse + 8);
|
||||
mapargs->silent = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore obsolete "<special>" modifier.
|
||||
if (strncmp(to_parse, "<special>", 9) == 0) {
|
||||
to_parse = skipwhite((char *)to_parse + 9);
|
||||
to_parse = skipwhite(to_parse + 9);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(to_parse, "<script>", 8) == 0) {
|
||||
to_parse = skipwhite((char *)to_parse + 8);
|
||||
to_parse = skipwhite(to_parse + 8);
|
||||
mapargs->script = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(to_parse, "<expr>", 6) == 0) {
|
||||
to_parse = skipwhite((char *)to_parse + 6);
|
||||
to_parse = skipwhite(to_parse + 6);
|
||||
mapargs->expr = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(to_parse, "<unique>", 8) == 0) {
|
||||
to_parse = skipwhite((char *)to_parse + 8);
|
||||
to_parse = skipwhite(to_parse + 8);
|
||||
mapargs->unique = true;
|
||||
continue;
|
||||
}
|
||||
@ -407,7 +407,7 @@ static int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *ma
|
||||
//
|
||||
// With :unmap, literal white space is included in the {lhs}; there is no
|
||||
// separate {rhs}.
|
||||
const char *lhs_end = (char *)to_parse;
|
||||
const char *lhs_end = to_parse;
|
||||
bool do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL);
|
||||
while (*lhs_end && (is_unmap || !ascii_iswhite(*lhs_end))) {
|
||||
if ((lhs_end[0] == Ctrl_V || (do_backslash && lhs_end[0] == '\\'))
|
||||
@ -915,7 +915,7 @@ theend:
|
||||
int do_map(int maptype, char_u *arg, int mode, bool is_abbrev)
|
||||
{
|
||||
MapArguments parsed_args;
|
||||
int result = str_to_mapargs(arg, maptype == MAPTYPE_UNMAP, &parsed_args);
|
||||
int result = str_to_mapargs((char *)arg, maptype == MAPTYPE_UNMAP, &parsed_args);
|
||||
switch (result) {
|
||||
case 0:
|
||||
break;
|
||||
@ -1067,9 +1067,9 @@ bool map_to_exists(const char *const str, const char *const modechars, const boo
|
||||
int retval;
|
||||
|
||||
char *buf = NULL;
|
||||
const char_u *const rhs = (char_u *)replace_termcodes(str, strlen(str),
|
||||
&buf, REPTERM_DO_LT,
|
||||
NULL, CPO_TO_CPO_FLAGS);
|
||||
const char *const rhs = replace_termcodes(str, strlen(str),
|
||||
&buf, REPTERM_DO_LT,
|
||||
NULL, CPO_TO_CPO_FLAGS);
|
||||
|
||||
#define MAPMODE(mode, modechars, chr, modeflags) \
|
||||
do { \
|
||||
@ -1087,7 +1087,7 @@ bool map_to_exists(const char *const str, const char *const modechars, const boo
|
||||
MAPMODE(mode, modechars, 'c', MODE_CMDLINE);
|
||||
#undef MAPMODE
|
||||
|
||||
retval = map_to_exists_mode((char *)rhs, mode, abbr);
|
||||
retval = map_to_exists_mode(rhs, mode, abbr);
|
||||
xfree(buf);
|
||||
|
||||
return retval;
|
||||
@ -1344,7 +1344,7 @@ int ExpandMappings(regmatch_T *regmatch, int *num_file, char ***file)
|
||||
}
|
||||
|
||||
if (round == 1) {
|
||||
*file = xmalloc((size_t)count * sizeof(char_u *));
|
||||
*file = xmalloc((size_t)count * sizeof(char *));
|
||||
}
|
||||
} // for (round)
|
||||
|
||||
@ -1418,25 +1418,25 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
|
||||
|
||||
{
|
||||
bool vim_abbr;
|
||||
char_u *p = mb_prevptr((char_u *)ptr, (char_u *)ptr + col);
|
||||
if (!vim_iswordp((char *)p)) {
|
||||
char *p = (char *)mb_prevptr((char_u *)ptr, (char_u *)ptr + col);
|
||||
if (!vim_iswordp(p)) {
|
||||
vim_abbr = true; // Vim added abbr.
|
||||
} else {
|
||||
vim_abbr = false; // vi compatible abbr.
|
||||
if (p > (char_u *)ptr) {
|
||||
is_id = vim_iswordp((char *)mb_prevptr((char_u *)ptr, p));
|
||||
if (p > ptr) {
|
||||
is_id = vim_iswordp((char *)mb_prevptr((char_u *)ptr, (char_u *)p));
|
||||
}
|
||||
}
|
||||
clen = 1;
|
||||
while (p > (char_u *)ptr + mincol) {
|
||||
p = mb_prevptr((char_u *)ptr, p);
|
||||
if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp((char *)p))) {
|
||||
p += utfc_ptr2len((char *)p);
|
||||
while (p > ptr + mincol) {
|
||||
p = (char *)mb_prevptr((char_u *)ptr, (char_u *)p);
|
||||
if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) {
|
||||
p += utfc_ptr2len(p);
|
||||
break;
|
||||
}
|
||||
clen++;
|
||||
}
|
||||
scol = (int)(p - (char_u *)ptr);
|
||||
scol = (int)(p - ptr);
|
||||
}
|
||||
|
||||
if (scol < mincol) {
|
||||
@ -1623,8 +1623,8 @@ char *eval_map_expr(mapblock_T *mp, int c)
|
||||
int makemap(FILE *fd, buf_T *buf)
|
||||
{
|
||||
mapblock_T *mp;
|
||||
char_u c1, c2, c3;
|
||||
char_u *p;
|
||||
char c1, c2, c3;
|
||||
char *p;
|
||||
char *cmd;
|
||||
int abbr;
|
||||
int hash;
|
||||
@ -1662,8 +1662,8 @@ int makemap(FILE *fd, buf_T *buf)
|
||||
if (mp->m_luaref != LUA_NOREF) {
|
||||
continue;
|
||||
}
|
||||
for (p = (char_u *)mp->m_str; *p != NUL; p++) {
|
||||
if (p[0] == K_SPECIAL && p[1] == KS_EXTRA
|
||||
for (p = mp->m_str; *p != NUL; p++) {
|
||||
if ((uint8_t)p[0] == K_SPECIAL && (uint8_t)p[1] == KS_EXTRA
|
||||
&& p[2] == KE_SNR) {
|
||||
break;
|
||||
}
|
||||
@ -2107,13 +2107,12 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
|
||||
const int flags = REPTERM_FROM_PART | REPTERM_DO_LT;
|
||||
const int mode = get_map_mode((char **)&which, 0);
|
||||
|
||||
char_u *keys_simplified
|
||||
= (char_u *)replace_termcodes(keys, strlen(keys), &keys_buf, flags, &did_simplify,
|
||||
CPO_TO_CPO_FLAGS);
|
||||
char *keys_simplified = replace_termcodes(keys, strlen(keys), &keys_buf, flags, &did_simplify,
|
||||
CPO_TO_CPO_FLAGS);
|
||||
mapblock_T *mp = NULL;
|
||||
int buffer_local;
|
||||
LuaRef rhs_lua;
|
||||
char *rhs = check_map((char *)keys_simplified, mode, exact, false, abbr, &mp, &buffer_local,
|
||||
char *rhs = check_map(keys_simplified, mode, exact, false, abbr, &mp, &buffer_local,
|
||||
&rhs_lua);
|
||||
if (did_simplify) {
|
||||
// When the lhs is being simplified the not-simplified keys are
|
||||
@ -2140,7 +2139,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
|
||||
// Return a dictionary.
|
||||
if (mp != NULL && (rhs != NULL || rhs_lua != LUA_NOREF)) {
|
||||
Dictionary dict = mapblock_fill_dict(mp,
|
||||
did_simplify ? (char *)keys_simplified : NULL,
|
||||
did_simplify ? keys_simplified : NULL,
|
||||
buffer_local, true);
|
||||
(void)object_to_vim(DICTIONARY_OBJ(dict), rettv, NULL);
|
||||
api_free_dictionary(dict);
|
||||
@ -2350,14 +2349,14 @@ void langmap_init(void)
|
||||
/// changed at any time!
|
||||
void langmap_set(void)
|
||||
{
|
||||
char_u *p;
|
||||
char_u *p2;
|
||||
char *p;
|
||||
char *p2;
|
||||
int from, to;
|
||||
|
||||
ga_clear(&langmap_mapga); // clear the previous map first
|
||||
langmap_init(); // back to one-to-one map
|
||||
|
||||
for (p = (char_u *)p_langmap; p[0] != NUL;) {
|
||||
for (p = p_langmap; p[0] != NUL;) {
|
||||
for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
|
||||
MB_PTR_ADV(p2)) {
|
||||
if (p2[0] == '\\' && p2[1] != NUL) {
|
||||
@ -2377,7 +2376,7 @@ void langmap_set(void)
|
||||
if (p[0] == '\\' && p[1] != NUL) {
|
||||
p++;
|
||||
}
|
||||
from = utf_ptr2char((char *)p);
|
||||
from = utf_ptr2char(p);
|
||||
to = NUL;
|
||||
if (p2 == NULL) {
|
||||
MB_PTR_ADV(p);
|
||||
@ -2385,14 +2384,14 @@ void langmap_set(void)
|
||||
if (p[0] == '\\') {
|
||||
p++;
|
||||
}
|
||||
to = utf_ptr2char((char *)p);
|
||||
to = utf_ptr2char(p);
|
||||
}
|
||||
} else {
|
||||
if (p2[0] != ',') {
|
||||
if (p2[0] == '\\') {
|
||||
p2++;
|
||||
}
|
||||
to = utf_ptr2char((char *)p2);
|
||||
to = utf_ptr2char(p2);
|
||||
}
|
||||
}
|
||||
if (to == NUL) {
|
||||
@ -2416,8 +2415,7 @@ void langmap_set(void)
|
||||
p = p2;
|
||||
if (p[0] != NUL) {
|
||||
if (p[0] != ',') {
|
||||
semsg(_("E358: 'langmap': Extra characters after semicolon: %s"),
|
||||
p);
|
||||
semsg(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
|
||||
return;
|
||||
}
|
||||
p++;
|
||||
|
@ -833,7 +833,7 @@ void ex_marks(exarg_T *eap)
|
||||
}
|
||||
for (i = 0; i < NGLOBALMARKS; i++) {
|
||||
if (namedfm[i].fmark.fnum != 0) {
|
||||
name = (char *)fm_getname(&namedfm[i].fmark, 15);
|
||||
name = fm_getname(&namedfm[i].fmark, 15);
|
||||
} else {
|
||||
name = namedfm[i].fname;
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ void ex_jumps(exarg_T *eap)
|
||||
msg_puts_title(_("\n jump line col file/text"));
|
||||
for (i = 0; i < curwin->w_jumplistlen && !got_int; i++) {
|
||||
if (curwin->w_jumplist[i].fmark.mark.lnum != 0) {
|
||||
name = (char *)fm_getname(&curwin->w_jumplist[i].fmark, 16);
|
||||
name = fm_getname(&curwin->w_jumplist[i].fmark, 16);
|
||||
|
||||
// Make sure to output the current indicator, even when on an wiped
|
||||
// out buffer. ":filter" may still skip it.
|
||||
|
@ -461,16 +461,16 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
|
||||
} else if (vim_strchr(p_cpo, CPO_SEARCH) == NULL
|
||||
|| (shl->rm.endpos[0].lnum == 0
|
||||
&& shl->rm.endpos[0].col <= shl->rm.startpos[0].col)) {
|
||||
char_u *ml;
|
||||
char *ml;
|
||||
|
||||
matchcol = shl->rm.startpos[0].col;
|
||||
ml = (char_u *)ml_get_buf(shl->buf, lnum, false) + matchcol;
|
||||
ml = ml_get_buf(shl->buf, lnum, false) + matchcol;
|
||||
if (*ml == NUL) {
|
||||
matchcol++;
|
||||
shl->lnum = 0;
|
||||
break;
|
||||
}
|
||||
matchcol += utfc_ptr2len((char *)ml);
|
||||
matchcol += utfc_ptr2len(ml);
|
||||
} else {
|
||||
matchcol = shl->rm.endpos[0].col;
|
||||
}
|
||||
|
@ -759,7 +759,7 @@ void mf_free_fnames(memfile_T *mfp)
|
||||
void mf_set_fnames(memfile_T *mfp, char *fname)
|
||||
{
|
||||
mfp->mf_fname = fname;
|
||||
mfp->mf_ffname = (char_u *)FullName_save(mfp->mf_fname, false);
|
||||
mfp->mf_ffname = FullName_save(mfp->mf_fname, false);
|
||||
}
|
||||
|
||||
/// Make name of memfile's swapfile a full path.
|
||||
@ -769,7 +769,7 @@ void mf_fullname(memfile_T *mfp)
|
||||
{
|
||||
if (mfp != NULL && mfp->mf_fname != NULL && mfp->mf_ffname != NULL) {
|
||||
xfree(mfp->mf_fname);
|
||||
mfp->mf_fname = (char *)mfp->mf_ffname;
|
||||
mfp->mf_fname = mfp->mf_ffname;
|
||||
mfp->mf_ffname = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ typedef struct mf_blocknr_trans_item {
|
||||
/// A memory file.
|
||||
typedef struct memfile {
|
||||
char *mf_fname; /// name of the file
|
||||
char_u *mf_ffname; /// idem, full path
|
||||
char *mf_ffname; /// idem, full path
|
||||
int mf_fd; /// file descriptor
|
||||
bhdr_T *mf_free_first; /// first block header in free list
|
||||
bhdr_T *mf_used_first; /// mru block header in used list
|
||||
|
@ -2641,7 +2641,7 @@ static void ml_flush_line(buf_T *buf)
|
||||
DATA_BL *dp = hp->bh_data;
|
||||
int idx = lnum - buf->b_ml.ml_locked_low;
|
||||
int start = ((dp->db_index[idx]) & DB_INDEX_MASK);
|
||||
char_u *old_line = (char_u *)dp + start;
|
||||
char *old_line = (char *)dp + start;
|
||||
int old_len;
|
||||
if (idx == 0) { // line is last in block
|
||||
old_len = (int)dp->db_txt_end - start;
|
||||
@ -3047,13 +3047,13 @@ char *makeswapname(char *fname, char *ffname, buf_T *buf, char *dir_name)
|
||||
}
|
||||
|
||||
// Prepend a '.' to the swap file name for the current directory.
|
||||
char_u *r = (char_u *)modname(fname_res, ".swp",
|
||||
dir_name[0] == '.' && dir_name[1] == NUL);
|
||||
char *r = modname(fname_res, ".swp",
|
||||
dir_name[0] == '.' && dir_name[1] == NUL);
|
||||
if (r == NULL) { // out of memory
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = get_file_in_dir((char *)r, dir_name);
|
||||
s = get_file_in_dir(r, dir_name);
|
||||
xfree(r);
|
||||
return s;
|
||||
}
|
||||
@ -3100,16 +3100,16 @@ char *get_file_in_dir(char *fname, char *dname)
|
||||
///
|
||||
/// @param buf buffer being edited
|
||||
/// @param fname swap file name
|
||||
static void attention_message(buf_T *buf, char_u *fname)
|
||||
static void attention_message(buf_T *buf, char *fname)
|
||||
{
|
||||
assert(buf->b_fname != NULL);
|
||||
|
||||
no_wait_return++;
|
||||
(void)emsg(_("E325: ATTENTION"));
|
||||
msg_puts(_("\nFound a swap file by the name \""));
|
||||
msg_home_replace((char *)fname);
|
||||
msg_home_replace(fname);
|
||||
msg_puts("\"\n");
|
||||
const time_t swap_mtime = swapfile_info(fname);
|
||||
const time_t swap_mtime = swapfile_info((char_u *)fname);
|
||||
msg_puts(_("While opening file \""));
|
||||
msg_outtrans(buf->b_fname);
|
||||
msg_puts("\"\n");
|
||||
@ -3136,7 +3136,7 @@ static void attention_message(buf_T *buf, char_u *fname)
|
||||
msg_outtrans(buf->b_fname);
|
||||
msg_puts(_("\"\n to recover the changes (see \":help recovery\").\n"));
|
||||
msg_puts(_(" If you did this already, delete the swap file \""));
|
||||
msg_outtrans((char *)fname);
|
||||
msg_outtrans(fname);
|
||||
msg_puts(_("\"\n to avoid this message.\n"));
|
||||
cmdline_row = msg_row;
|
||||
no_wait_return--;
|
||||
@ -3316,7 +3316,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
|
||||
|
||||
if (choice == 0) {
|
||||
// Show info about the existing swap file.
|
||||
attention_message(buf, (char_u *)fname);
|
||||
attention_message(buf, fname);
|
||||
|
||||
// We don't want a 'q' typed at the more-prompt
|
||||
// interrupt loading a file.
|
||||
|
@ -1577,7 +1577,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
|
||||
|
||||
// if i == 0: try to find an identifier
|
||||
// if i == 1: try to find any non-white text
|
||||
char_u *ptr = (char_u *)ml_get_buf(wp->w_buffer, lnum, false);
|
||||
char *ptr = ml_get_buf(wp->w_buffer, lnum, false);
|
||||
for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; i++) {
|
||||
// 1. skip to start of identifier/text
|
||||
col = startcol;
|
||||
@ -1586,11 +1586,11 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
|
||||
if ((find_type & FIND_EVAL) && ptr[col] == ']') {
|
||||
break;
|
||||
}
|
||||
this_class = mb_get_class(ptr + col);
|
||||
this_class = mb_get_class((char_u *)ptr + col);
|
||||
if (this_class != 0 && (i == 1 || this_class != 1)) {
|
||||
break;
|
||||
}
|
||||
col += utfc_ptr2len((char *)ptr + col);
|
||||
col += utfc_ptr2len(ptr + col);
|
||||
}
|
||||
|
||||
// When starting on a ']' count it, so that we include the '['.
|
||||
@ -1603,18 +1603,18 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
|
||||
if ((find_type & FIND_EVAL) && ptr[col] == ']') {
|
||||
this_class = mb_get_class((char_u *)"a");
|
||||
} else {
|
||||
this_class = mb_get_class(ptr + col);
|
||||
this_class = mb_get_class((char_u *)ptr + col);
|
||||
}
|
||||
while (col > 0 && this_class != 0) {
|
||||
prevcol = col - 1 - utf_head_off((char *)ptr, (char *)ptr + col - 1);
|
||||
prev_class = mb_get_class(ptr + prevcol);
|
||||
prevcol = col - 1 - utf_head_off(ptr, ptr + col - 1);
|
||||
prev_class = mb_get_class((char_u *)ptr + prevcol);
|
||||
if (this_class != prev_class
|
||||
&& (i == 0
|
||||
|| prev_class == 0
|
||||
|| (find_type & FIND_IDENT))
|
||||
&& (!(find_type & FIND_EVAL)
|
||||
|| prevcol == 0
|
||||
|| !find_is_eval_item(ptr + prevcol, &prevcol, &bn, BACKWARD))) {
|
||||
|| !find_is_eval_item((char_u *)ptr + prevcol, &prevcol, &bn, BACKWARD))) {
|
||||
break;
|
||||
}
|
||||
col = prevcol;
|
||||
@ -1640,7 +1640,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
|
||||
return 0;
|
||||
}
|
||||
ptr += col;
|
||||
*text = (char *)ptr;
|
||||
*text = ptr;
|
||||
if (textcol != NULL) {
|
||||
*textcol = col;
|
||||
}
|
||||
@ -1650,15 +1650,15 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text
|
||||
startcol -= col;
|
||||
col = 0;
|
||||
// Search for point of changing multibyte character class.
|
||||
this_class = mb_get_class(ptr);
|
||||
this_class = mb_get_class((char_u *)ptr);
|
||||
while (ptr[col] != NUL // -V781
|
||||
&& ((i == 0
|
||||
? mb_get_class(ptr + col) == this_class
|
||||
: mb_get_class(ptr + col) != 0)
|
||||
? mb_get_class((char_u *)ptr + col) == this_class
|
||||
: mb_get_class((char_u *)ptr + col) != 0)
|
||||
|| ((find_type & FIND_EVAL)
|
||||
&& col <= (int)startcol
|
||||
&& find_is_eval_item(ptr + col, &col, &bn, FORWARD)))) {
|
||||
col += utfc_ptr2len((char *)ptr + col);
|
||||
&& find_is_eval_item((char_u *)ptr + col, &col, &bn, FORWARD)))) {
|
||||
col += utfc_ptr2len(ptr + col);
|
||||
}
|
||||
|
||||
assert(col >= 0);
|
||||
@ -1783,7 +1783,7 @@ void may_clear_cmdline(void)
|
||||
}
|
||||
|
||||
// Routines for displaying a partly typed command
|
||||
static char_u old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd()
|
||||
static char old_showcmd_buf[SHOWCMD_BUFLEN]; // For push_showcmd()
|
||||
static bool showcmd_is_clear = true;
|
||||
static bool showcmd_visual = false;
|
||||
|
||||
@ -1827,20 +1827,20 @@ void clear_showcmd(void)
|
||||
} else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum) {
|
||||
snprintf(showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64, (int64_t)lines);
|
||||
} else {
|
||||
char_u *s, *e;
|
||||
char *s, *e;
|
||||
int l;
|
||||
int bytes = 0;
|
||||
int chars = 0;
|
||||
|
||||
if (cursor_bot) {
|
||||
s = (char_u *)ml_get_pos(&VIsual);
|
||||
e = (char_u *)get_cursor_pos_ptr();
|
||||
s = ml_get_pos(&VIsual);
|
||||
e = get_cursor_pos_ptr();
|
||||
} else {
|
||||
s = (char_u *)get_cursor_pos_ptr();
|
||||
e = (char_u *)ml_get_pos(&VIsual);
|
||||
s = get_cursor_pos_ptr();
|
||||
e = ml_get_pos(&VIsual);
|
||||
}
|
||||
while ((*p_sel != 'e') ? s <= e : s < e) {
|
||||
l = utfc_ptr2len((char *)s);
|
||||
l = utfc_ptr2len(s);
|
||||
if (l == 0) {
|
||||
bytes++;
|
||||
chars++;
|
||||
@ -2269,7 +2269,7 @@ static bool is_ident(const char_u *line, int offset)
|
||||
/// @return fail when not found.
|
||||
bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_arg)
|
||||
{
|
||||
char_u *pat;
|
||||
char *pat;
|
||||
pos_T old_pos;
|
||||
pos_T par_pos;
|
||||
pos_T found_pos;
|
||||
@ -2285,7 +2285,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
|
||||
// Put "\V" before the pattern to avoid that the special meaning of "."
|
||||
// and "~" causes trouble.
|
||||
assert(len <= INT_MAX);
|
||||
sprintf((char *)pat, vim_iswordp((char *)ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", // NOLINT(runtime/printf)
|
||||
sprintf(pat, vim_iswordp((char *)ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", // NOLINT(runtime/printf)
|
||||
(int)len, ptr);
|
||||
old_pos = curwin->w_cursor;
|
||||
save_p_ws = p_ws;
|
||||
@ -2313,7 +2313,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
|
||||
clearpos(&found_pos);
|
||||
for (;;) {
|
||||
t = searchit(curwin, curbuf, &curwin->w_cursor, NULL, FORWARD,
|
||||
pat, 1L, searchflags, RE_LAST, NULL);
|
||||
(char_u *)pat, 1L, searchflags, RE_LAST, NULL);
|
||||
if (curwin->w_cursor.lnum >= old_pos.lnum) {
|
||||
t = false; // match after start is failure too
|
||||
}
|
||||
@ -3815,10 +3815,10 @@ static void nv_left(cmdarg_T *cap)
|
||||
// Don't adjust op_end now, otherwise it won't work.
|
||||
if ((cap->oap->op_type == OP_DELETE || cap->oap->op_type == OP_CHANGE)
|
||||
&& !LINEEMPTY(curwin->w_cursor.lnum)) {
|
||||
char_u *cp = (char_u *)get_cursor_pos_ptr();
|
||||
char *cp = get_cursor_pos_ptr();
|
||||
|
||||
if (*cp != NUL) {
|
||||
curwin->w_cursor.col += utfc_ptr2len((char *)cp);
|
||||
curwin->w_cursor.col += utfc_ptr2len(cp);
|
||||
}
|
||||
cap->retval |= CA_NO_ADJ_OP_END;
|
||||
}
|
||||
@ -3890,7 +3890,7 @@ static void nv_down(cmdarg_T *cap)
|
||||
/// Grab the file name under the cursor and edit it.
|
||||
static void nv_gotofile(cmdarg_T *cap)
|
||||
{
|
||||
char_u *ptr;
|
||||
char *ptr;
|
||||
linenr_T lnum = -1;
|
||||
|
||||
if (check_text_locked(cap->oap)) {
|
||||
@ -3901,7 +3901,7 @@ static void nv_gotofile(cmdarg_T *cap)
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = grab_file_name(cap->count1, &lnum);
|
||||
ptr = (char *)grab_file_name(cap->count1, &lnum);
|
||||
|
||||
if (ptr != NULL) {
|
||||
// do autowrite if necessary
|
||||
@ -3909,7 +3909,7 @@ static void nv_gotofile(cmdarg_T *cap)
|
||||
(void)autowrite(curbuf, false);
|
||||
}
|
||||
setpcmark();
|
||||
if (do_ecmd(0, (char *)ptr, NULL, NULL, ECMD_LAST,
|
||||
if (do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
|
||||
buf_hide(curbuf) ? ECMD_HIDE : 0, curwin) == OK
|
||||
&& cap->nchar == 'F' && lnum >= 0) {
|
||||
curwin->w_cursor.lnum = lnum;
|
||||
@ -5239,7 +5239,7 @@ static void nv_g_underscore_cmd(cmdarg_T *cap)
|
||||
return;
|
||||
}
|
||||
|
||||
char_u *ptr = (char_u *)get_cursor_line_ptr();
|
||||
char *ptr = get_cursor_line_ptr();
|
||||
|
||||
// In Visual mode we may end up after the line.
|
||||
if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) {
|
||||
@ -6227,7 +6227,7 @@ static void nv_object(cmdarg_T *cap)
|
||||
{
|
||||
bool flag;
|
||||
bool include;
|
||||
char_u *mps_save;
|
||||
char *mps_save;
|
||||
|
||||
if (cap->cmdchar == 'i') {
|
||||
include = false; // "ix" = inner object: exclude white space
|
||||
@ -6235,7 +6235,7 @@ static void nv_object(cmdarg_T *cap)
|
||||
include = true; // "ax" = an object: include white space
|
||||
}
|
||||
// Make sure (), [], {} and <> are in 'matchpairs'
|
||||
mps_save = (char_u *)curbuf->b_p_mps;
|
||||
mps_save = curbuf->b_p_mps;
|
||||
curbuf->b_p_mps = "(:),{:},[:],<:>";
|
||||
|
||||
switch (cap->nchar) {
|
||||
@ -6290,7 +6290,7 @@ static void nv_object(cmdarg_T *cap)
|
||||
break;
|
||||
}
|
||||
|
||||
curbuf->b_p_mps = (char *)mps_save;
|
||||
curbuf->b_p_mps = mps_save;
|
||||
if (!flag) {
|
||||
clearopbeep(cap->oap);
|
||||
}
|
||||
|
@ -1109,12 +1109,12 @@ int do_execreg(int regname, int colon, int addcr, int silent)
|
||||
// don't keep the cmdline containing @:
|
||||
XFREE_CLEAR(new_last_cmdline);
|
||||
// Escape all control characters with a CTRL-V
|
||||
p = (char *)vim_strsave_escaped_ext((char_u *)last_cmdline,
|
||||
(char_u *)"\001\002\003\004\005\006\007"
|
||||
"\010\011\012\013\014\015\016\017"
|
||||
"\020\021\022\023\024\025\026\027"
|
||||
"\030\031\032\033\034\035\036\037",
|
||||
Ctrl_V, false);
|
||||
p = vim_strsave_escaped_ext(last_cmdline,
|
||||
"\001\002\003\004\005\006\007"
|
||||
"\010\011\012\013\014\015\016\017"
|
||||
"\020\021\022\023\024\025\026\027"
|
||||
"\030\031\032\033\034\035\036\037",
|
||||
Ctrl_V, false);
|
||||
// When in Visual mode "'<,'>" will be prepended to the command.
|
||||
// Remove it when it's already there.
|
||||
if (VIsual_active && strncmp(p, "'<,'>", 5) == 0) {
|
||||
|
@ -4783,7 +4783,7 @@ void ExpandOldSetting(int *num_file, char ***file)
|
||||
|
||||
// A backslash is required before some characters. This is the reverse of
|
||||
// what happens in do_set().
|
||||
char_u *buf = vim_strsave_escaped((char_u *)var, escape_chars);
|
||||
char_u *buf = (char_u *)vim_strsave_escaped(var, (char *)escape_chars);
|
||||
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
// For MS-Windows et al. we don't double backslashes at the start and
|
||||
|
@ -711,7 +711,7 @@ void expand_env_esc(char *restrict srcp, char *restrict dst, int dstlen, bool es
|
||||
// If "var" contains white space, escape it with a backslash.
|
||||
// Required for ":e ~/tt" when $HOME includes a space.
|
||||
if (esc && var != NULL && strpbrk(var, " \t") != NULL) {
|
||||
char *p = (char *)vim_strsave_escaped((char_u *)var, (char_u *)" \t");
|
||||
char *p = vim_strsave_escaped(var, " \t");
|
||||
|
||||
if (mustfree) {
|
||||
xfree(var);
|
||||
|
@ -1332,7 +1332,7 @@ static char *shell_xescape_xquote(const char *cmd)
|
||||
|
||||
const char *ecmd = cmd;
|
||||
if (*p_sxe != NUL && strcmp(p_sxq, "(") == 0) {
|
||||
ecmd = (char *)vim_strsave_escaped_ext((char_u *)cmd, p_sxe, '^', false);
|
||||
ecmd = vim_strsave_escaped_ext(cmd, (char *)p_sxe, '^', false);
|
||||
}
|
||||
size_t ncmd_size = strlen(ecmd) + strlen(p_sxq) * 2 + 1;
|
||||
char *ncmd = xmalloc(ncmd_size);
|
||||
|
@ -585,10 +585,10 @@ bool path_has_exp_wildcard(const char_u *p)
|
||||
/// - EW_NOERROR: Silence error messages.
|
||||
/// - EW_NOTWILD: Add matches literally.
|
||||
/// @returns the number of matches found.
|
||||
static size_t path_expand(garray_T *gap, const char_u *path, int flags)
|
||||
static size_t path_expand(garray_T *gap, const char *path, int flags)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
return do_path_expand(gap, (char *)path, 0, flags, false);
|
||||
return do_path_expand(gap, path, 0, flags, false);
|
||||
}
|
||||
|
||||
static const char *scandir_next_with_dots(Directory *dir)
|
||||
@ -790,7 +790,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in
|
||||
|
||||
// Moves "*psep" back to the previous path separator in "path".
|
||||
// Returns FAIL is "*psep" ends up at the beginning of "path".
|
||||
static int find_previous_pathsep(char_u *path, char_u **psep)
|
||||
static int find_previous_pathsep(char *path, char **psep)
|
||||
{
|
||||
// skip the current separator
|
||||
if (*psep > path && vim_ispathsep(**psep)) {
|
||||
@ -1000,7 +1000,7 @@ static void uniquefy_paths(garray_T *gap, char *pattern)
|
||||
// Here all files can be reached without path, so get shortest
|
||||
// unique path. We start at the end of the path. */
|
||||
pathsep_p = path + len - 1;
|
||||
while (find_previous_pathsep((char_u *)path, (char_u **)&pathsep_p)) {
|
||||
while (find_previous_pathsep(path, &pathsep_p)) {
|
||||
if (vim_regexec(®match, pathsep_p + 1, (colnr_T)0)
|
||||
&& is_unique(pathsep_p + 1, gap, i)
|
||||
&& path_cutoff != NULL && pathsep_p + 1 >= path_cutoff) {
|
||||
@ -1117,11 +1117,11 @@ static int expand_in_path(garray_T *const gap, char *const pattern, const int fl
|
||||
{
|
||||
garray_T path_ga;
|
||||
|
||||
char_u *const curdir = xmalloc(MAXPATHL);
|
||||
os_dirname((char *)curdir, MAXPATHL);
|
||||
char *const curdir = xmalloc(MAXPATHL);
|
||||
os_dirname(curdir, MAXPATHL);
|
||||
|
||||
ga_init(&path_ga, (int)sizeof(char_u *), 1);
|
||||
expand_path_option((char *)curdir, &path_ga);
|
||||
expand_path_option(curdir, &path_ga);
|
||||
xfree(curdir);
|
||||
if (GA_EMPTY(&path_ga)) {
|
||||
return 0;
|
||||
@ -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, (char_u *)p, flags);
|
||||
size_t tmp_add_pat = path_expand(&ga, p, flags);
|
||||
assert(tmp_add_pat <= INT_MAX);
|
||||
add_pat = (int)tmp_add_pat;
|
||||
}
|
||||
@ -1498,11 +1498,11 @@ void addfile(garray_T *gap, char *f, int flags)
|
||||
void simplify_filename(char_u *filename)
|
||||
{
|
||||
int components = 0;
|
||||
char_u *p, *tail, *start;
|
||||
char *p, *tail, *start;
|
||||
bool stripping_disabled = false;
|
||||
bool relative = true;
|
||||
|
||||
p = filename;
|
||||
p = (char *)filename;
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
if (p[0] != NUL && p[1] == ':') { // skip "x:"
|
||||
p += 2;
|
||||
@ -1521,7 +1521,7 @@ void simplify_filename(char_u *filename)
|
||||
// At this point "p" is pointing to the char following a single "/"
|
||||
// or "p" is at the "start" of the (absolute or relative) path name.
|
||||
if (vim_ispathsep(*p)) {
|
||||
STRMOVE(p, (char *)p + 1); // remove duplicate "/"
|
||||
STRMOVE(p, p + 1); // remove duplicate "/"
|
||||
} else if (p[0] == '.'
|
||||
&& (vim_ispathsep(p[1]) || p[1] == NUL)) {
|
||||
if (p == start && relative) {
|
||||
@ -1539,7 +1539,7 @@ void simplify_filename(char_u *filename)
|
||||
} else if (p > start) {
|
||||
p--; // strip preceding path separator
|
||||
}
|
||||
STRMOVE(p, (char *)tail);
|
||||
STRMOVE(p, tail);
|
||||
}
|
||||
} else if (p[0] == '.' && p[1] == '.'
|
||||
&& (vim_ispathsep(p[2]) || p[2] == NUL)) {
|
||||
@ -1551,7 +1551,7 @@ void simplify_filename(char_u *filename)
|
||||
|
||||
if (components > 0) { // strip one preceding component
|
||||
bool do_strip = false;
|
||||
char_u saved_char;
|
||||
char saved_char;
|
||||
|
||||
// Don't strip for an erroneous file name.
|
||||
if (!stripping_disabled) {
|
||||
@ -1568,7 +1568,7 @@ void simplify_filename(char_u *filename)
|
||||
|
||||
p--;
|
||||
// Skip back to after previous '/'.
|
||||
while (p > start && !after_pathsep((char *)start, (char *)p)) {
|
||||
while (p > start && !after_pathsep(start, p)) {
|
||||
MB_PTR_BACK(start, p);
|
||||
}
|
||||
|
||||
@ -1638,23 +1638,23 @@ void simplify_filename(char_u *filename)
|
||||
if (p > start && tail[-1] == '.') {
|
||||
p--;
|
||||
}
|
||||
STRMOVE(p, (char *)tail); // strip previous component
|
||||
STRMOVE(p, tail); // strip previous component
|
||||
}
|
||||
|
||||
components--;
|
||||
}
|
||||
} else if (p == start && !relative) { // leading "/.." or "/../"
|
||||
STRMOVE(p, (char *)tail); // strip ".." or "../"
|
||||
STRMOVE(p, tail); // strip ".." or "../"
|
||||
} else {
|
||||
if (p == start + 2 && p[-2] == '.') { // leading "./../"
|
||||
STRMOVE(p - 2, (char *)p); // strip leading "./"
|
||||
STRMOVE(p - 2, p); // strip leading "./"
|
||||
tail -= 2;
|
||||
}
|
||||
p = tail; // skip to char after ".." or "../"
|
||||
}
|
||||
} else {
|
||||
components++; // Simple path component.
|
||||
p = (char_u *)path_next_component((const char *)p);
|
||||
p = (char *)path_next_component(p);
|
||||
}
|
||||
} while (*p != NUL);
|
||||
}
|
||||
@ -2046,11 +2046,11 @@ int pathcmp(const char *p, const char *q, int maxlen)
|
||||
/// - NULL if `full_path` is NULL.
|
||||
char_u *path_try_shorten_fname(char_u *full_path)
|
||||
{
|
||||
char_u *dirname = xmalloc(MAXPATHL);
|
||||
char *dirname = xmalloc(MAXPATHL);
|
||||
char_u *p = full_path;
|
||||
|
||||
if (os_dirname((char *)dirname, MAXPATHL) == OK) {
|
||||
p = (char_u *)path_shorten_fname((char *)full_path, (char *)dirname);
|
||||
if (os_dirname(dirname, MAXPATHL) == OK) {
|
||||
p = (char_u *)path_shorten_fname((char *)full_path, dirname);
|
||||
if (p == NULL || *p == NUL) {
|
||||
p = full_path;
|
||||
}
|
||||
@ -2086,7 +2086,7 @@ char *path_shorten_fname(char *full_path, char *dir_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char_u *p = (char_u *)full_path + len;
|
||||
char *p = full_path + len;
|
||||
|
||||
// If *p is not pointing to a path separator, this means that full_path's
|
||||
// last directory name is longer than *dir_name's last directory, so they
|
||||
@ -2095,7 +2095,7 @@ char *path_shorten_fname(char *full_path, char *dir_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (char *)p + 1;
|
||||
return p + 1;
|
||||
}
|
||||
|
||||
/// Invoke expand_wildcards() for one pattern
|
||||
@ -2241,8 +2241,8 @@ int match_suffix(char *fname)
|
||||
|
||||
size_t fnamelen = strlen(fname);
|
||||
size_t setsuflen = 0;
|
||||
for (char_u *setsuf = p_su; *setsuf;) {
|
||||
setsuflen = copy_option_part((char **)&setsuf, (char *)suf_buf, MAXSUFLEN, ".,");
|
||||
for (char *setsuf = (char *)p_su; *setsuf;) {
|
||||
setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,");
|
||||
if (setsuflen == 0) {
|
||||
char *tail = path_tail(fname);
|
||||
|
||||
|
@ -408,8 +408,8 @@ void pum_redraw(void)
|
||||
int attr;
|
||||
int i;
|
||||
int idx;
|
||||
char_u *s;
|
||||
char_u *p = NULL;
|
||||
char *s;
|
||||
char *p = NULL;
|
||||
int totwidth, width, w;
|
||||
int thumb_pos = 0;
|
||||
int thumb_height = 1;
|
||||
@ -501,15 +501,15 @@ void pum_redraw(void)
|
||||
|
||||
switch (round) {
|
||||
case 1:
|
||||
p = pum_array[idx].pum_text;
|
||||
p = (char *)pum_array[idx].pum_text;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
p = pum_array[idx].pum_kind;
|
||||
p = (char *)pum_array[idx].pum_kind;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
p = pum_array[idx].pum_extra;
|
||||
p = (char *)pum_array[idx].pum_extra;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -518,24 +518,24 @@ void pum_redraw(void)
|
||||
if (s == NULL) {
|
||||
s = p;
|
||||
}
|
||||
w = ptr2cells((char *)p);
|
||||
w = ptr2cells(p);
|
||||
|
||||
if ((*p == NUL) || (*p == TAB) || (totwidth + w > pum_width)) {
|
||||
// Display the text that fits or comes before a Tab.
|
||||
// First convert it to printable characters.
|
||||
char_u *st;
|
||||
char_u saved = *p;
|
||||
char *st;
|
||||
char saved = *p;
|
||||
|
||||
if (saved != NUL) {
|
||||
*p = NUL;
|
||||
}
|
||||
st = (char_u *)transstr((const char *)s, true);
|
||||
st = transstr(s, true);
|
||||
if (saved != NUL) {
|
||||
*p = saved;
|
||||
}
|
||||
|
||||
if (pum_rl) {
|
||||
char *rt = reverse_text((char *)st);
|
||||
char *rt = reverse_text(st);
|
||||
char *rt_start = rt;
|
||||
int size = vim_strsize(rt);
|
||||
|
||||
@ -559,7 +559,7 @@ void pum_redraw(void)
|
||||
grid_col -= width;
|
||||
} else {
|
||||
// use grid_puts_len() to truncate the text
|
||||
grid_puts(&pum_grid, (char *)st, row, grid_col, attr);
|
||||
grid_puts(&pum_grid, st, row, grid_col, attr);
|
||||
xfree(st);
|
||||
grid_col += width;
|
||||
}
|
||||
@ -762,17 +762,17 @@ static bool pum_set_selected(int n, int repeat)
|
||||
}
|
||||
|
||||
if (res == OK) {
|
||||
char_u *p, *e;
|
||||
char *p, *e;
|
||||
linenr_T lnum = 0;
|
||||
|
||||
for (p = pum_array[pum_selected].pum_info; *p != NUL;) {
|
||||
e = (char_u *)vim_strchr((char *)p, '\n');
|
||||
for (p = (char *)pum_array[pum_selected].pum_info; *p != NUL;) {
|
||||
e = vim_strchr(p, '\n');
|
||||
if (e == NULL) {
|
||||
ml_append(lnum++, (char *)p, 0, false);
|
||||
ml_append(lnum++, p, 0, false);
|
||||
break;
|
||||
}
|
||||
*e = NUL;
|
||||
ml_append(lnum++, (char *)p, (int)(e - p + 1), false);
|
||||
ml_append(lnum++, p, (int)(e - p + 1), false);
|
||||
*e = '\n';
|
||||
p = e + 1;
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ retry:
|
||||
}
|
||||
|
||||
// Convert a line if it contains a non-ASCII character
|
||||
if (state->vc.vc_type != CONV_NONE && has_non_ascii((char_u *)state->linebuf)) {
|
||||
if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf)) {
|
||||
char *line = string_convert(&state->vc, state->linebuf, &state->linelen);
|
||||
if (line != NULL) {
|
||||
if (state->linelen < IOSIZE) {
|
||||
|
@ -1837,7 +1837,7 @@ static int vim_regsub_both(char *source, typval_T *expr, char *dest, int destlen
|
||||
}
|
||||
if (had_backslash && (flags & REGSUB_BACKSLASH)) {
|
||||
// Backslashes will be consumed, need to double them.
|
||||
s = (char *)vim_strsave_escaped((char_u *)eval_result[nested], (char_u *)"\\");
|
||||
s = vim_strsave_escaped(eval_result[nested], "\\");
|
||||
xfree(eval_result[nested]);
|
||||
eval_result[nested] = s;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ static char *mr_pattern = NULL;
|
||||
// been searched already.
|
||||
typedef struct SearchedFile {
|
||||
FILE *fp; // File pointer
|
||||
char_u *name; // Full name of file
|
||||
char *name; // Full name of file
|
||||
linenr_T lnum; // Line we were up to in file
|
||||
int matched; // Found a match in this file
|
||||
} SearchedFile;
|
||||
@ -376,17 +376,17 @@ int ignorecase_opt(char_u *pat, int ic_in, int scs)
|
||||
bool pat_has_uppercase(char_u *pat)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char_u *p = pat;
|
||||
char *p = (char *)pat;
|
||||
magic_T magic_val = MAGIC_ON;
|
||||
|
||||
// get the magicness of the pattern
|
||||
(void)skip_regexp_ex((char *)pat, NUL, magic_isset(), NULL, NULL, &magic_val);
|
||||
|
||||
while (*p != NUL) {
|
||||
const int l = utfc_ptr2len((char *)p);
|
||||
const int l = utfc_ptr2len(p);
|
||||
|
||||
if (l > 1) {
|
||||
if (mb_isupper(utf_ptr2char((char *)p))) {
|
||||
if (mb_isupper(utf_ptr2char(p))) {
|
||||
return true;
|
||||
}
|
||||
p += l;
|
||||
@ -406,7 +406,7 @@ bool pat_has_uppercase(char_u *pat)
|
||||
} else {
|
||||
p++;
|
||||
}
|
||||
} else if (mb_isupper(*p)) {
|
||||
} else if (mb_isupper((uint8_t)(*p))) {
|
||||
return true;
|
||||
} else {
|
||||
p++;
|
||||
@ -1028,7 +1028,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, long count, i
|
||||
long c;
|
||||
char *dircp;
|
||||
char *strcopy = NULL;
|
||||
char_u *ps;
|
||||
char *ps;
|
||||
char *msgbuf = NULL;
|
||||
size_t len;
|
||||
bool has_offset = false;
|
||||
@ -1102,9 +1102,9 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, long count, i
|
||||
if (pat != NULL && *pat != NUL) { // look for (new) offset
|
||||
// Find end of regular expression.
|
||||
// If there is a matching '/' or '?', toss it.
|
||||
ps = (char_u *)strcopy;
|
||||
ps = strcopy;
|
||||
p = skip_regexp_ex(pat, search_delim, magic_isset(), &strcopy, NULL, NULL);
|
||||
if (strcopy != (char *)ps) {
|
||||
if (strcopy != ps) {
|
||||
// made a copy of "pat" to change "\?" to "?"
|
||||
searchcmdlen += (int)(strlen(pat) - strlen(strcopy));
|
||||
pat = strcopy;
|
||||
@ -1603,16 +1603,16 @@ pos_T *findmatch(oparg_T *oap, int initc)
|
||||
// Update "*prevcol" to the column of the previous character, unless "prevcol"
|
||||
// is NULL.
|
||||
// Handles multibyte string correctly.
|
||||
static bool check_prevcol(char_u *linep, int col, int ch, int *prevcol)
|
||||
static bool check_prevcol(char *linep, int col, int ch, int *prevcol)
|
||||
{
|
||||
col--;
|
||||
if (col > 0) {
|
||||
col -= utf_head_off((char *)linep, (char *)linep + col);
|
||||
col -= utf_head_off(linep, linep + col);
|
||||
}
|
||||
if (prevcol) {
|
||||
*prevcol = col;
|
||||
}
|
||||
return col >= 0 && linep[col] == ch;
|
||||
return col >= 0 && (uint8_t)linep[col] == ch;
|
||||
}
|
||||
|
||||
/// Raw string start is found at linep[startpos.col - 1].
|
||||
@ -1839,7 +1839,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
|
||||
// Set "match_escaped" if there are an odd number of
|
||||
// backslashes.
|
||||
for (col = pos.col; check_prevcol((char_u *)linep, col, '\\', &col);) {
|
||||
for (col = pos.col; check_prevcol(linep, col, '\\', &col);) {
|
||||
bslcnt++;
|
||||
}
|
||||
match_escaped = (bslcnt & 1);
|
||||
@ -2192,8 +2192,8 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
if (curbuf->b_p_lisp
|
||||
&& vim_strchr("(){}[]", c) != NULL
|
||||
&& pos.col > 1
|
||||
&& check_prevcol((char_u *)linep, pos.col, '\\', NULL)
|
||||
&& check_prevcol((char_u *)linep, pos.col - 1, '#', NULL)) {
|
||||
&& check_prevcol(linep, pos.col, '\\', NULL)
|
||||
&& check_prevcol(linep, pos.col - 1, '#', NULL)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2204,7 +2204,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
int col, bslcnt = 0;
|
||||
|
||||
if (!cpo_bsl) {
|
||||
for (col = pos.col; check_prevcol((char_u *)linep, col, '\\', &col);) {
|
||||
for (col = pos.col; check_prevcol(linep, col, '\\', &col);) {
|
||||
bslcnt++;
|
||||
}
|
||||
}
|
||||
@ -2298,19 +2298,19 @@ void showmatch(int c)
|
||||
long save_siso;
|
||||
int save_state;
|
||||
colnr_T save_dollar_vcol;
|
||||
char_u *p;
|
||||
char *p;
|
||||
|
||||
// Only show match for chars in the 'matchpairs' option.
|
||||
// 'matchpairs' is "x:y,x:y"
|
||||
for (p = (char_u *)curbuf->b_p_mps; *p != NUL; p++) {
|
||||
if (utf_ptr2char((char *)p) == c && (curwin->w_p_rl ^ p_ri)) {
|
||||
for (p = curbuf->b_p_mps; *p != NUL; p++) {
|
||||
if (utf_ptr2char(p) == c && (curwin->w_p_rl ^ p_ri)) {
|
||||
break;
|
||||
}
|
||||
p += utfc_ptr2len((char *)p) + 1;
|
||||
if (utf_ptr2char((char *)p) == c && !(curwin->w_p_rl ^ p_ri)) {
|
||||
p += utfc_ptr2len(p) + 1;
|
||||
if (utf_ptr2char(p) == c && !(curwin->w_p_rl ^ p_ri)) {
|
||||
break;
|
||||
}
|
||||
p += utfc_ptr2len((char *)p);
|
||||
p += utfc_ptr2len(p);
|
||||
if (*p == NUL) {
|
||||
return;
|
||||
}
|
||||
@ -2407,8 +2407,7 @@ int current_search(long count, bool forward)
|
||||
}
|
||||
|
||||
// Is the pattern is zero-width?, this time, don't care about the direction
|
||||
int zero_width = is_zero_width((char_u *)spats[last_idx].pat, true, &curwin->w_cursor,
|
||||
FORWARD);
|
||||
int zero_width = is_zero_width(spats[last_idx].pat, true, &curwin->w_cursor, FORWARD);
|
||||
if (zero_width == -1) {
|
||||
return FAIL; // pattern not found
|
||||
}
|
||||
@ -2515,7 +2514,7 @@ int current_search(long count, bool forward)
|
||||
/// else from position "cur".
|
||||
/// "direction" is FORWARD or BACKWARD.
|
||||
/// Returns true, false or -1 for failure.
|
||||
static int is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direction)
|
||||
static int is_zero_width(char *pattern, int move, pos_T *cur, Direction direction)
|
||||
{
|
||||
regmmatch_T regmatch;
|
||||
int nmatched = 0;
|
||||
@ -2525,10 +2524,10 @@ static int is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direct
|
||||
int flag = 0;
|
||||
|
||||
if (pattern == NULL) {
|
||||
pattern = (char_u *)spats[last_idx].pat;
|
||||
pattern = spats[last_idx].pat;
|
||||
}
|
||||
|
||||
if (search_regcomp(pattern, NULL, RE_SEARCH, RE_SEARCH,
|
||||
if (search_regcomp((char_u *)pattern, NULL, RE_SEARCH, RE_SEARCH,
|
||||
SEARCH_KEEP, ®match) == FAIL) {
|
||||
return -1;
|
||||
}
|
||||
@ -2543,7 +2542,7 @@ static int is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direct
|
||||
// accept a match at the cursor position
|
||||
flag = SEARCH_START;
|
||||
}
|
||||
if (searchit(curwin, curbuf, &pos, NULL, direction, pattern, 1,
|
||||
if (searchit(curwin, curbuf, &pos, NULL, direction, (char_u *)pattern, 1,
|
||||
SEARCH_KEEP + flag, RE_SEARCH, NULL) != FAIL) {
|
||||
// Zero-width pattern should match somewhere, then we can check if
|
||||
// start and end are in the same position.
|
||||
@ -2574,9 +2573,9 @@ static int is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direct
|
||||
/// return true if line 'lnum' is empty or has white chars only.
|
||||
int linewhite(linenr_T lnum)
|
||||
{
|
||||
char_u *p;
|
||||
char *p;
|
||||
|
||||
p = (char_u *)skipwhite(ml_get(lnum));
|
||||
p = skipwhite(ml_get(lnum));
|
||||
return *p == NUL;
|
||||
}
|
||||
|
||||
@ -2753,7 +2752,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, searchst
|
||||
void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
pos_T pos = curwin->w_cursor;
|
||||
char_u *pattern = NULL;
|
||||
char *pattern = NULL;
|
||||
int maxcount = SEARCH_STAT_DEF_MAX_COUNT;
|
||||
long timeout = SEARCH_STAT_DEF_TIMEOUT;
|
||||
bool recompute = true;
|
||||
@ -2797,9 +2796,9 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
di = tv_dict_find(dict, (const char *)"pattern", -1);
|
||||
di = tv_dict_find(dict, "pattern", -1);
|
||||
if (di != NULL) {
|
||||
pattern = (char_u *)tv_get_string_chk(&di->di_tv);
|
||||
pattern = (char *)tv_get_string_chk(&di->di_tv);
|
||||
if (pattern == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -2845,7 +2844,7 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
goto the_end;
|
||||
}
|
||||
xfree(spats[last_idx].pat);
|
||||
spats[last_idx].pat = xstrdup((char *)pattern);
|
||||
spats[last_idx].pat = xstrdup(pattern);
|
||||
}
|
||||
if (spats[last_idx].pat == NULL || *spats[last_idx].pat == NUL) {
|
||||
goto the_end; // the previous pattern was never defined
|
||||
@ -2944,7 +2943,7 @@ typedef struct {
|
||||
|
||||
/// Compute a score for a fuzzy matched string. The matching character locations
|
||||
/// are in 'matches'.
|
||||
static int fuzzy_match_compute_score(const char_u *const str, const int strSz,
|
||||
static int fuzzy_match_compute_score(const char *const str, const int strSz,
|
||||
const uint32_t *const matches, const int numMatches)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
|
||||
{
|
||||
@ -2981,14 +2980,14 @@ static int fuzzy_match_compute_score(const char_u *const str, const int strSz,
|
||||
// Check for bonuses based on neighbor character value
|
||||
if (currIdx > 0) {
|
||||
// Camel case
|
||||
const char_u *p = str;
|
||||
const char *p = str;
|
||||
int neighbor = ' ';
|
||||
|
||||
for (uint32_t sidx = 0; sidx < currIdx; sidx++) {
|
||||
neighbor = utf_ptr2char((char *)p);
|
||||
neighbor = utf_ptr2char(p);
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
const int curr = utf_ptr2char((char *)p);
|
||||
const int curr = utf_ptr2char(p);
|
||||
|
||||
if (mb_islower(neighbor) && mb_isupper(curr)) {
|
||||
score += CAMEL_BONUS;
|
||||
@ -3010,11 +3009,10 @@ static int fuzzy_match_compute_score(const char_u *const str, const int strSz,
|
||||
|
||||
/// Perform a recursive search for fuzzy matching 'fuzpat' in 'str'.
|
||||
/// @return the number of matching characters.
|
||||
static int fuzzy_match_recursive(const char_u *fuzpat, const char_u *str, uint32_t strIdx,
|
||||
int *const outScore, const char_u *const strBegin,
|
||||
const int strLen, const uint32_t *const srcMatches,
|
||||
uint32_t *const matches, const int maxMatches, int nextMatch,
|
||||
int *const recursionCount)
|
||||
static int fuzzy_match_recursive(const char *fuzpat, const char *str, uint32_t strIdx,
|
||||
int *const outScore, const char *const strBegin, const int strLen,
|
||||
const uint32_t *const srcMatches, uint32_t *const matches,
|
||||
const int maxMatches, int nextMatch, int *const recursionCount)
|
||||
FUNC_ATTR_NONNULL_ARG(1, 2, 4, 5, 8, 11) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
// Recursion params
|
||||
@ -3055,7 +3053,7 @@ static int fuzzy_match_recursive(const char_u *fuzpat, const char_u *str, uint32
|
||||
// Recursive call that "skips" this match
|
||||
uint32_t recursiveMatches[MAX_FUZZY_MATCHES];
|
||||
int recursiveScore = 0;
|
||||
const char_u *const next_char = str + utfc_ptr2len((char *)str);
|
||||
const char *const next_char = (char *)str + utfc_ptr2len((char *)str);
|
||||
if (fuzzy_match_recursive(fuzpat, next_char, strIdx + 1, &recursiveScore, strBegin, strLen,
|
||||
matches, recursiveMatches,
|
||||
sizeof(recursiveMatches) / sizeof(recursiveMatches[0]), nextMatch,
|
||||
@ -3121,9 +3119,9 @@ bool fuzzy_match(char_u *const str, const char_u *const pat_arg, const bool matc
|
||||
|
||||
*outScore = 0;
|
||||
|
||||
char_u *const save_pat = (char_u *)xstrdup((char *)pat_arg);
|
||||
char_u *pat = save_pat;
|
||||
char_u *p = pat;
|
||||
char *const save_pat = xstrdup((char *)pat_arg);
|
||||
char *pat = save_pat;
|
||||
char *p = pat;
|
||||
|
||||
// Try matching each word in 'pat_arg' in 'str'
|
||||
while (true) {
|
||||
@ -3131,12 +3129,12 @@ bool fuzzy_match(char_u *const str, const char_u *const pat_arg, const bool matc
|
||||
complete = true;
|
||||
} else {
|
||||
// Extract one word from the pattern (separated by space)
|
||||
p = (char_u *)skipwhite((char *)p);
|
||||
p = skipwhite(p);
|
||||
if (*p == NUL) {
|
||||
break;
|
||||
}
|
||||
pat = p;
|
||||
while (*p != NUL && !ascii_iswhite(utf_ptr2char((char *)p))) {
|
||||
while (*p != NUL && !ascii_iswhite(utf_ptr2char(p))) {
|
||||
MB_PTR_ADV(p);
|
||||
}
|
||||
if (*p == NUL) { // processed all the words
|
||||
@ -3148,7 +3146,8 @@ bool fuzzy_match(char_u *const str, const char_u *const pat_arg, const bool matc
|
||||
int score = 0;
|
||||
int recursionCount = 0;
|
||||
const int matchCount
|
||||
= fuzzy_match_recursive(pat, str, 0, &score, str, len, NULL, matches + numMatches,
|
||||
= fuzzy_match_recursive(pat, (char *)str, 0, &score, (char *)str, len, NULL,
|
||||
matches + numMatches,
|
||||
maxMatches - numMatches, 0, &recursionCount);
|
||||
if (matchCount == 0) {
|
||||
numMatches = 0;
|
||||
@ -3193,8 +3192,8 @@ static int fuzzy_match_item_compare(const void *const s1, const void *const s2)
|
||||
/// for each item or use 'item_cb' Funcref function to get the string.
|
||||
/// If 'retmatchpos' is true, then return a list of positions where 'str'
|
||||
/// matches for each item.
|
||||
static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool matchseq,
|
||||
const char_u *const key, Callback *const item_cb,
|
||||
static void fuzzy_match_in_list(list_T *const l, char *const str, const bool matchseq,
|
||||
const char *const key, Callback *const item_cb,
|
||||
const bool retmatchpos, list_T *const fmatchlist,
|
||||
const long max_matches)
|
||||
FUNC_ATTR_NONNULL_ARG(2, 5, 7)
|
||||
@ -3217,17 +3216,17 @@ static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool m
|
||||
break;
|
||||
}
|
||||
|
||||
char_u *itemstr = NULL;
|
||||
char *itemstr = NULL;
|
||||
typval_T rettv;
|
||||
rettv.v_type = VAR_UNKNOWN;
|
||||
const typval_T *const tv = TV_LIST_ITEM_TV(li);
|
||||
if (tv->v_type == VAR_STRING) { // list of strings
|
||||
itemstr = (char_u *)tv->vval.v_string;
|
||||
itemstr = tv->vval.v_string;
|
||||
} else if (tv->v_type == VAR_DICT && (key != NULL || item_cb->type != kCallbackNone)) {
|
||||
// For a dict, either use the specified key to lookup the string or
|
||||
// use the specified callback function to get the string.
|
||||
if (key != NULL) {
|
||||
itemstr = (char_u *)tv_dict_get_string(tv->vval.v_dict, (const char *)key, false);
|
||||
itemstr = tv_dict_get_string(tv->vval.v_dict, (const char *)key, false);
|
||||
} else {
|
||||
typval_T argv[2];
|
||||
|
||||
@ -3238,7 +3237,7 @@ static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool m
|
||||
argv[1].v_type = VAR_UNKNOWN;
|
||||
if (callback_call(item_cb, 1, argv, &rettv)) {
|
||||
if (rettv.v_type == VAR_STRING) {
|
||||
itemstr = (char_u *)rettv.vval.v_string;
|
||||
itemstr = rettv.vval.v_string;
|
||||
}
|
||||
}
|
||||
tv_dict_unref(tv->vval.v_dict);
|
||||
@ -3246,7 +3245,7 @@ static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool m
|
||||
}
|
||||
|
||||
int score;
|
||||
if (itemstr != NULL && fuzzy_match(itemstr, str, matchseq, &score, matches,
|
||||
if (itemstr != NULL && fuzzy_match((char_u *)itemstr, (char_u *)str, matchseq, &score, matches,
|
||||
MAX_FUZZY_MATCHES)) {
|
||||
items[match_count].idx = (int)match_count;
|
||||
items[match_count].item = li;
|
||||
@ -3257,9 +3256,9 @@ static void fuzzy_match_in_list(list_T *const l, char_u *const str, const bool m
|
||||
if (retmatchpos) {
|
||||
items[match_count].lmatchpos = tv_list_alloc(kListLenMayKnow);
|
||||
int j = 0;
|
||||
const char_u *p = str;
|
||||
const char *p = (char *)str;
|
||||
while (*p != NUL) {
|
||||
if (!ascii_iswhite(utf_ptr2char((char *)p)) || matchseq) {
|
||||
if (!ascii_iswhite(utf_ptr2char(p)) || matchseq) {
|
||||
tv_list_append_number(items[match_count].lmatchpos, matches[j]);
|
||||
j++;
|
||||
}
|
||||
@ -3344,7 +3343,7 @@ static void do_fuzzymatch(const typval_T *const argvars, typval_T *const rettv,
|
||||
}
|
||||
|
||||
Callback cb = CALLBACK_NONE;
|
||||
const char_u *key = NULL;
|
||||
const char *key = NULL;
|
||||
bool matchseq = false;
|
||||
long max_matches = 0;
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
@ -3363,7 +3362,7 @@ static void do_fuzzymatch(const typval_T *const argvars, typval_T *const rettv,
|
||||
semsg(_(e_invarg2), tv_get_string(&di->di_tv));
|
||||
return;
|
||||
}
|
||||
key = (const char_u *)tv_get_string(&di->di_tv);
|
||||
key = tv_get_string(&di->di_tv);
|
||||
} else if (!tv_dict_get_callback(d, "text_cb", -1, &cb)) {
|
||||
semsg(_(e_invargval), "text_cb");
|
||||
return;
|
||||
@ -3394,7 +3393,8 @@ static void do_fuzzymatch(const typval_T *const argvars, typval_T *const rettv,
|
||||
tv_list_append_list(rettv->vval.v_list, tv_list_alloc(kListLenUnknown));
|
||||
}
|
||||
|
||||
fuzzy_match_in_list(argvars[0].vval.v_list, (char_u *)tv_get_string(&argvars[1]), matchseq, key,
|
||||
fuzzy_match_in_list(argvars[0].vval.v_list,
|
||||
(char *)tv_get_string(&argvars[1]), matchseq, key,
|
||||
&cb, retmatchpos, rettv->vval.v_list, max_matches);
|
||||
callback_free(&cb);
|
||||
}
|
||||
@ -3441,16 +3441,16 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
|
||||
int max_path_depth = 50;
|
||||
long match_count = 1;
|
||||
|
||||
char_u *pat;
|
||||
char_u *new_fname;
|
||||
char_u *curr_fname = (char_u *)curbuf->b_fname;
|
||||
char_u *prev_fname = NULL;
|
||||
char *pat;
|
||||
char *new_fname;
|
||||
char *curr_fname = curbuf->b_fname;
|
||||
char *prev_fname = NULL;
|
||||
linenr_T lnum;
|
||||
int depth;
|
||||
int depth_displayed; // For type==CHECK_PATH
|
||||
int old_files;
|
||||
int already_searched;
|
||||
char_u *file_line;
|
||||
char *file_line;
|
||||
char *line;
|
||||
char *p;
|
||||
char save_char;
|
||||
@ -3480,10 +3480,10 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
|
||||
size_t patlen = len + 5;
|
||||
pat = xmalloc(patlen);
|
||||
assert(len <= INT_MAX);
|
||||
snprintf((char *)pat, patlen, whole ? "\\<%.*s\\>" : "%.*s", (int)len, ptr);
|
||||
snprintf(pat, patlen, whole ? "\\<%.*s\\>" : "%.*s", (int)len, ptr);
|
||||
// ignore case according to p_ic, p_scs and pat
|
||||
regmatch.rm_ic = ignorecase(pat);
|
||||
regmatch.regprog = vim_regcomp((char *)pat, magic_isset() ? RE_MAGIC : 0);
|
||||
regmatch.rm_ic = ignorecase((char_u *)pat);
|
||||
regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0);
|
||||
xfree(pat);
|
||||
if (regmatch.regprog == NULL) {
|
||||
goto fpip_end;
|
||||
@ -3517,25 +3517,26 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
|
||||
if (lnum > end_lnum) { // do at least one line
|
||||
lnum = end_lnum;
|
||||
}
|
||||
line = get_line_and_copy(lnum, (char *)file_line);
|
||||
line = get_line_and_copy(lnum, file_line);
|
||||
|
||||
for (;;) {
|
||||
if (incl_regmatch.regprog != NULL
|
||||
&& vim_regexec(&incl_regmatch, line, (colnr_T)0)) {
|
||||
char_u *p_fname = (curr_fname == (char_u *)curbuf->b_fname)
|
||||
? (char_u *)curbuf->b_ffname : curr_fname;
|
||||
char *p_fname = (curr_fname == curbuf->b_fname)
|
||||
? curbuf->b_ffname : curr_fname;
|
||||
|
||||
if (inc_opt != NULL && strstr(inc_opt, "\\zs") != NULL) {
|
||||
// Use text from '\zs' to '\ze' (or end) of 'include'.
|
||||
new_fname = (char_u *)find_file_name_in_path(incl_regmatch.startp[0],
|
||||
(size_t)(incl_regmatch.endp[0]
|
||||
- incl_regmatch.startp[0]),
|
||||
FNAME_EXP|FNAME_INCL|FNAME_REL,
|
||||
1L, (char *)p_fname);
|
||||
new_fname = find_file_name_in_path(incl_regmatch.startp[0],
|
||||
(size_t)(incl_regmatch.endp[0]
|
||||
- incl_regmatch.startp[0]),
|
||||
FNAME_EXP|FNAME_INCL|FNAME_REL,
|
||||
1L, p_fname);
|
||||
} else {
|
||||
// Use text after match with 'include'.
|
||||
new_fname = file_name_in_line((char_u *)incl_regmatch.endp[0], 0,
|
||||
FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname, NULL);
|
||||
new_fname = (char *)file_name_in_line((char_u *)incl_regmatch.endp[0], 0,
|
||||
FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, (char_u *)p_fname,
|
||||
NULL);
|
||||
}
|
||||
already_searched = false;
|
||||
if (new_fname != NULL) {
|
||||
@ -3547,14 +3548,14 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
|
||||
if (i == max_path_depth) {
|
||||
break;
|
||||
}
|
||||
if (path_full_compare((char *)new_fname, (char *)files[i].name, true,
|
||||
if (path_full_compare(new_fname, files[i].name, true,
|
||||
true) & kEqualFiles) {
|
||||
if (type != CHECK_PATH
|
||||
&& action == ACTION_SHOW_ALL && files[i].matched) {
|
||||
msg_putchar('\n'); // cursor below last one */
|
||||
if (!got_int) { // don't display if 'q' typed at "--more--"
|
||||
// message
|
||||
msg_home_replace_hl((char *)new_fname);
|
||||
msg_home_replace_hl(new_fname);
|
||||
msg_puts(_(" (includes previously listed match)"));
|
||||
prev_fname = NULL;
|
||||
}
|
||||
@ -3584,7 +3585,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
|
||||
for (i = 0; i < depth_displayed; i++) {
|
||||
msg_puts(" ");
|
||||
}
|
||||
msg_home_replace((char *)files[depth_displayed].name);
|
||||
msg_home_replace(files[depth_displayed].name);
|
||||
msg_puts(" -->\n");
|
||||
}
|
||||
if (!got_int) { // don't display if 'q' typed
|
||||
@ -3595,7 +3596,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
|
||||
if (new_fname != NULL) {
|
||||
// using "new_fname" is more reliable, e.g., when
|
||||
// 'includeexpr' is set.
|
||||
msg_outtrans_attr((char *)new_fname, HL_ATTR(HLF_D));
|
||||
msg_outtrans_attr(new_fname, HL_ATTR(HLF_D));
|
||||
} else {
|
||||
// Isolate the file name.
|
||||
// Include the surrounding "" or <> if present.
|
||||
@ -3664,7 +3665,7 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
|
||||
xfree(files);
|
||||
files = bigger;
|
||||
}
|
||||
if ((files[depth + 1].fp = os_fopen((char *)new_fname, "r")) == NULL) {
|
||||
if ((files[depth + 1].fp = os_fopen(new_fname, "r")) == NULL) {
|
||||
xfree(new_fname);
|
||||
} else {
|
||||
if (++depth == old_files) {
|
||||
@ -3680,12 +3681,11 @@ void find_pattern_in_path(char *ptr, Direction dir, size_t len, bool whole, bool
|
||||
msg_hist_off = true; // reset in msg_trunc_attr()
|
||||
vim_snprintf(IObuff, IOSIZE,
|
||||
_("Scanning included file: %s"),
|
||||
(char *)new_fname);
|
||||
new_fname);
|
||||
msg_trunc_attr(IObuff, true, HL_ATTR(HLF_R));
|
||||
} else if (p_verbose >= 5) {
|
||||
verbose_enter();
|
||||
smsg(_("Searching included file %s"),
|
||||
(char *)new_fname);
|
||||
smsg(_("Searching included file %s"), new_fname);
|
||||
verbose_leave();
|
||||
}
|
||||
}
|
||||
@ -3794,8 +3794,8 @@ search_line:
|
||||
if (lnum >= end_lnum) {
|
||||
goto exit_matched;
|
||||
}
|
||||
line = get_line_and_copy(++lnum, (char *)file_line);
|
||||
} else if (vim_fgets(line = (char *)file_line,
|
||||
line = get_line_and_copy(++lnum, file_line);
|
||||
} else if (vim_fgets(line = file_line,
|
||||
LSIZE, files[depth].fp)) {
|
||||
goto exit_matched;
|
||||
}
|
||||
@ -3836,8 +3836,8 @@ search_line:
|
||||
}
|
||||
|
||||
const int add_r = ins_compl_add_infercase((char_u *)aux, i, p_ic,
|
||||
curr_fname == (char_u *)curbuf->b_fname
|
||||
? NULL : curr_fname,
|
||||
curr_fname == curbuf->b_fname
|
||||
? NULL : (char_u *)curr_fname,
|
||||
dir, cont_s_ipos);
|
||||
if (add_r == OK) {
|
||||
// if dir was BACKWARD then honor it just once
|
||||
@ -3856,7 +3856,7 @@ search_line:
|
||||
}
|
||||
if (!got_int) { // don't display if 'q' typed
|
||||
// at "--more--" message
|
||||
msg_home_replace_hl((char *)curr_fname);
|
||||
msg_home_replace_hl(curr_fname);
|
||||
}
|
||||
prev_fname = curr_fname;
|
||||
}
|
||||
@ -3958,13 +3958,13 @@ exit_matched:
|
||||
// end-of-file, close the file and continue in the file that included
|
||||
// it.
|
||||
while (depth >= 0 && !already
|
||||
&& vim_fgets(line = (char *)file_line, LSIZE, files[depth].fp)) {
|
||||
&& vim_fgets(line = file_line, LSIZE, files[depth].fp)) {
|
||||
fclose(files[depth].fp);
|
||||
old_files--;
|
||||
files[old_files].name = files[depth].name;
|
||||
files[old_files].matched = files[depth].matched;
|
||||
depth--;
|
||||
curr_fname = (depth == -1) ? (char_u *)curbuf->b_fname
|
||||
curr_fname = (depth == -1) ? curbuf->b_fname
|
||||
: files[depth].name;
|
||||
if (depth < depth_displayed) {
|
||||
depth_displayed = depth;
|
||||
@ -3984,7 +3984,7 @@ exit_matched:
|
||||
if (++lnum > end_lnum) {
|
||||
break;
|
||||
}
|
||||
line = get_line_and_copy(lnum, (char *)file_line);
|
||||
line = get_line_and_copy(lnum, file_line);
|
||||
}
|
||||
already = NULL;
|
||||
}
|
||||
|
@ -2478,8 +2478,8 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
||||
|
||||
// Don't use an affix entry with non-ASCII characters when
|
||||
// "spin->si_ascii" is true.
|
||||
if (!spin->si_ascii || !(has_non_ascii((char_u *)aff_entry->ae_chop)
|
||||
|| has_non_ascii((char_u *)aff_entry->ae_add))) {
|
||||
if (!spin->si_ascii || !(has_non_ascii(aff_entry->ae_chop)
|
||||
|| has_non_ascii(aff_entry->ae_add))) {
|
||||
aff_entry->ae_next = cur_aff->ah_first;
|
||||
cur_aff->ah_first = aff_entry;
|
||||
|
||||
@ -3197,7 +3197,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
||||
}
|
||||
|
||||
// Skip non-ASCII words when "spin->si_ascii" is true.
|
||||
if (spin->si_ascii && has_non_ascii(w)) {
|
||||
if (spin->si_ascii && has_non_ascii((char *)w)) {
|
||||
non_ascii++;
|
||||
xfree(pc);
|
||||
continue;
|
||||
@ -3817,7 +3817,7 @@ static int spell_read_wordfile(spellinfo_T *spin, char_u *fname)
|
||||
}
|
||||
|
||||
// Skip non-ASCII words when "spin->si_ascii" is true.
|
||||
if (spin->si_ascii && has_non_ascii((char_u *)line)) {
|
||||
if (spin->si_ascii && has_non_ascii(line)) {
|
||||
non_ascii++;
|
||||
continue;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ char *xstrnsave(const char *string, size_t len)
|
||||
|
||||
// Same as vim_strsave(), but any characters found in esc_chars are preceded
|
||||
// by a backslash.
|
||||
char_u *vim_strsave_escaped(const char_u *string, const char_u *esc_chars)
|
||||
char *vim_strsave_escaped(const char *string, const char *esc_chars)
|
||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
return vim_strsave_escaped_ext(string, esc_chars, '\\', false);
|
||||
@ -50,36 +50,36 @@ char_u *vim_strsave_escaped(const char_u *string, const char_u *esc_chars)
|
||||
// Same as vim_strsave_escaped(), but when "bsl" is true also escape
|
||||
// characters where rem_backslash() would remove the backslash.
|
||||
// Escape the characters with "cc".
|
||||
char_u *vim_strsave_escaped_ext(const char_u *string, const char_u *esc_chars, char_u cc, bool bsl)
|
||||
char *vim_strsave_escaped_ext(const char *string, const char *esc_chars, char cc, bool bsl)
|
||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
// First count the number of backslashes required.
|
||||
// Then allocate the memory and insert them.
|
||||
size_t length = 1; // count the trailing NUL
|
||||
for (const char_u *p = string; *p; p++) {
|
||||
const size_t l = (size_t)(utfc_ptr2len((char *)p));
|
||||
for (const char *p = string; *p; p++) {
|
||||
const size_t l = (size_t)(utfc_ptr2len(p));
|
||||
if (l > 1) {
|
||||
length += l; // count a multibyte char
|
||||
p += l - 1;
|
||||
continue;
|
||||
}
|
||||
if (vim_strchr((char *)esc_chars, *p) != NULL || (bsl && rem_backslash((char *)p))) {
|
||||
if (vim_strchr(esc_chars, (uint8_t)(*p)) != NULL || (bsl && rem_backslash(p))) {
|
||||
length++; // count a backslash
|
||||
}
|
||||
length++; // count an ordinary char
|
||||
}
|
||||
|
||||
char_u *escaped_string = xmalloc(length);
|
||||
char_u *p2 = escaped_string;
|
||||
for (const char_u *p = string; *p; p++) {
|
||||
const size_t l = (size_t)(utfc_ptr2len((char *)p));
|
||||
char *escaped_string = xmalloc(length);
|
||||
char *p2 = escaped_string;
|
||||
for (const char *p = string; *p; p++) {
|
||||
const size_t l = (size_t)(utfc_ptr2len(p));
|
||||
if (l > 1) {
|
||||
memcpy(p2, p, l);
|
||||
p2 += l;
|
||||
p += l - 1; // skip multibyte char
|
||||
continue;
|
||||
}
|
||||
if (vim_strchr((char *)esc_chars, *p) != NULL || (bsl && rem_backslash((char *)p))) {
|
||||
if (vim_strchr(esc_chars, (uint8_t)(*p)) != NULL || (bsl && rem_backslash(p))) {
|
||||
*p2++ = cc;
|
||||
}
|
||||
*p2++ = *p;
|
||||
@ -150,7 +150,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
|
||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *d;
|
||||
char_u *escaped_string;
|
||||
char *escaped_string;
|
||||
size_t l;
|
||||
int csh_like;
|
||||
bool fish_like;
|
||||
@ -196,7 +196,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
|
||||
|
||||
// Allocate memory for the result and fill it.
|
||||
escaped_string = xmalloc(length);
|
||||
d = (char *)escaped_string;
|
||||
d = escaped_string;
|
||||
|
||||
// add opening quote
|
||||
#ifdef MSWIN
|
||||
@ -206,7 +206,7 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
|
||||
#endif
|
||||
*d++ = '\'';
|
||||
|
||||
for (const char *p = (char *)string; *p != NUL;) {
|
||||
for (const char *p = string; *p != NUL;) {
|
||||
#ifdef MSWIN
|
||||
if (!p_ssl) {
|
||||
if (*p == '"') {
|
||||
@ -259,19 +259,19 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
|
||||
*d++ = '\'';
|
||||
*d = NUL;
|
||||
|
||||
return (char *)escaped_string;
|
||||
return escaped_string;
|
||||
}
|
||||
|
||||
// Like vim_strsave(), but make all characters uppercase.
|
||||
// This uses ASCII lower-to-upper case translation, language independent.
|
||||
char_u *vim_strsave_up(const char_u *string)
|
||||
char *vim_strsave_up(const char *string)
|
||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *p1;
|
||||
|
||||
p1 = xstrdup((char *)string);
|
||||
p1 = xstrdup(string);
|
||||
vim_strup((char_u *)p1);
|
||||
return (char_u *)p1;
|
||||
return p1;
|
||||
}
|
||||
|
||||
/// Like xstrnsave(), but make all characters uppercase.
|
||||
@ -452,14 +452,14 @@ void sort_strings(char **files, int count)
|
||||
|
||||
// Return true if string "s" contains a non-ASCII character (128 or higher).
|
||||
// When "s" is NULL false is returned.
|
||||
bool has_non_ascii(const char_u *s)
|
||||
bool has_non_ascii(const char *s)
|
||||
FUNC_ATTR_PURE
|
||||
{
|
||||
const char_u *p;
|
||||
const char *p;
|
||||
|
||||
if (s != NULL) {
|
||||
for (p = s; *p != NUL; p++) {
|
||||
if (*p >= 128) {
|
||||
if ((uint8_t)(*p) >= 128) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -946,18 +946,18 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, t
|
||||
- str_arg);
|
||||
}
|
||||
if (fmt_spec == 'S') {
|
||||
char_u *p1;
|
||||
char *p1;
|
||||
size_t i;
|
||||
|
||||
for (i = 0, p1 = (char_u *)str_arg; *p1; p1 += utfc_ptr2len((char *)p1)) {
|
||||
size_t cell = (size_t)utf_ptr2cells((char *)p1);
|
||||
for (i = 0, p1 = (char *)str_arg; *p1; p1 += utfc_ptr2len(p1)) {
|
||||
size_t cell = (size_t)utf_ptr2cells(p1);
|
||||
if (precision_specified && i + cell > precision) {
|
||||
break;
|
||||
}
|
||||
i += cell;
|
||||
}
|
||||
|
||||
str_arg_l = (size_t)(p1 - (char_u *)str_arg);
|
||||
str_arg_l = (size_t)(p1 - str_arg);
|
||||
if (min_field_width != 0) {
|
||||
min_field_width += str_arg_l - i;
|
||||
}
|
||||
|
@ -4573,7 +4573,7 @@ static void syn_combine_list(int16_t **const clstr1, int16_t **const clstr2, con
|
||||
static int syn_scl_name2id(char *name)
|
||||
{
|
||||
// Avoid using stricmp() too much, it's slow on some systems
|
||||
char *name_u = (char *)vim_strsave_up((char_u *)name);
|
||||
char *name_u = vim_strsave_up(name);
|
||||
int i;
|
||||
for (i = curwin->w_s->b_syn_clusters.ga_len; --i >= 0;) {
|
||||
if (SYN_CLSTR(curwin->w_s)[i].scl_name_u != NULL
|
||||
@ -4635,7 +4635,7 @@ static int syn_add_cluster(char *name)
|
||||
&curwin->w_s->b_syn_clusters);
|
||||
CLEAR_POINTER(scp);
|
||||
scp->scl_name = (char_u *)name;
|
||||
scp->scl_name_u = (char *)vim_strsave_up((char_u *)name);
|
||||
scp->scl_name_u = vim_strsave_up(name);
|
||||
scp->scl_list = NULL;
|
||||
|
||||
if (STRICMP(name, "Spell") == 0) {
|
||||
@ -5304,7 +5304,7 @@ void ex_ownsyntax(exarg_T *eap)
|
||||
}
|
||||
|
||||
// Save value of b:current_syntax.
|
||||
old_value = (char *)get_var_value("b:current_syntax");
|
||||
old_value = get_var_value("b:current_syntax");
|
||||
if (old_value != NULL) {
|
||||
old_value = xstrdup(old_value);
|
||||
}
|
||||
@ -5313,7 +5313,7 @@ void ex_ownsyntax(exarg_T *eap)
|
||||
apply_autocmds(EVENT_SYNTAX, eap->arg, curbuf->b_fname, true, curbuf);
|
||||
|
||||
// Move value of b:current_syntax to w:current_syntax.
|
||||
new_value = (char *)get_var_value("b:current_syntax");
|
||||
new_value = get_var_value("b:current_syntax");
|
||||
if (new_value != NULL) {
|
||||
set_internal_string_var("w:current_syntax", new_value);
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1);
|
||||
|
||||
// Jump to the desired match.
|
||||
i = jumpto_tag((char_u *)matches[cur_match], forceit, true);
|
||||
i = jumpto_tag(matches[cur_match], forceit, true);
|
||||
|
||||
set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);
|
||||
|
||||
@ -984,7 +984,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches)
|
||||
list_T *list;
|
||||
char tag_name[128 + 1];
|
||||
char *fname;
|
||||
char_u *cmd;
|
||||
char *cmd;
|
||||
int i;
|
||||
char *p;
|
||||
tagptrs_T tagp;
|
||||
@ -1071,7 +1071,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches)
|
||||
if (cmd_len > (CMDBUFFSIZE - 5)) {
|
||||
cmd_len = CMDBUFFSIZE - 5;
|
||||
}
|
||||
snprintf((char *)cmd + len, (size_t)(CMDBUFFSIZE + 1 - len),
|
||||
snprintf(cmd + len, (size_t)(CMDBUFFSIZE + 1 - len),
|
||||
"%.*s", cmd_len, cmd_start);
|
||||
len += cmd_len;
|
||||
|
||||
@ -1093,7 +1093,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches)
|
||||
tv_dict_add_str(dict, S_LEN("filename"), (const char *)fname);
|
||||
tv_dict_add_nr(dict, S_LEN("lnum"), lnum);
|
||||
if (lnum == 0) {
|
||||
tv_dict_add_str(dict, S_LEN("pattern"), (const char *)cmd);
|
||||
tv_dict_add_str(dict, S_LEN("pattern"), cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2018,7 +2018,7 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_
|
||||
*tagpp->tagname_end = TAB;
|
||||
} else if (name_only) {
|
||||
if (st->get_searchpat) {
|
||||
char_u *temp_end = (char_u *)tagpp->command;
|
||||
char *temp_end = tagpp->command;
|
||||
|
||||
if (*temp_end == '/') {
|
||||
while (*temp_end && *temp_end != '\r'
|
||||
@ -2028,8 +2028,8 @@ static void findtags_add_match(findtags_state_T *st, tagptrs_T *tagpp, findtags_
|
||||
}
|
||||
}
|
||||
|
||||
if (tagpp->command + 2 < (char *)temp_end) {
|
||||
len = (size_t)(temp_end - (char_u *)tagpp->command - 2);
|
||||
if (tagpp->command + 2 < temp_end) {
|
||||
len = (size_t)(temp_end - tagpp->command - 2);
|
||||
mfp = xmalloc(len + 2);
|
||||
xstrlcpy(mfp, tagpp->command + 2, len + 1);
|
||||
} else {
|
||||
@ -2807,7 +2807,7 @@ static char *tag_full_fname(tagptrs_T *tagp)
|
||||
/// @param keep_help keep help flag
|
||||
///
|
||||
/// @return OK for success, NOTAGFILE when file not found, FAIL otherwise.
|
||||
static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
|
||||
static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help)
|
||||
{
|
||||
bool save_p_ws;
|
||||
int save_p_scs, save_p_ic;
|
||||
@ -2815,24 +2815,24 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
|
||||
char *str;
|
||||
char *pbuf; // search pattern buffer
|
||||
char *pbuf_end;
|
||||
char_u *tofree_fname = NULL;
|
||||
char *tofree_fname = NULL;
|
||||
char *fname;
|
||||
tagptrs_T tagp;
|
||||
int retval = FAIL;
|
||||
int getfile_result = GETFILE_UNUSED;
|
||||
int search_options;
|
||||
win_T *curwin_save = NULL;
|
||||
char_u *full_fname = NULL;
|
||||
char *full_fname = NULL;
|
||||
const bool old_KeyTyped = KeyTyped; // getting the file may reset it
|
||||
const int l_g_do_tagpreview = g_do_tagpreview;
|
||||
const size_t len = matching_line_len((char *)lbuf_arg) + 1;
|
||||
char_u *lbuf = xmalloc(len);
|
||||
const size_t len = matching_line_len(lbuf_arg) + 1;
|
||||
char *lbuf = xmalloc(len);
|
||||
memmove(lbuf, lbuf_arg, len);
|
||||
|
||||
pbuf = xmalloc(LSIZE);
|
||||
|
||||
// parse the match line into the tagp structure
|
||||
if (parse_match((char *)lbuf, &tagp) == FAIL) {
|
||||
if (parse_match(lbuf, &tagp) == FAIL) {
|
||||
tagp.fname_end = NULL;
|
||||
goto erret;
|
||||
}
|
||||
@ -2863,7 +2863,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
|
||||
// Expand file name, when needed (for environment variables).
|
||||
// If 'tagrelative' option set, may change file name.
|
||||
fname = expand_tag_fname(fname, tagp.tag_fname, true);
|
||||
tofree_fname = (char_u *)fname; // free() it later
|
||||
tofree_fname = fname; // free() it later
|
||||
|
||||
// Check if the file with the tag exists before abandoning the current
|
||||
// file. Also accept a file name for which there is a matching BufReadCmd
|
||||
@ -2886,8 +2886,8 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
|
||||
// entering it (autocommands) so turn the tag filename
|
||||
// into a fullpath
|
||||
if (!curwin->w_p_pvw) {
|
||||
full_fname = (char_u *)FullName_save(fname, false);
|
||||
fname = (char *)full_fname;
|
||||
full_fname = FullName_save(fname, false);
|
||||
fname = full_fname;
|
||||
|
||||
// Make the preview window the current window.
|
||||
// Open a preview window when needed.
|
||||
|
@ -237,9 +237,9 @@ bool findpar(bool *pincl, int dir, long count, int what, bool both)
|
||||
}
|
||||
|
||||
/// check if the string 's' is a nroff macro that is in option 'opt'
|
||||
static bool inmacro(char_u *opt, const char_u *s)
|
||||
static bool inmacro(char *opt, const char *s)
|
||||
{
|
||||
char_u *macro;
|
||||
char *macro;
|
||||
|
||||
for (macro = opt; macro[0]; macro++) {
|
||||
// Accept two characters in the option being equal to two characters
|
||||
@ -266,14 +266,14 @@ static bool inmacro(char_u *opt, const char_u *s)
|
||||
/// If 'both' is true also stop at '}'
|
||||
bool startPS(linenr_T lnum, int para, bool both)
|
||||
{
|
||||
char_u *s;
|
||||
char *s;
|
||||
|
||||
s = (char_u *)ml_get(lnum);
|
||||
if (*s == para || *s == '\f' || (both && *s == '}')) {
|
||||
s = ml_get(lnum);
|
||||
if ((uint8_t)(*s) == para || *s == '\f' || (both && *s == '}')) {
|
||||
return true;
|
||||
}
|
||||
if (*s == '.' && (inmacro((char_u *)p_sections, s + 1)
|
||||
|| (!para && inmacro(p_para, s + 1)))) {
|
||||
if (*s == '.' && (inmacro(p_sections, s + 1)
|
||||
|| (!para && inmacro((char *)p_para, s + 1)))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1040,8 +1040,8 @@ int current_block(oparg_T *oap, long count, bool include, int what, int other)
|
||||
/// @return true if the cursor is on a "<aaa>" tag. Ignore "<aaa/>".
|
||||
static bool in_html_tag(bool end_tag)
|
||||
{
|
||||
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||
char_u *p;
|
||||
char *line = get_cursor_line_ptr();
|
||||
char *p;
|
||||
int c;
|
||||
int lc = NUL;
|
||||
pos_T pos;
|
||||
@ -1097,8 +1097,8 @@ int current_tagblock(oparg_T *oap, long count_arg, bool include)
|
||||
pos_T start_pos;
|
||||
pos_T end_pos;
|
||||
pos_T old_start, old_end;
|
||||
char_u *p;
|
||||
char_u *cp;
|
||||
char *p;
|
||||
char *cp;
|
||||
int len;
|
||||
bool do_include = include;
|
||||
bool save_p_ws = p_ws;
|
||||
@ -1165,7 +1165,7 @@ again:
|
||||
|
||||
// Search for matching "</aaa>". First isolate the "aaa".
|
||||
inc_cursor();
|
||||
p = (char_u *)get_cursor_pos_ptr();
|
||||
p = get_cursor_pos_ptr();
|
||||
for (cp = p;
|
||||
*cp != NUL && *cp != '>' && !ascii_iswhite(*cp);
|
||||
MB_PTR_ADV(cp)) {}
|
||||
@ -1204,7 +1204,7 @@ again:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char_u *c = (char_u *)get_cursor_pos_ptr();
|
||||
char *c = get_cursor_pos_ptr();
|
||||
// Exclude the '<' of the end tag.
|
||||
// If the closing tag is on new line, do not decrement cursor, but make
|
||||
// operation exclusive, so that the linefeed will be selected
|
||||
@ -1441,15 +1441,15 @@ extend:
|
||||
/// @param escape escape characters, can be NULL
|
||||
///
|
||||
/// @return column number of "quotechar" or -1 when not found.
|
||||
static int find_next_quote(char_u *line, int col, int quotechar, char_u *escape)
|
||||
static int find_next_quote(char *line, int col, int quotechar, char *escape)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (;;) {
|
||||
c = line[col];
|
||||
c = (uint8_t)line[col];
|
||||
if (c == NUL) {
|
||||
return -1;
|
||||
} else if (escape != NULL && vim_strchr((char *)escape, c)) {
|
||||
} else if (escape != NULL && vim_strchr(escape, c)) {
|
||||
col++;
|
||||
if (line[col] == NUL) {
|
||||
return -1;
|
||||
@ -1457,7 +1457,7 @@ static int find_next_quote(char_u *line, int col, int quotechar, char_u *escape)
|
||||
} else if (c == quotechar) {
|
||||
break;
|
||||
}
|
||||
col += utfc_ptr2len((char *)line + col);
|
||||
col += utfc_ptr2len(line + col);
|
||||
}
|
||||
return col;
|
||||
}
|
||||
@ -1469,23 +1469,23 @@ static int find_next_quote(char_u *line, int col, int quotechar, char_u *escape)
|
||||
/// @param escape escape characters, can be NULL
|
||||
///
|
||||
/// @return the found column or zero.
|
||||
static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *escape)
|
||||
static int find_prev_quote(char *line, int col_start, int quotechar, char *escape)
|
||||
{
|
||||
int n;
|
||||
|
||||
while (col_start > 0) {
|
||||
col_start--;
|
||||
col_start -= utf_head_off((char *)line, (char *)line + col_start);
|
||||
col_start -= utf_head_off(line, line + col_start);
|
||||
n = 0;
|
||||
if (escape != NULL) {
|
||||
while (col_start - n > 0 && vim_strchr((char *)escape,
|
||||
line[col_start - n - 1]) != NULL) {
|
||||
while (col_start - n > 0 && vim_strchr(escape,
|
||||
(uint8_t)line[col_start - n - 1]) != NULL) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
if (n & 1) {
|
||||
col_start -= n; // uneven number of escape chars, skip it
|
||||
} else if (line[col_start] == quotechar) {
|
||||
} else if ((uint8_t)line[col_start] == quotechar) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1501,7 +1501,7 @@ static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *e
|
||||
bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||
char *line = get_cursor_line_ptr();
|
||||
int col_end;
|
||||
int col_start = curwin->w_cursor.col;
|
||||
bool inclusive = false;
|
||||
@ -1550,16 +1550,16 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
// quotes.
|
||||
if (vis_bef_curs) {
|
||||
inside_quotes = VIsual.col > 0
|
||||
&& line[VIsual.col - 1] == quotechar
|
||||
&& (uint8_t)line[VIsual.col - 1] == quotechar
|
||||
&& line[curwin->w_cursor.col] != NUL
|
||||
&& line[curwin->w_cursor.col + 1] == quotechar;
|
||||
&& (uint8_t)line[curwin->w_cursor.col + 1] == quotechar;
|
||||
i = VIsual.col;
|
||||
col_end = curwin->w_cursor.col;
|
||||
} else {
|
||||
inside_quotes = curwin->w_cursor.col > 0
|
||||
&& line[curwin->w_cursor.col - 1] == quotechar
|
||||
&& (uint8_t)line[curwin->w_cursor.col - 1] == quotechar
|
||||
&& line[VIsual.col] != NUL
|
||||
&& line[VIsual.col + 1] == quotechar;
|
||||
&& (uint8_t)line[VIsual.col + 1] == quotechar;
|
||||
i = curwin->w_cursor.col;
|
||||
col_end = VIsual.col;
|
||||
}
|
||||
@ -1571,14 +1571,14 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
if (line[i] == NUL) {
|
||||
break;
|
||||
}
|
||||
if (line[i++] == quotechar) {
|
||||
if ((uint8_t)line[i++] == quotechar) {
|
||||
selected_quote = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!vis_empty && line[col_start] == quotechar) {
|
||||
if (!vis_empty && (uint8_t)line[col_start] == quotechar) {
|
||||
// Already selecting something and on a quote character. Find the
|
||||
// next quoted string.
|
||||
if (vis_bef_curs) {
|
||||
@ -1588,7 +1588,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
if (col_start < 0) {
|
||||
goto abort_search;
|
||||
}
|
||||
col_end = find_next_quote(line, col_start + 1, quotechar, (char_u *)curbuf->b_p_qe);
|
||||
col_end = find_next_quote(line, col_start + 1, quotechar, curbuf->b_p_qe);
|
||||
if (col_end < 0) {
|
||||
// We were on a starting quote perhaps?
|
||||
col_end = col_start;
|
||||
@ -1596,17 +1596,17 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
}
|
||||
} else {
|
||||
col_end = find_prev_quote(line, col_start, quotechar, NULL);
|
||||
if (line[col_end] != quotechar) {
|
||||
if ((uint8_t)line[col_end] != quotechar) {
|
||||
goto abort_search;
|
||||
}
|
||||
col_start = find_prev_quote(line, col_end, quotechar, (char_u *)curbuf->b_p_qe);
|
||||
if (line[col_start] != quotechar) {
|
||||
col_start = find_prev_quote(line, col_end, quotechar, curbuf->b_p_qe);
|
||||
if ((uint8_t)line[col_start] != quotechar) {
|
||||
// We were on an ending quote perhaps?
|
||||
col_start = col_end;
|
||||
col_end = curwin->w_cursor.col;
|
||||
}
|
||||
}
|
||||
} else if (line[col_start] == quotechar || !vis_empty) {
|
||||
} else if ((uint8_t)line[col_start] == quotechar || !vis_empty) {
|
||||
int first_col = col_start;
|
||||
|
||||
if (!vis_empty) {
|
||||
@ -1628,7 +1628,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
goto abort_search;
|
||||
}
|
||||
// Find close quote character.
|
||||
col_end = find_next_quote(line, col_start + 1, quotechar, (char_u *)curbuf->b_p_qe);
|
||||
col_end = find_next_quote(line, col_start + 1, quotechar, curbuf->b_p_qe);
|
||||
if (col_end < 0) {
|
||||
goto abort_search;
|
||||
}
|
||||
@ -1641,8 +1641,8 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
}
|
||||
} else {
|
||||
// Search backward for a starting quote.
|
||||
col_start = find_prev_quote(line, col_start, quotechar, (char_u *)curbuf->b_p_qe);
|
||||
if (line[col_start] != quotechar) {
|
||||
col_start = find_prev_quote(line, col_start, quotechar, curbuf->b_p_qe);
|
||||
if ((uint8_t)line[col_start] != quotechar) {
|
||||
// No quote before the cursor, look after the cursor.
|
||||
col_start = find_next_quote(line, col_start, quotechar, NULL);
|
||||
if (col_start < 0) {
|
||||
@ -1651,7 +1651,7 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
}
|
||||
|
||||
// Find close quote character.
|
||||
col_end = find_next_quote(line, col_start + 1, quotechar, (char_u *)curbuf->b_p_qe);
|
||||
col_end = find_next_quote(line, col_start + 1, quotechar, curbuf->b_p_qe);
|
||||
if (col_end < 0) {
|
||||
goto abort_search;
|
||||
}
|
||||
@ -1685,9 +1685,9 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
|| (vis_bef_curs
|
||||
&& !selected_quote
|
||||
&& (inside_quotes
|
||||
|| (line[VIsual.col] != quotechar
|
||||
|| ((uint8_t)line[VIsual.col] != quotechar
|
||||
&& (VIsual.col == 0
|
||||
|| line[VIsual.col - 1] != quotechar))))) {
|
||||
|| (uint8_t)line[VIsual.col - 1] != quotechar))))) {
|
||||
VIsual = curwin->w_cursor;
|
||||
redraw_curbuf_later(UPD_INVERTED);
|
||||
}
|
||||
@ -1715,9 +1715,9 @@ bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||
// quote.
|
||||
if (inside_quotes
|
||||
|| (!selected_quote
|
||||
&& line[VIsual.col] != quotechar
|
||||
&& (uint8_t)line[VIsual.col] != quotechar
|
||||
&& (line[VIsual.col] == NUL
|
||||
|| line[VIsual.col + 1] != quotechar))) {
|
||||
|| (uint8_t)line[VIsual.col + 1] != quotechar))) {
|
||||
dec_cursor();
|
||||
VIsual = curwin->w_cursor;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user