Merge pull request #19592 from dundargoc/refactor/char_u-to-char

refactor: replace char_u with char
This commit is contained in:
bfredl 2022-08-12 14:44:28 +02:00 committed by GitHub
commit 54a165d9a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 499 additions and 537 deletions

View File

@ -583,7 +583,7 @@ void ex_history(exarg_T *eap)
int hisidx2 = -1;
int idx;
int i, j, k;
char_u *end;
char *end;
char_u *arg = (char_u *)eap->arg;
if (hislen == 0) {
@ -592,14 +592,14 @@ void ex_history(exarg_T *eap)
}
if (!(ascii_isdigit(*arg) || *arg == '-' || *arg == ',')) {
end = arg;
end = (char *)arg;
while (ASCII_ISALPHA(*end)
|| vim_strchr(":=@>/?", *end) != NULL) {
end++;
}
histype1 = get_histtype((const char *)arg, (size_t)(end - arg), false);
histype1 = get_histtype((const char *)arg, (size_t)(end - (char *)arg), false);
if (histype1 == HIST_INVALID) {
if (STRNICMP(arg, "all", end - arg) == 0) {
if (STRNICMP(arg, "all", end - (char *)arg) == 0) {
histype1 = 0;
histype2 = HIST_COUNT - 1;
} else {
@ -610,7 +610,7 @@ void ex_history(exarg_T *eap)
histype2 = histype1;
}
} else {
end = arg;
end = (char *)arg;
}
if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) {
semsg(_(e_trailing_arg), end);

View File

@ -2143,14 +2143,14 @@ int diffopt_changed(void)
long diff_algorithm_new = 0;
long diff_indent_heuristic = 0;
char_u *p = p_dip;
char *p = (char *)p_dip;
while (*p != NUL) {
if (STRNCMP(p, "filler", 6) == 0) {
p += 6;
diff_flags_new |= DIFF_FILLER;
} else if ((STRNCMP(p, "context:", 8) == 0) && ascii_isdigit(p[8])) {
p += 8;
diff_context_new = getdigits_int((char **)&p, false, diff_context_new);
diff_context_new = getdigits_int(&p, false, diff_context_new);
} else if (STRNCMP(p, "iblank", 6) == 0) {
p += 6;
diff_flags_new |= DIFF_IBLANK;
@ -2174,7 +2174,7 @@ int diffopt_changed(void)
diff_flags_new |= DIFF_VERTICAL;
} else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) {
p += 11;
diff_foldcolumn_new = getdigits_int((char **)&p, false, diff_foldcolumn_new);
diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new);
} else if (STRNCMP(p, "hiddenoff", 9) == 0) {
p += 9;
diff_flags_new |= DIFF_HIDDEN_OFF;

View File

@ -2022,7 +2022,7 @@ static void insert_special(int c, int allow_modmask, int ctrlv)
/// @param second_indent indent for second line if >= 0
void insertchar(int c, int flags, int second_indent)
{
char_u *p;
char *p;
int force_format = flags & INSCHAR_FORMAT;
const int textwidth = comp_textwidth(force_format);
@ -2081,13 +2081,13 @@ void insertchar(int c, int flags, int second_indent)
// Need to remove existing (middle) comment leader and insert end
// comment leader. First, check what comment leader we can find.
char_u *line = get_cursor_line_ptr();
int i = get_leader_len((char *)line, (char **)&p, false, true);
if (i > 0 && vim_strchr((char *)p, COM_MIDDLE) != NULL) { // Just checking
int i = get_leader_len((char *)line, &p, false, true);
if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) { // Just checking
// Skip middle-comment string
while (*p && p[-1] != ':') { // find end of middle flags
p++;
}
int middle_len = (int)copy_option_part((char **)&p, (char *)lead_end, COM_MAX_LEN, ",");
int middle_len = (int)copy_option_part(&p, (char *)lead_end, COM_MAX_LEN, ",");
// Don't count trailing white space for middle_len
while (middle_len > 0 && ascii_iswhite(lead_end[middle_len - 1])) {
middle_len--;
@ -2097,7 +2097,7 @@ void insertchar(int c, int flags, int second_indent)
while (*p && p[-1] != ':') { // find end of end flags
p++;
}
int end_len = (int)copy_option_part((char **)&p, (char *)lead_end, COM_MAX_LEN, ",");
int end_len = (int)copy_option_part(&p, (char *)lead_end, COM_MAX_LEN, ",");
// Skip white space before the cursor
i = curwin->w_cursor.col;

View File

@ -2258,7 +2258,7 @@ static int eval_func(char **const arg, char *const name, const int name_len, typ
funcexe.evaluate = evaluate;
funcexe.partial = partial;
funcexe.basetv = basetv;
int ret = get_func_tv((char_u *)s, len, rettv, (char_u **)arg, &funcexe);
int ret = get_func_tv((char_u *)s, len, rettv, arg, &funcexe);
xfree(s);
@ -3114,7 +3114,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string)
// Lambda: {arg, arg -> expr}
// Dictionary: {'key': val, 'key': val}
case '{':
ret = get_lambda_tv((char_u **)arg, rettv, evaluate);
ret = get_lambda_tv(arg, rettv, evaluate);
if (ret == NOTDONE) {
ret = dict_get_tv(arg, rettv, evaluate, false);
}
@ -3292,7 +3292,7 @@ static int call_func_rettv(char **const arg, typval_T *const rettv, const bool e
funcexe.selfdict = selfdict;
funcexe.basetv = basetv;
const int ret = get_func_tv((char_u *)funcname, is_lua ? (int)(*arg - funcname) : -1, rettv,
(char_u **)arg, &funcexe);
arg, &funcexe);
// Clear the funcref afterwards, so that deleting it while
// evaluating the arguments is possible (see test55).
@ -3320,7 +3320,7 @@ static int eval_lambda(char **const arg, typval_T *const rettv, const bool evalu
typval_T base = *rettv;
rettv->v_type = VAR_UNKNOWN;
int ret = get_lambda_tv((char_u **)arg, rettv, evaluate);
int ret = get_lambda_tv(arg, rettv, evaluate);
if (ret != OK) {
return FAIL;
} else if (**arg != '(') {
@ -3924,11 +3924,11 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
FALLTHROUGH;
default:
mb_copy_char((const char_u **)&p, (char_u **)&name);
mb_copy_char((const char **)&p, &name);
break;
}
} else {
mb_copy_char((const char_u **)&p, (char_u **)&name);
mb_copy_char((const char **)&p, &name);
}
}
*name = NUL;
@ -3987,7 +3987,7 @@ static int get_lit_string_tv(char **arg, typval_T *rettv, int evaluate)
}
++p;
}
mb_copy_char((const char_u **)&p, (char_u **)&str);
mb_copy_char((const char **)&p, &str);
}
*str = NUL;
*arg = p + 1;
@ -5092,7 +5092,7 @@ void common_function(typval_T *argvars, typval_T *rettv, bool is_funcref, FunPtr
if ((use_string && vim_strchr(s, AUTOLOAD_CHAR) == NULL) || is_funcref) {
name = s;
trans_name = (char *)trans_function_name((char_u **)&name, false,
trans_name = (char *)trans_function_name(&name, false,
TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD
| TFN_NO_DEREF, NULL, NULL);
if (*name != NUL) {

View File

@ -2557,7 +2557,7 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr)
foldinfo_T info = fold_info(curwin, lnum);
if (info.fi_lines > 0) {
text = get_foldtext(curwin, lnum, lnum + (linenr_T)info.fi_lines - 1, info, buf);
text = get_foldtext(curwin, lnum, lnum + info.fi_lines - 1, info, buf);
if (text == buf) {
text = vim_strsave(text);
}
@ -3967,7 +3967,7 @@ static void f_globpath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (file != NULL && !error) {
garray_T ga;
ga_init(&ga, (int)sizeof(char_u *), 10);
globpath((char_u *)tv_get_string(&argvars[0]), (char_u *)file, &ga, flags);
globpath((char *)tv_get_string(&argvars[0]), (char_u *)file, &ga, flags);
if (rettv->v_type == VAR_STRING) {
rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n");
@ -8266,10 +8266,10 @@ static void f_setqflist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
/// Translate a register type string to the yank type and block length
static int get_yank_type(char_u **const pp, MotionType *const yank_type, long *const block_len)
static int get_yank_type(char **const pp, MotionType *const yank_type, long *const block_len)
FUNC_ATTR_NONNULL_ALL
{
char *stropt = (char *)(*pp);
char *stropt = *pp;
switch (*stropt) {
case 'v':
case 'c': // character-wise selection
@ -8291,7 +8291,7 @@ static int get_yank_type(char_u **const pp, MotionType *const yank_type, long *c
default:
return FAIL;
}
*pp = (char_u *)stropt;
*pp = stropt;
return OK;
}
@ -8323,7 +8323,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (tv_dict_len(d) == 0) {
// Empty dict, clear the register (like setreg(0, []))
char_u *lstval[2] = { NULL, NULL };
char *lstval[2] = { NULL, NULL };
write_reg_contents_lst(regname, lstval, false, kMTUnknown, -1);
return;
}
@ -8335,7 +8335,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
const char *stropt = tv_dict_get_string(d, "regtype", false);
if (stropt != NULL) {
const int ret = get_yank_type((char_u **)&stropt, &yank_type, &block_len);
const int ret = get_yank_type((char **)&stropt, &yank_type, &block_len);
if (ret == FAIL || *(++stropt) != NUL) {
semsg(_(e_invargval), "value");
@ -8378,7 +8378,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
set_unnamed = true;
break;
default:
get_yank_type((char_u **)&stropt, &yank_type, &block_len);
get_yank_type((char **)&stropt, &yank_type, &block_len);
}
}
}
@ -8412,7 +8412,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
});
*curval++ = NULL;
write_reg_contents_lst(regname, (char_u **)lstval, append, yank_type, (colnr_T)block_len);
write_reg_contents_lst(regname, lstval, append, yank_type, (colnr_T)block_len);
free_lstval:
while (curallocval > allocval) {
@ -9632,20 +9632,20 @@ static int get_winnr(tabpage_T *tp, typval_T *argvar)
}
} else {
// Extract the window count (if specified). e.g. winnr('3j')
char_u *endp;
long count = strtol((char *)arg, (char **)&endp, 10);
char *endp;
long count = strtol((char *)arg, &endp, 10);
if (count <= 0) {
// if count is not specified, default to 1
count = 1;
}
if (endp != NULL && *endp != '\0') {
if (strequal((char *)endp, "j")) {
if (strequal(endp, "j")) {
twin = win_vert_neighbor(tp, twin, false, count);
} else if (strequal((char *)endp, "k")) {
} else if (strequal(endp, "k")) {
twin = win_vert_neighbor(tp, twin, true, count);
} else if (strequal((char *)endp, "h")) {
} else if (strequal(endp, "h")) {
twin = win_horz_neighbor(tp, twin, true, count);
} else if (strequal((char *)endp, "l")) {
} else if (strequal(endp, "l")) {
twin = win_horz_neighbor(tp, twin, false, count);
} else {
invalid_arg = true;

View File

@ -75,12 +75,12 @@ hashtab_T *func_tbl_get(void)
}
/// Get function arguments.
static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, int *varargs,
static int get_function_args(char **argp, char_u endchar, garray_T *newargs, int *varargs,
garray_T *default_args, bool skip)
{
bool mustend = false;
char_u *arg = *argp;
char_u *p = arg;
char *arg = *argp;
char *p = arg;
char_u c;
int i;
@ -97,7 +97,7 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, i
// Isolate the arguments: "arg1, arg2, ...)"
bool any_default = false;
while (*p != endchar) {
while (*p != (char)endchar) {
if (p[0] == '.' && p[1] == '.' && p[2] == '.') {
if (varargs != NULL) {
*varargs = true;
@ -119,44 +119,43 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, i
}
if (newargs != NULL) {
ga_grow(newargs, 1);
c = *p;
c = (char_u)(*p);
*p = NUL;
arg = vim_strsave(arg);
arg = xstrdup(arg);
// Check for duplicate argument name.
for (i = 0; i < newargs->ga_len; i++) {
if (STRCMP(((char_u **)(newargs->ga_data))[i], arg) == 0) {
if (STRCMP(((char **)(newargs->ga_data))[i], arg) == 0) {
semsg(_("E853: Duplicate argument name: %s"), arg);
xfree(arg);
goto err_ret;
}
}
((char_u **)(newargs->ga_data))[newargs->ga_len] = arg;
((char **)(newargs->ga_data))[newargs->ga_len] = arg;
newargs->ga_len++;
*p = c;
*p = (char)c;
}
if (*skipwhite((char *)p) == '=' && default_args != NULL) {
if (*skipwhite(p) == '=' && default_args != NULL) {
typval_T rettv;
any_default = true;
p = (char_u *)skipwhite((char *)p) + 1;
p = (char_u *)skipwhite((char *)p);
char_u *expr = p;
if (eval1((char **)&p, &rettv, false) != FAIL) {
p = skipwhite(p) + 1;
p = skipwhite(p);
char_u *expr = (char_u *)p;
if (eval1(&p, &rettv, false) != FAIL) {
ga_grow(default_args, 1);
// trim trailing whitespace
while (p > expr && ascii_iswhite(p[-1])) {
while (p > (char *)expr && ascii_iswhite(p[-1])) {
p--;
}
c = *p;
c = (char_u)(*p);
*p = NUL;
expr = vim_strsave(expr);
((char_u **)(default_args->ga_data))
[default_args->ga_len] = expr;
((char **)(default_args->ga_data))[default_args->ga_len] = (char *)expr;
default_args->ga_len++;
*p = c;
*p = (char)c;
} else {
mustend = true;
}
@ -170,15 +169,15 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, i
mustend = true;
}
}
p = (char_u *)skipwhite((char *)p);
if (mustend && *p != endchar) {
p = skipwhite(p);
if (mustend && *p != (char)endchar) {
if (!skip) {
semsg(_(e_invarg2), *argp);
}
break;
}
}
if (*p != endchar) {
if (*p != (char)endchar) {
goto err_ret;
}
p++; // skip "endchar"
@ -224,7 +223,7 @@ char_u *get_lambda_name(void)
/// Parse a lambda expression and get a Funcref from "*arg".
///
/// @return OK or FAIL. Returns NOTDONE for dict or {expr}.
int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
int get_lambda_tv(char **arg, typval_T *rettv, bool evaluate)
{
garray_T newargs = GA_EMPTY_INIT_VALUE;
garray_T *pnewargs;
@ -232,13 +231,13 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
partial_T *pt = NULL;
int varargs;
int ret;
char_u *start = (char_u *)skipwhite((char *)(*arg) + 1);
char_u *start = (char_u *)skipwhite(*arg + 1);
char_u *s, *e;
bool *old_eval_lavars = eval_lavars_used;
bool eval_lavars = false;
// First, check if this is a lambda expression. "->" must exists.
ret = get_function_args(&start, '-', NULL, NULL, NULL, true);
ret = get_function_args((char **)&start, '-', NULL, NULL, NULL, true);
if (ret == FAIL || *start != '>') {
return NOTDONE;
}
@ -249,7 +248,7 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
} else {
pnewargs = NULL;
}
*arg = (char_u *)skipwhite((char *)(*arg) + 1);
*arg = skipwhite(*arg + 1);
ret = get_function_args(arg, '-', pnewargs, &varargs, NULL, false);
if (ret == FAIL || **arg != '>') {
goto errret;
@ -261,14 +260,14 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
}
// Get the start and the end of the expression.
*arg = (char_u *)skipwhite((char *)(*arg) + 1);
s = *arg;
ret = skip_expr((char **)arg);
*arg = skipwhite((*arg) + 1);
s = (char_u *)(*arg);
ret = skip_expr(arg);
if (ret == FAIL) {
goto errret;
}
e = *arg;
*arg = (char_u *)skipwhite((char *)(*arg));
e = (char_u *)(*arg);
*arg = skipwhite(*arg);
if (**arg != '}') {
goto errret;
}
@ -290,7 +289,7 @@ int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate)
// Add "return " before the expression.
size_t len = (size_t)(7 + e - s + 1);
p = (char_u *)xmalloc(len);
((char_u **)(newlines.ga_data))[newlines.ga_len++] = p;
((char **)(newlines.ga_data))[newlines.ga_len++] = (char *)p;
STRCPY(p, "return ");
STRLCPY(p + 7, s, e - s + 1);
if (strstr((char *)p + 7, "a:") == NULL) {
@ -419,24 +418,22 @@ 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_u **arg, funcexe_T *funcexe)
int get_func_tv(const char_u *name, int len, typval_T *rettv, char **arg, funcexe_T *funcexe)
{
char_u *argp;
char *argp;
int ret = OK;
typval_T argvars[MAX_FUNC_ARGS + 1]; // vars for arguments
int argcount = 0; // number of arguments found
/*
* Get the arguments.
*/
// Get the arguments.
argp = *arg;
while (argcount < MAX_FUNC_ARGS
- (funcexe->partial == NULL ? 0 : funcexe->partial->pt_argc)) {
argp = (char_u *)skipwhite((char *)argp + 1); // skip the '(' or ','
argp = skipwhite(argp + 1); // skip the '(' or ','
if (*argp == ')' || *argp == ',' || *argp == NUL) {
break;
}
if (eval1((char **)&argp, &argvars[argcount], funcexe->evaluate) == FAIL) {
if (eval1(&argp, &argvars[argcount], funcexe->evaluate) == FAIL) {
ret = FAIL;
break;
}
@ -480,7 +477,7 @@ int get_func_tv(const char_u *name, int len, typval_T *rettv, char_u **arg, func
tv_clear(&argvars[argcount]);
}
*arg = (char_u *)skipwhite((char *)argp);
*arg = skipwhite(argp);
return ret;
}
@ -822,7 +819,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
int ai;
bool islambda = false;
char_u numbuf[NUMBUFLEN];
char_u *name;
char *name;
typval_T *tv_to_free[MAX_FUNC_ARGS];
int tv_to_free_len = 0;
proftime_T wait_start;
@ -878,7 +875,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
// some compiler that checks the destination size.
v = (dictitem_T *)&fc->fixvar[fixvar_idx++];
#ifndef __clang_analyzer__
name = v->di_key;
name = (char *)v->di_key;
STRCPY(name, "self");
#endif
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
@ -904,7 +901,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
// destination size.
v = (dictitem_T *)&fc->fixvar[fixvar_idx++];
#ifndef __clang_analyzer__
name = v->di_key;
name = (char *)v->di_key;
STRCPY(name, "000");
#endif
v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
@ -943,13 +940,13 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
// evaluate named argument default expression
isdefault = ai + fp->uf_def_args.ga_len >= 0 && i >= argcount;
if (isdefault) {
char_u *default_expr = NULL;
char *default_expr = NULL;
def_rettv.v_type = VAR_NUMBER;
def_rettv.vval.v_number = -1;
default_expr = ((char_u **)(fp->uf_def_args.ga_data))
default_expr = ((char **)(fp->uf_def_args.ga_data))
[ai + fp->uf_def_args.ga_len];
if (eval1((char **)&default_expr, &def_rettv, true) == FAIL) {
if (eval1(&default_expr, &def_rettv, true) == FAIL) {
default_arg_err = true;
break;
}
@ -961,7 +958,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
}
// "..." argument a:1, a:2, etc.
snprintf((char *)numbuf, sizeof(numbuf), "%d", ai + 1);
name = numbuf;
name = (char *)numbuf;
}
if (fixvar_idx < FIXVAR_CNT && STRLEN(name) <= VAR_SHORT_LEN) {
v = (dictitem_T *)&fc->fixvar[fixvar_idx++];
@ -1105,12 +1102,12 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
if (default_arg_err && (fp->uf_flags & FC_ABORT)) {
did_emsg = true;
} else if (islambda) {
char_u *p = *(char_u **)fp->uf_lines.ga_data + 7;
char *p = *(char **)fp->uf_lines.ga_data + 7;
// A Lambda always has the command "return {expr}". It is much faster
// to evaluate {expr} directly.
ex_nesting_level++;
(void)eval1((char **)&p, rettv, true);
(void)eval1(&p, rettv, true);
ex_nesting_level--;
} else {
// call do_cmdline() to execute the lines
@ -1699,7 +1696,7 @@ static void list_func_head(ufunc_T *fp, int indent, bool force)
/// @param partial return: partial of a FuncRef
///
/// @return the function name in allocated memory, or NULL for failure.
char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp, partial_T **partial)
char_u *trans_function_name(char **pp, bool skip, int flags, funcdict_T *fdp, partial_T **partial)
FUNC_ATTR_NONNULL_ARG(1)
{
char_u *name = NULL;
@ -1712,11 +1709,11 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
if (fdp != NULL) {
CLEAR_POINTER(fdp);
}
start = *pp;
start = (char_u *)(*pp);
// Check for hard coded <SNR>: already translated function ID (from a user
// command).
if ((*pp)[0] == K_SPECIAL && (*pp)[1] == KS_EXTRA
if ((unsigned char)(*pp)[0] == K_SPECIAL && (unsigned char)(*pp)[1] == KS_EXTRA
&& (*pp)[2] == KE_SNR) {
*pp += 3;
len = get_id_len((const char **)pp) + 3;
@ -1750,7 +1747,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
semsg(_(e_invarg2), start);
}
} else {
*pp = (char_u *)find_name_end((char *)start, NULL, NULL, FNE_INCL_BR);
*pp = (char *)find_name_end((char *)start, NULL, NULL, FNE_INCL_BR);
}
goto theend;
}
@ -1764,7 +1761,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
}
if (lv.ll_tv->v_type == VAR_FUNC && lv.ll_tv->vval.v_string != NULL) {
name = vim_strsave((char_u *)lv.ll_tv->vval.v_string);
*pp = (char_u *)end;
*pp = (char *)end;
} 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 == '.') {
@ -1775,10 +1772,10 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
}
name = xmallocz((size_t)len);
memcpy(name, end + 1, (size_t)len);
*pp = (char_u *)end + 1 + len;
*pp = (char *)end + 1 + len;
} else {
name = vim_strsave((char_u *)partial_name(lv.ll_tv->vval.v_partial));
*pp = (char_u *)end;
*pp = (char *)end;
}
if (partial != NULL) {
*partial = lv.ll_tv->vval.v_partial;
@ -1789,7 +1786,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
|| fdp->fd_newkey == NULL)) {
emsg(_(e_funcref));
} else {
*pp = (char_u *)end;
*pp = (char *)end;
}
name = NULL;
}
@ -1798,7 +1795,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
if (lv.ll_name == NULL) {
// Error found, but continue after the function name.
*pp = (char_u *)end;
*pp = (char *)end;
goto theend;
}
@ -1811,16 +1808,16 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
name = NULL;
}
} else if (!(flags & TFN_NO_DEREF)) {
len = (int)(end - *pp);
len = (int)(end - (char_u *)(*pp));
name = deref_func_name((const char *)(*pp), &len, partial,
flags & TFN_NO_AUTOLOAD);
if (name == *pp) {
if (name == (char_u *)(*pp)) {
name = NULL;
}
}
if (name != NULL) {
name = vim_strsave(name);
*pp = (char_u *)end;
*pp = (char *)end;
if (STRNCMP(name, "<SNR>", 5) == 0) {
// Change "<SNR>" to the byte sequence.
name[0] = K_SPECIAL;
@ -1898,7 +1895,7 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp,
}
memmove(name + lead, lv.ll_name, (size_t)len);
name[lead + len] = NUL;
*pp = (char_u *)end;
*pp = (char *)end;
theend:
clear_lval(&lv);
@ -2015,7 +2012,7 @@ void ex_function(exarg_T *eap)
// s:func script-local function name
// g:func global function name, same as "func"
p = (char_u *)eap->arg;
name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
name = trans_function_name((char **)&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
paren = (vim_strchr((char *)p, '(') != NULL);
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) {
/*
@ -2072,7 +2069,7 @@ void ex_function(exarg_T *eap)
msg_putchar(' ');
}
}
msg_prt_line(FUNCLINE(fp, j), false);
msg_prt_line((char_u *)FUNCLINE(fp, j), false);
ui_flush(); // show a line at a time
os_breakcheck();
}
@ -2130,7 +2127,7 @@ void ex_function(exarg_T *eap)
}
}
if (get_function_args(&p, ')', &newargs, &varargs,
if (get_function_args((char **)&p, ')', &newargs, &varargs,
&default_args, eap->skip) == FAIL) {
goto errret_2;
}
@ -2323,7 +2320,7 @@ void ex_function(exarg_T *eap)
p = (char_u *)skipwhite((char *)p + 1);
}
p += eval_fname_script((const char *)p);
xfree(trans_function_name(&p, true, 0, NULL, NULL));
xfree(trans_function_name((char **)&p, true, 0, NULL, NULL));
if (*skipwhite((char *)p) == '(') {
nesting++;
indent += 2;
@ -2408,12 +2405,12 @@ void ex_function(exarg_T *eap)
// allocates 250 bytes per line, this saves 80% on average. The cost
// is an extra alloc/free.
p = vim_strsave(theline);
((char_u **)(newlines.ga_data))[newlines.ga_len++] = p;
((char **)(newlines.ga_data))[newlines.ga_len++] = (char *)p;
// Add NULL lines for continuation lines, so that the line count is
// equal to the index in the growarray.
while (sourcing_lnum_off-- > 0) {
((char_u **)(newlines.ga_data))[newlines.ga_len++] = NULL;
((char **)(newlines.ga_data))[newlines.ga_len++] = NULL;
}
// Check for end of eap->arg.
@ -2636,8 +2633,7 @@ bool function_exists(const char *const name, bool no_deref)
if (no_deref) {
flag |= TFN_NO_DEREF;
}
char *const p = (char *)trans_function_name((char_u **)&nm, false, flag, NULL,
NULL);
char *const p = (char *)trans_function_name((char **)&nm, false, flag, NULL, NULL);
nm = (char_u *)skipwhite((char *)nm);
// Only accept "funcname", "funcname ", "funcname (..." and
@ -2701,7 +2697,7 @@ void ex_delfunction(exarg_T *eap)
funcdict_T fudi;
p = (char_u *)eap->arg;
name = trans_function_name(&p, eap->skip, 0, &fudi, NULL);
name = trans_function_name((char **)&p, eap->skip, 0, &fudi, NULL);
xfree(fudi.fd_newkey);
if (name == NULL) {
if (fudi.fd_dict != NULL && !eap->skip) {
@ -2940,7 +2936,7 @@ void ex_call(exarg_T *eap)
return;
}
tofree = trans_function_name(&arg, false, TFN_INT, &fudi, &partial);
tofree = trans_function_name((char **)&arg, false, TFN_INT, &fudi, &partial);
if (fudi.fd_newkey != NULL) {
// Still need to give an error message for missing key.
semsg(_(e_dictkey), fudi.fd_newkey);
@ -2995,7 +2991,7 @@ void ex_call(exarg_T *eap)
funcexe.evaluate = true;
funcexe.partial = partial;
funcexe.selfdict = fudi.fd_dict;
if (get_func_tv(name, -1, &rettv, &arg, &funcexe) == FAIL) {
if (get_func_tv(name, -1, &rettv, (char **)&arg, &funcexe) == FAIL) {
failed = true;
break;
}
@ -3168,13 +3164,13 @@ char *get_func_line(int c, void *cookie, int indent, bool do_concat)
} else {
// Skip NULL lines (continuation lines).
while (fcp->linenr < gap->ga_len
&& ((char_u **)(gap->ga_data))[fcp->linenr] == NULL) {
&& ((char **)(gap->ga_data))[fcp->linenr] == NULL) {
fcp->linenr++;
}
if (fcp->linenr >= gap->ga_len) {
retval = NULL;
} else {
retval = vim_strsave(((char_u **)(gap->ga_data))[fcp->linenr++]);
retval = (char_u *)xstrdup(((char **)(gap->ga_data))[fcp->linenr++]);
sourcing_lnum = fcp->linenr;
if (do_profiling == PROF_YES) {
func_line_start(cookie);

View File

@ -64,8 +64,8 @@ typedef struct {
.basetv = NULL, \
}
#define FUNCARG(fp, j) ((char_u **)(fp->uf_args.ga_data))[j]
#define FUNCLINE(fp, j) ((char_u **)(fp->uf_lines.ga_data))[j]
#define FUNCARG(fp, j) ((char **)(fp->uf_args.ga_data))[j]
#define FUNCLINE(fp, j) ((char **)(fp->uf_lines.ga_data))[j]
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "eval/userfunc.h.generated.h"

View File

@ -3544,7 +3544,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
which_pat = RE_LAST; // use last used regexp
delimiter = (char_u)(*cmd++); // remember delimiter character
pat = cmd; // remember start of search pat
cmd = (char *)skip_regexp((char_u *)cmd, delimiter, p_magic, (char_u **)&eap->arg);
cmd = (char *)skip_regexp((char_u *)cmd, delimiter, p_magic, &eap->arg);
if (cmd[0] == delimiter) { // end delimiter found
*cmd++ = NUL; // replace it with a NUL
has_second_delim = true;
@ -4629,7 +4629,7 @@ void ex_global(exarg_T *eap)
delim = *cmd; // get the delimiter
cmd++; // skip delimiter if there is one
pat = cmd; // remember start of pattern
cmd = (char *)skip_regexp((char_u *)cmd, delim, p_magic, (char_u **)&eap->arg);
cmd = (char *)skip_regexp((char_u *)cmd, delim, p_magic, &eap->arg);
if (cmd[0] == delim) { // end delimiter found
*cmd++ = NUL; // replace it with a NUL
}

View File

@ -696,7 +696,7 @@ void ex_args(exarg_T *eap)
for (int i = 0; i < ARGCOUNT; i++) {
items[i] = alist_name(&ARGLIST[i]);
}
list_in_columns((char_u **)items, ARGCOUNT, curwin->w_arg_idx);
list_in_columns(items, ARGCOUNT, curwin->w_arg_idx);
xfree(items);
}
} else if (eap->cmdidx == CMD_arglocal) {

View File

@ -2888,7 +2888,7 @@ static void append_command(char *cmd)
} else if ((char_u *)d - IObuff + utfc_ptr2len(s) + 1 >= IOSIZE) {
break;
} else {
mb_copy_char((const char_u **)&s, (char_u **)&d);
mb_copy_char((const char **)&s, &d);
}
}
*d = NUL;
@ -3787,7 +3787,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
} else if (context == EXPAND_COMMANDS) {
return arg;
} else if (context == EXPAND_MAPPINGS) {
return (const char *)set_context_in_map_cmd(xp, (char_u *)"map", (char_u *)arg, forceit,
return (const char *)set_context_in_map_cmd(xp, "map", (char_u *)arg, forceit,
false, false,
CMD_map);
}
@ -3825,7 +3825,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_snoremap:
case CMD_xmap:
case CMD_xnoremap:
return (const char *)set_context_in_map_cmd(xp, (char_u *)cmd, (char_u *)arg, forceit, false,
return (const char *)set_context_in_map_cmd(xp, (char *)cmd, (char_u *)arg, forceit, false,
false, ea.cmdidx);
case CMD_unmap:
case CMD_nunmap:
@ -3836,7 +3836,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_lunmap:
case CMD_sunmap:
case CMD_xunmap:
return (const char *)set_context_in_map_cmd(xp, (char_u *)cmd, (char_u *)arg, forceit, false,
return (const char *)set_context_in_map_cmd(xp, (char *)cmd, (char_u *)arg, forceit, false,
true, ea.cmdidx);
case CMD_mapclear:
case CMD_nmapclear:
@ -3857,12 +3857,12 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
case CMD_cnoreabbrev:
case CMD_iabbrev:
case CMD_inoreabbrev:
return (const char *)set_context_in_map_cmd(xp, (char_u *)cmd, (char_u *)arg, forceit, true,
return (const char *)set_context_in_map_cmd(xp, (char *)cmd, (char_u *)arg, forceit, true,
false, ea.cmdidx);
case CMD_unabbreviate:
case CMD_cunabbrev:
case CMD_iunabbrev:
return (const char *)set_context_in_map_cmd(xp, (char_u *)cmd, (char_u *)arg, forceit, true,
return (const char *)set_context_in_map_cmd(xp, (char *)cmd, (char_u *)arg, forceit, true,
true, ea.cmdidx);
case CMD_menu:
case CMD_noremenu:
@ -7788,7 +7788,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
if (spec_idx == SPEC_CWORD
|| spec_idx == SPEC_CCWORD
|| spec_idx == SPEC_CEXPR) {
resultlen = find_ident_under_cursor((char_u **)&result,
resultlen = find_ident_under_cursor(&result,
spec_idx == SPEC_CWORD
? (FIND_IDENT | FIND_STRING)
: (spec_idx == SPEC_CEXPR

View File

@ -3665,7 +3665,7 @@ static void restore_cmdline(struct cmdline_info *ccp)
/// @returns FAIL for failure, OK otherwise
static bool cmdline_paste(int regname, bool literally, bool remcr)
{
char_u *arg;
char *arg;
char_u *p;
bool allocated;
@ -3698,7 +3698,7 @@ static bool cmdline_paste(int regname, bool literally, bool remcr)
// When 'incsearch' is set and CTRL-R CTRL-W used: skip the duplicate
// part of the word.
p = arg;
p = (char_u *)arg;
if (p_is && regname == Ctrl_W) {
char_u *w;
int len;
@ -5672,7 +5672,7 @@ static int ExpandUserLua(expand_T *xp, int *num_file, char ***file)
/// Expand `file` for all comma-separated directories in `path`.
/// Adds matches to `ga`.
void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options)
void globpath(char *path, char_u *file, garray_T *ga, int expand_options)
{
expand_T xpc;
ExpandInit(&xpc);
@ -5683,7 +5683,7 @@ void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options)
// Loop over all entries in {path}.
while (*path != NUL) {
// Copy one item of the path to buf[] and concatenate the file name.
copy_option_part((char **)&path, (char *)buf, MAXPATHL, ",");
copy_option_part(&path, (char *)buf, MAXPATHL, ",");
if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL) {
add_pathsep((char *)buf);
STRCAT(buf, file); // NOLINT
@ -5845,26 +5845,26 @@ int get_cmdline_firstc(void)
/// @param num2 to
///
/// @return OK if parsed successfully, otherwise FAIL.
int get_list_range(char_u **str, int *num1, int *num2)
int get_list_range(char **str, int *num1, int *num2)
{
int len;
int first = false;
varnumber_T num;
*str = (char_u *)skipwhite((char *)(*str));
*str = skipwhite((*str));
if (**str == '-' || ascii_isdigit(**str)) { // parse "from" part of range
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, false);
vim_str2nr((char_u *)(*str), NULL, &len, 0, &num, NULL, 0, false);
*str += len;
*num1 = (int)num;
first = true;
}
*str = (char_u *)skipwhite((char *)(*str));
*str = skipwhite((*str));
if (**str == ',') { // parse "to" part of range
*str = (char_u *)skipwhite((char *)(*str) + 1);
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, false);
*str = skipwhite((*str) + 1);
vim_str2nr((char_u *)(*str), NULL, &len, 0, &num, NULL, 0, false);
if (len > 0) {
*num2 = (int)num;
*str = (char_u *)skipwhite((char *)(*str) + len);
*str = skipwhite((*str) + len);
} else if (!first) { // no number given at all
return FAIL;
}

View File

@ -583,7 +583,7 @@ char_u *vim_findfile(void *search_ctx_arg)
ff_stack_T *stackp = NULL;
size_t len;
char_u *p;
char_u *suf;
char *suf;
ff_search_ctx_T *search_ctx;
if (search_ctx_arg == NULL) {
@ -824,9 +824,9 @@ char_u *vim_findfile(void *search_ctx_arg)
*/
len = STRLEN(file_path);
if (search_ctx->ffsc_tagfile) {
suf = (char_u *)"";
suf = "";
} else {
suf = curbuf->b_p_sua;
suf = (char *)curbuf->b_p_sua;
}
for (;;) {
// if file exists and we didn't already find it
@ -891,7 +891,7 @@ char_u *vim_findfile(void *search_ctx_arg)
break;
}
assert(MAXPATHL >= len);
copy_option_part((char **)&suf, (char *)file_path + len, MAXPATHL - len, ",");
copy_option_part(&suf, (char *)file_path + len, MAXPATHL - len, ",");
}
}
} else {
@ -1401,11 +1401,11 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
char_u *path_option, int find_what, char_u *rel_fname,
char_u *suffixes)
{
static char_u *dir;
static int did_findfile_init = FALSE;
static char *dir;
static int did_findfile_init = false;
char_u save_char;
char_u *file_name = NULL;
char_u *buf = NULL;
char *buf = NULL;
int rel_to_curdir;
if (rel_fname != NULL && path_with_url((const char *)rel_fname)) {
@ -1482,7 +1482,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
/* When the file doesn't exist, try adding parts of
* 'suffixesadd'. */
buf = suffixes;
buf = (char *)suffixes;
for (;;) {
if (
(os_path_exists(NameBuff)
@ -1496,7 +1496,7 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
break;
}
assert(MAXPATHL >= l);
copy_option_part((char **)&buf, (char *)NameBuff + l, MAXPATHL - l, ",");
copy_option_part(&buf, (char *)NameBuff + l, MAXPATHL - l, ",");
}
}
}
@ -1509,8 +1509,8 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
if (first == TRUE) {
// vim_findfile_free_visited can handle a possible NULL pointer
vim_findfile_free_visited(fdip_search_ctx);
dir = path_option;
did_findfile_init = FALSE;
dir = (char *)path_option;
did_findfile_init = false;
}
for (;;) {
@ -1536,13 +1536,13 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
// copy next path
buf[0] = 0;
copy_option_part((char **)&dir, (char *)buf, MAXPATHL, " ,");
copy_option_part(&dir, buf, MAXPATHL, " ,");
// get the stopdir string
r_ptr = vim_findfile_stopdir(buf);
fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find,
r_ptr, 100, FALSE, find_what,
fdip_search_ctx, FALSE, rel_fname);
r_ptr = vim_findfile_stopdir((char_u *)buf);
fdip_search_ctx = vim_findfile_init((char_u *)buf, ff_file_to_find,
r_ptr, 100, false, find_what,
fdip_search_ctx, false, rel_fname);
if (fdip_search_ctx != NULL) {
did_findfile_init = TRUE;
}

View File

@ -5580,14 +5580,14 @@ bool match_file_list(char_u *list, char_u *sfname, char_u *ffname)
char_u *regpat;
char allow_dirs;
bool match;
char_u *p;
char *p;
tail = (char_u *)path_tail((char *)sfname);
// try all patterns in 'wildignore'
p = list;
p = (char *)list;
while (*p) {
copy_option_part((char **)&p, (char *)buf, ARRAY_SIZE(buf), ",");
copy_option_part(&p, (char *)buf, ARRAY_SIZE(buf), ",");
regpat = (char_u *)file_pat_to_reg_pat((char *)buf, NULL, &allow_dirs, false);
if (regpat == NULL) {
break;

View File

@ -292,8 +292,8 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_
char *ret = NULL;
char_u *stringp;
char_u *colonp;
char_u *commap;
char_u *p;
char *commap;
char *p;
size_t idx = 0; // init for GCC
int len;
@ -315,9 +315,9 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_
ret = N_("E550: Missing colon");
break;
}
commap = (char_u *)vim_strchr((char *)stringp, ',');
commap = vim_strchr((char *)stringp, ',');
if (commap == NULL) {
commap = option_str + STRLEN(option_str);
commap = (char *)option_str + STRLEN(option_str);
}
len = (int)(colonp - stringp);
@ -333,8 +333,8 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_
break;
}
p = colonp + 1;
table[idx].present = TRUE;
p = (char *)colonp + 1;
table[idx].present = true;
if (table[idx].hasnum) {
if (!ascii_isdigit(*p)) {
@ -342,13 +342,13 @@ static char *parse_list_options(char_u *option_str, option_table_T *table, size_
break;
}
table[idx].number = getdigits_int((char **)&p, false, 0);
table[idx].number = getdigits_int(&p, false, 0);
}
table[idx].string = p;
table[idx].string = (char_u *)p;
table[idx].strlen = (int)(commap - p);
stringp = commap;
stringp = (char_u *)commap;
if (*stringp == ',') {
++stringp;
}

View File

@ -416,16 +416,15 @@ static int cs_add_common(char *arg1, char *arg2, char *flags)
char *fname2 = NULL;
char *ppath = NULL;
size_t usedlen = 0;
char_u *fbuf = NULL;
char *fbuf = NULL;
// get the filename (arg1), expand it, and try to stat it
fname = xmalloc(MAXPATHL + 1);
expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL);
size_t len = STRLEN(fname);
fbuf = (char_u *)fname;
(void)modify_fname(":p", false, &usedlen,
&fname, (char **)&fbuf, &len);
fbuf = fname;
(void)modify_fname(":p", false, &usedlen, &fname, &fbuf, &len);
if (fname == NULL) {
goto add_err;
}

View File

@ -769,10 +769,10 @@ static int lisp_match(char_u *p)
{
char_u buf[LSIZE];
int len;
char_u *word = *curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords;
char *word = (char *)(*curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords);
while (*word != NUL) {
(void)copy_option_part((char **)&word, (char *)buf, LSIZE, ",");
(void)copy_option_part(&word, (char *)buf, LSIZE, ",");
len = (int)STRLEN(buf);
if ((STRNCMP(buf, p, len) == 0) && (p[len] == ' ')) {

View File

@ -223,8 +223,8 @@ bool cin_is_cinword(const char_u *line)
char_u *cinw_buf = xmalloc(cinw_len);
line = (char_u *)skipwhite((char *)line);
for (char_u *cinw = curbuf->b_p_cinw; *cinw;) {
size_t len = copy_option_part((char **)&cinw, (char *)cinw_buf, cinw_len, ",");
for (char *cinw = (char *)curbuf->b_p_cinw; *cinw;) {
size_t len = copy_option_part(&cinw, (char *)cinw_buf, cinw_len, ",");
if (STRNCMP(line, cinw_buf, len) == 0
&& (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) {
retval = true;
@ -519,8 +519,8 @@ bool cin_isscopedecl(const char_u *p)
bool found = false;
for (char_u *cinsd = curbuf->b_p_cinsd; *cinsd;) {
const size_t len = copy_option_part((char **)&cinsd, (char *)cinsd_buf, cinsd_len, ",");
for (char *cinsd = (char *)curbuf->b_p_cinsd; *cinsd;) {
const size_t len = copy_option_part(&cinsd, (char *)cinsd_buf, cinsd_len, ",");
if (STRNCMP(s, cinsd_buf, len) == 0) {
const char_u *skip = cin_skipcomment(s + len);
if (*skip == ':' && skip[1] != ':') {
@ -1601,8 +1601,8 @@ static int find_last_paren(const char_u *l, int start, int end)
*/
void parse_cino(buf_T *buf)
{
char_u *p;
char_u *l;
char *p;
char *l;
int divider;
int fraction = 0;
int sw = get_sw_value(buf);
@ -1740,16 +1740,16 @@ void parse_cino(buf_T *buf)
// Handle C #pragma directives
buf->b_ind_pragma = 0;
for (p = buf->b_p_cino; *p;) {
for (p = (char *)buf->b_p_cino; *p;) {
l = p++;
if (*p == '-') {
p++;
}
char_u *digits_start = p; // remember where the digits start
int n = getdigits_int((char **)&p, true, 0);
char *digits_start = p; // remember where the digits start
int n = getdigits_int(&p, true, 0);
divider = 0;
if (*p == '.') { // ".5s" means a fraction.
fraction = atoi((char *)++p);
fraction = atoi(++p);
while (ascii_isdigit(*p)) {
p++;
if (divider) {
@ -2052,7 +2052,7 @@ int get_c_indent(void)
char lead_start[COM_MAX_LEN]; // start-comment string
char lead_middle[COM_MAX_LEN]; // middle-comment string
char lead_end[COM_MAX_LEN]; // end-comment string
char_u *p;
char *p;
int start_align = 0;
int start_off = 0;
int done = FALSE;
@ -2063,7 +2063,7 @@ int get_c_indent(void)
*lead_start = NUL;
*lead_middle = NUL;
p = curbuf->b_p_com;
p = (char *)curbuf->b_p_com;
while (*p != NUL) {
int align = 0;
int off = 0;
@ -2071,11 +2071,11 @@ int get_c_indent(void)
while (*p != NUL && *p != ':') {
if (*p == COM_START || *p == COM_END || *p == COM_MIDDLE) {
what = *p++;
what = (unsigned char)(*p++);
} else if (*p == COM_LEFT || *p == COM_RIGHT) {
align = *p++;
align = (unsigned char)(*p++);
} else if (ascii_isdigit(*p) || *p == '-') {
off = getdigits_int((char **)&p, true, 0);
off = getdigits_int(&p, true, 0);
} else {
p++;
}
@ -2084,7 +2084,7 @@ int get_c_indent(void)
if (*p == ':') {
p++;
}
(void)copy_option_part((char **)&p, lead_end, COM_MAX_LEN, ",");
(void)copy_option_part(&p, lead_end, COM_MAX_LEN, ",");
if (what == COM_START) {
STRCPY(lead_start, lead_end);
lead_start_len = (int)STRLEN(lead_start);

View File

@ -2474,7 +2474,7 @@ static int ins_compl_get_exp(pos_T *ini)
{
static pos_T first_match_pos;
static pos_T last_match_pos;
static char_u *e_cpt = (char_u *)""; // curr. entry in 'complete'
static char *e_cpt = ""; // curr. entry in 'complete'
static bool found_all = false; // Found all matches of a
// certain type.
static buf_T *ins_buf = NULL; // buffer being scanned
@ -2503,8 +2503,7 @@ static int ins_compl_get_exp(pos_T *ini)
}
found_all = false;
ins_buf = curbuf;
e_cpt = (compl_cont_status & CONT_LOCAL)
? (char_u *)"." : curbuf->b_p_cpt;
e_cpt = (compl_cont_status & CONT_LOCAL) ? "." : (char *)curbuf->b_p_cpt;
last_match_pos = first_match_pos = *ini;
} else if (ins_buf != curbuf && !buf_valid(ins_buf)) {
ins_buf = curbuf; // In case the buffer was wiped out.
@ -2584,7 +2583,7 @@ static int ins_compl_get_exp(pos_T *ini)
type = CTRL_X_THESAURUS;
}
if (*++e_cpt != ',' && *e_cpt != NUL) {
dict = e_cpt;
dict = (char_u *)e_cpt;
dict_f = DICT_FIRST;
}
} else if (*e_cpt == 'i') {
@ -2601,7 +2600,7 @@ static int ins_compl_get_exp(pos_T *ini)
}
// in any case e_cpt is advanced to the next entry
(void)copy_option_part((char **)&e_cpt, (char *)IObuff, IOSIZE, ",");
(void)copy_option_part(&e_cpt, (char *)IObuff, IOSIZE, ",");
found_all = true;
if (type == -1) {

View File

@ -964,7 +964,7 @@ static int get_map_mode(char **cmdp, bool forceit)
/// Clear all mappings (":mapclear") or abbreviations (":abclear").
/// "abbr" should be false for mappings, true for abbreviations.
/// This function used to be called map_clear().
static void do_mapclear(char_u *cmdp, char_u *arg, int forceit, int abbr)
static void do_mapclear(char *cmdp, char_u *arg, int forceit, int abbr)
{
int mode;
int local;
@ -975,7 +975,7 @@ static void do_mapclear(char_u *cmdp, char_u *arg, int forceit, int abbr)
return;
}
mode = get_map_mode((char **)&cmdp, forceit);
mode = get_map_mode(&cmdp, forceit);
map_clear_mode(curbuf, mode, local, abbr);
}
@ -1051,9 +1051,9 @@ bool map_to_exists(const char *const str, const char *const modechars, const boo
int mode = 0;
int retval;
char_u *buf = NULL;
char *buf = NULL;
const char_u *const rhs = (char_u *)replace_termcodes(str, strlen(str),
(char **)&buf, REPTERM_DO_LT,
&buf, REPTERM_DO_LT,
NULL, CPO_TO_CPO_FLAGS);
#define MAPMODE(mode, modechars, chr, modeflags) \
@ -1194,14 +1194,14 @@ static char_u *translate_mapping(char_u *str, int cpo_flags)
/// @param forceit true if '!' given
/// @param isabbrev true if abbreviation
/// @param isunmap true if unmap/unabbrev command
char_u *set_context_in_map_cmd(expand_T *xp, char_u *cmd, char_u *arg, bool forceit, bool isabbrev,
char_u *set_context_in_map_cmd(expand_T *xp, char *cmd, char_u *arg, bool forceit, bool isabbrev,
bool isunmap, cmdidx_T cmdidx)
{
if (forceit && cmdidx != CMD_map && cmdidx != CMD_unmap) {
xp->xp_context = EXPAND_NOTHING;
} else {
if (isunmap) {
expand_mapmodes = get_map_mode((char **)&cmd, forceit || isabbrev);
expand_mapmodes = get_map_mode(&cmd, forceit || isabbrev);
} else {
expand_mapmodes = MODE_INSERT | MODE_CMDLINE;
if (!isabbrev) {
@ -2079,7 +2079,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
}
char *keys_buf = NULL;
char_u *alt_keys_buf = NULL;
char *alt_keys_buf = NULL;
bool did_simplify = false;
const int flags = REPTERM_FROM_PART | REPTERM_DO_LT;
const int mode = get_map_mode((char **)&which, 0);
@ -2096,9 +2096,9 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
// preferred for printing, like in do_map().
(void)replace_termcodes(keys,
STRLEN(keys),
(char **)&alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL,
&alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL,
CPO_TO_CPO_FLAGS);
rhs = check_map(alt_keys_buf, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua);
rhs = check_map((char_u *)alt_keys_buf, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua);
}
if (!get_dict) {
@ -2439,13 +2439,13 @@ void ex_unmap(exarg_T *eap)
/// ":mapclear" and friends.
void ex_mapclear(exarg_T *eap)
{
do_mapclear((char_u *)eap->cmd, (char_u *)eap->arg, eap->forceit, false);
do_mapclear(eap->cmd, (char_u *)eap->arg, eap->forceit, false);
}
/// ":abclear" and friends.
void ex_abclear(exarg_T *eap)
{
do_mapclear((char_u *)eap->cmd, (char_u *)eap->arg, true, true);
do_mapclear(eap->cmd, (char_u *)eap->arg, true, true);
}
/// Set, tweak, or remove a mapping in a mode. Acts as the implementation for

View File

@ -1818,9 +1818,9 @@ bool utf_allow_break(int cc, int ncc)
///
/// @param[in,out] fp Source of the character to copy.
/// @param[in,out] tp Destination to copy to.
void mb_copy_char(const char_u **const fp, char_u **const tp)
void mb_copy_char(const char **const fp, char **const tp)
{
const size_t l = (size_t)utfc_ptr2len((char *)(*fp));
const size_t l = (size_t)utfc_ptr2len(*fp);
memmove(*tp, *fp, l);
*tp += l;

View File

@ -383,7 +383,7 @@ void ml_setname(buf_T *buf)
bool success = false;
memfile_T *mfp;
char_u *fname;
char_u *dirp;
char *dirp;
mfp = buf->b_ml.ml_mfp;
if (mfp->mf_fd < 0) { // there is no swap file yet
@ -397,17 +397,14 @@ void ml_setname(buf_T *buf)
return;
}
/*
* Try all directories in the 'directory' option.
*/
dirp = p_dir;
// Try all directories in the 'directory' option.
dirp = (char *)p_dir;
bool found_existing_dir = false;
for (;;) {
if (*dirp == NUL) { // tried all directories, fail
break;
}
fname = (char_u *)findswapname(buf, (char **)&dirp, (char *)mfp->mf_fname,
&found_existing_dir);
fname = (char_u *)findswapname(buf, &dirp, (char *)mfp->mf_fname, &found_existing_dir);
// alloc's fname
if (dirp == NULL) { // out of memory
break;
@ -472,7 +469,7 @@ void ml_open_file(buf_T *buf)
{
memfile_T *mfp;
char_u *fname;
char_u *dirp;
char *dirp;
mfp = buf->b_ml.ml_mfp;
if (mfp == NULL || mfp->mf_fd >= 0 || !buf->b_p_swf
@ -491,10 +488,8 @@ void ml_open_file(buf_T *buf)
return;
}
/*
* Try all directories in 'directory' option.
*/
dirp = p_dir;
// Try all directories in 'directory' option.
dirp = (char *)p_dir;
bool found_existing_dir = false;
for (;;) {
if (*dirp == NUL) {
@ -503,8 +498,7 @@ void ml_open_file(buf_T *buf)
// There is a small chance that between choosing the swap file name
// and creating it, another Vim creates the file. In that case the
// creation will fail and we will use another directory.
fname = (char_u *)findswapname(buf, (char **)&dirp, NULL,
&found_existing_dir);
fname = (char_u *)findswapname(buf, &dirp, NULL, &found_existing_dir);
if (dirp == NULL) {
break; // out of memory
}
@ -1272,7 +1266,7 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out)
int num_files;
int file_count = 0;
char **files;
char_u *dirp;
char *dirp;
char_u *dir_name;
char_u *fname_res = NULL;
#ifdef HAVE_READLINK
@ -1299,12 +1293,12 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out)
// Do the loop for every directory in 'directory'.
// First allocate some memory to put the directory name in.
dir_name = xmalloc(STRLEN(p_dir) + 1);
dirp = p_dir;
dirp = (char *)p_dir;
while (*dirp) {
// Isolate a directory name from *dirp and put it in dir_name (we know
// it is large enough, so use 31000 for length).
// Advance dirp to next directory name.
(void)copy_option_part((char **)&dirp, (char *)dir_name, 31000, ",");
(void)copy_option_part(&dirp, (char *)dir_name, 31000, ",");
if (dir_name[0] == '.' && dir_name[1] == NUL) { // check current dir
if (fname == NULL) {
@ -1395,7 +1389,7 @@ int recover_names(char_u *fname, int list, int nr, char_u **fname_out)
file_count += num_files;
if (nr <= file_count) {
*fname_out = vim_strsave((char_u *)files[nr - 1 + num_files - file_count]);
dirp = (char_u *)""; // stop searching
dirp = ""; // stop searching
}
} else if (list) {
if (dir_name[0] == '.' && dir_name[1] == NUL) {

View File

@ -2123,7 +2123,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
int t_col = 0; // Screen cells todo, 0 when "t_s" not used.
int l;
int cw;
const char_u *sb_str = str;
const char *sb_str = (char *)str;
int sb_col = msg_col;
int wrap;
int did_last_char;
@ -2208,7 +2208,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
if (p_more) {
// Store text for scrolling back.
store_sb_text((char_u **)&sb_str, (char_u *)s, attr, &sb_col, true);
store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, true);
}
inc_msg_scrolled();
@ -2255,7 +2255,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
if (wrap && p_more && !recurse) {
// Store text for scrolling back.
store_sb_text((char_u **)&sb_str, (char_u *)s, attr, &sb_col, true);
store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, true);
}
if (*s == '\n') { // go to next line
@ -2314,7 +2314,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
t_puts(&t_col, t_s, s, attr);
}
if (p_more && !recurse) {
store_sb_text((char_u **)&sb_str, (char_u *)s, attr, &sb_col, false);
store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, false);
}
msg_check();
@ -2497,7 +2497,7 @@ static sb_clear_T do_clear_sb_text = SB_CLEAR_NONE;
/// @param sb_str start of string
/// @param s just after string
/// @param finish line ends
static void store_sb_text(char_u **sb_str, char_u *s, int attr, int *sb_col, int finish)
static void store_sb_text(char **sb_str, char *s, int attr, int *sb_col, int finish)
{
msgchunk_T *mp;

View File

@ -2385,7 +2385,7 @@ static bool find_is_eval_item(const char_u *const ptr, int *const colp, int *con
///
/// If text is found, a pointer to the text is put in "*text". This
/// points into the current buffer line and is not always NUL terminated.
size_t find_ident_under_cursor(char_u **text, int find_type)
size_t find_ident_under_cursor(char **text, int find_type)
FUNC_ATTR_NONNULL_ARG(1)
{
return find_ident_at_pos(curwin, curwin->w_cursor.lnum,
@ -2396,7 +2396,7 @@ size_t find_ident_under_cursor(char_u **text, int find_type)
/// However: Uses 'iskeyword' from the current window!.
///
/// @param textcol column where "text" starts, can be NULL
size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **text, int *textcol,
size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text, int *textcol,
int find_type)
FUNC_ATTR_NONNULL_ARG(1, 4)
{
@ -2472,7 +2472,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **te
return 0;
}
ptr += col;
*text = ptr;
*text = (char *)ptr;
if (textcol != NULL) {
*textcol = col;
}
@ -3037,9 +3037,9 @@ static void nv_page(cmdarg_T *cap)
static void nv_gd(oparg_T *oap, int nchar, int thisblock)
{
size_t len;
char_u *ptr;
char *ptr;
if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0
|| !find_decl(ptr, len, nchar == 'd', thisblock, SEARCH_START)) {
|| !find_decl((char_u *)ptr, len, nchar == 'd', thisblock, SEARCH_START)) {
clearopbeep(oap);
} else {
if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) {
@ -3559,7 +3559,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar)
if (checkclearop(cap->oap)) {
return OK;
}
char_u *ptr = NULL;
char *ptr = NULL;
size_t len;
if (VIsual_active && !get_visual_text(cap, &ptr, &len)) {
return FAIL;
@ -3574,7 +3574,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar)
len = spell_move_to(curwin, FORWARD, true, true, NULL);
emsg_off--;
if (len != 0 && curwin->w_cursor.col <= pos.col) {
ptr = ml_get_pos(&curwin->w_cursor);
ptr = (char *)ml_get_pos(&curwin->w_cursor);
}
curwin->w_cursor = pos;
}
@ -3583,7 +3583,7 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar)
return FAIL;
}
assert(len <= INT_MAX);
spell_add_word(ptr, (int)len,
spell_add_word((char_u *)ptr, (int)len,
nchar == 'w' || nchar == 'W' ? SPELL_ADD_BAD : SPELL_ADD_GOOD,
(nchar == 'G' || nchar == 'W') ? 0 : (int)cap->count1,
undo);
@ -4159,7 +4159,7 @@ void do_nv_ident(int c1, int c2)
/// 'K' normal-mode command. Get the command to lookup the keyword under the
/// cursor.
static size_t nv_K_getcmd(cmdarg_T *cap, char_u *kp, bool kp_help, bool kp_ex, char_u **ptr_arg,
static size_t nv_K_getcmd(cmdarg_T *cap, char_u *kp, bool kp_help, bool kp_ex, char **ptr_arg,
size_t n, char *buf, size_t buf_size)
{
if (kp_help) {
@ -4178,7 +4178,7 @@ static size_t nv_K_getcmd(cmdarg_T *cap, char_u *kp, bool kp_help, bool kp_ex, c
return n;
}
char_u *ptr = *ptr_arg;
char *ptr = *ptr_arg;
// An external command will probably use an argument starting
// with "-" as an option. To avoid trouble we skip the "-".
@ -4228,7 +4228,7 @@ static size_t nv_K_getcmd(cmdarg_T *cap, char_u *kp, bool kp_help, bool kp_ex, c
/// g ']' :tselect for current identifier
static void nv_ident(cmdarg_T *cap)
{
char_u *ptr = NULL;
char *ptr = NULL;
char_u *p;
size_t n = 0; // init for GCC
int cmdchar;
@ -4274,7 +4274,7 @@ static void nv_ident(cmdarg_T *cap)
assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty.
bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command
bool kp_help = (STRCMP(kp, ":he") == 0 || STRCMP(kp, ":help") == 0);
if (kp_help && *skipwhite((char *)ptr) == NUL) {
if (kp_help && *skipwhite(ptr) == NUL) {
emsg(_(e_noident)); // found white space only
return;
}
@ -4290,9 +4290,9 @@ static void nv_ident(cmdarg_T *cap)
// Call setpcmark() first, so "*``" puts the cursor back where
// it was.
setpcmark();
curwin->w_cursor.col = (colnr_T)(ptr - get_cursor_line_ptr());
curwin->w_cursor.col = (colnr_T)(ptr - (char *)get_cursor_line_ptr());
if (!g_cmd && vim_iswordp(ptr)) {
if (!g_cmd && vim_iswordp((char_u *)ptr)) {
STRCPY(buf, "\\<");
}
no_smartcase = true; // don't use 'smartcase' now
@ -4329,13 +4329,13 @@ static void nv_ident(cmdarg_T *cap)
// Now grab the chars in the identifier
if (cmdchar == 'K' && !kp_help) {
ptr = vim_strnsave(ptr, n);
ptr = xstrnsave(ptr, n);
if (kp_ex) {
// Escape the argument properly for an Ex command
p = (char_u *)vim_strsave_fnameescape((const char *)ptr, VSE_NONE);
} else {
// Escape the argument properly for a shell command
p = vim_strsave_shellescape(ptr, true, true);
p = vim_strsave_shellescape((char_u *)ptr, true, true);
}
xfree(ptr);
char *newbuf = xrealloc(buf, STRLEN(buf) + STRLEN(p) + 1);
@ -4366,11 +4366,11 @@ static void nv_ident(cmdarg_T *cap)
}
// When current byte is a part of multibyte character, copy all
// bytes of that character.
const size_t len = (size_t)(utfc_ptr2len((char *)ptr) - 1);
const size_t len = (size_t)(utfc_ptr2len(ptr) - 1);
for (size_t i = 0; i < len && n > 0; i++, n--) {
*p++ = *ptr++;
*p++ = (char_u)(*ptr++);
}
*p++ = *ptr++;
*p++ = (char_u)(*ptr++);
}
*p = NUL;
}
@ -4378,7 +4378,7 @@ static void nv_ident(cmdarg_T *cap)
// Execute the command.
if (cmdchar == '*' || cmdchar == '#') {
if (!g_cmd
&& vim_iswordp(mb_prevptr(get_cursor_line_ptr(), ptr))) {
&& vim_iswordp(mb_prevptr(get_cursor_line_ptr(), (char_u *)ptr))) {
STRCAT(buf, "\\>");
}
@ -4410,7 +4410,7 @@ static void nv_ident(cmdarg_T *cap)
/// @param lenp return: length of selected text
///
/// @return false if more than one line selected.
bool get_visual_text(cmdarg_T *cap, char_u **pp, size_t *lenp)
bool get_visual_text(cmdarg_T *cap, char **pp, size_t *lenp)
{
if (VIsual_mode != 'V') {
unadjust_for_sel();
@ -4422,14 +4422,14 @@ bool get_visual_text(cmdarg_T *cap, char_u **pp, size_t *lenp)
return false;
}
if (VIsual_mode == 'V') {
*pp = get_cursor_line_ptr();
*pp = (char *)get_cursor_line_ptr();
*lenp = STRLEN(*pp);
} else {
if (lt(curwin->w_cursor, VIsual)) {
*pp = ml_get_pos(&curwin->w_cursor);
*pp = (char *)ml_get_pos(&curwin->w_cursor);
*lenp = (size_t)VIsual.col - (size_t)curwin->w_cursor.col + 1;
} else {
*pp = ml_get_pos(&VIsual);
*pp = (char *)ml_get_pos(&VIsual);
*lenp = (size_t)curwin->w_cursor.col - (size_t)VIsual.col + 1;
}
if (**pp == NUL) {
@ -4437,7 +4437,7 @@ bool get_visual_text(cmdarg_T *cap, char_u **pp, size_t *lenp)
}
if (*lenp > 0) {
// Correct the length to include all bytes of the last character.
*lenp += (size_t)(utfc_ptr2len((char *)(*pp) + (*lenp - 1)) - 1);
*lenp += (size_t)(utfc_ptr2len(*pp + (*lenp - 1)) - 1);
}
}
reset_VIsual_and_resel();
@ -5048,15 +5048,15 @@ static void nv_brackets(cmdarg_T *cap)
// fwd bwd fwd bwd fwd bwd
// identifier "]i" "[i" "]I" "[I" "]^I" "[^I"
// define "]d" "[d" "]D" "[D" "]^D" "[^D"
char_u *ptr;
char *ptr;
size_t len;
if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) {
clearop(cap->oap);
} else {
// Make a copy, if the line was changed it will be freed.
ptr = vim_strnsave(ptr, len);
find_pattern_in_path(ptr, 0, len, true,
ptr = xstrnsave(ptr, len);
find_pattern_in_path((char_u *)ptr, 0, len, true,
cap->count0 == 0 ? !isupper(cap->nchar) : false,
(((cap->nchar & 0xf) == ('d' & 0xf))
? FIND_DEFINE

View File

@ -998,14 +998,14 @@ static int stuff_yank(int regname, char_u *p)
}
yankreg_T *reg = get_yank_register(regname, YREG_YANK);
if (is_append_register(regname) && reg->y_array != NULL) {
char_u **pp = (char_u **)&(reg->y_array[reg->y_size - 1]);
char **pp = &(reg->y_array[reg->y_size - 1]);
char_u *lp = xmalloc(STRLEN(*pp) + STRLEN(p) + 1);
STRCPY(lp, *pp);
// TODO(philix): use xstpcpy() in stuff_yank()
STRCAT(lp, p);
xfree(p);
xfree(*pp);
*pp = lp;
*pp = (char *)lp;
} else {
free_register(reg);
set_yreg_additional_data(reg, NULL);
@ -1277,7 +1277,7 @@ int insert_reg(int regname, bool literally_arg)
return FAIL;
}
char_u *arg;
char *arg;
if (regname == '.') { // Insert last inserted text.
retval = stuff_inserted(NUL, 1L, true);
} else if (get_spec_reg(regname, &arg, &allocated, true)) {
@ -1348,7 +1348,7 @@ static void stuffescaped(const char *arg, bool literally)
/// @param errmsg give error message when failing
///
/// @return true if "regname" is a special register,
bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg)
bool get_spec_reg(int regname, char **argp, bool *allocated, bool errmsg)
{
size_t cnt;
@ -1359,15 +1359,15 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg)
if (errmsg) {
check_fname(); // will give emsg if not set
}
*argp = (char_u *)curbuf->b_fname;
*argp = curbuf->b_fname;
return true;
case '#': // alternate file name
*argp = (char_u *)getaltfname(errmsg); // may give emsg if not set
*argp = getaltfname(errmsg); // may give emsg if not set
return true;
case '=': // result of expression
*argp = get_expr_line();
*argp = (char *)get_expr_line();
*allocated = true;
return true;
@ -1375,18 +1375,18 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg)
if (last_cmdline == NULL && errmsg) {
emsg(_(e_nolastcmd));
}
*argp = last_cmdline;
*argp = (char *)last_cmdline;
return true;
case '/': // last search-pattern
if (last_search_pat() == NULL && errmsg) {
emsg(_(e_noprevre));
}
*argp = last_search_pat();
*argp = (char *)last_search_pat();
return true;
case '.': // last inserted text
*argp = get_last_insert_save();
*argp = (char *)get_last_insert_save();
*allocated = true;
if (*argp == NULL && errmsg) {
emsg(_(e_noinstext));
@ -1398,8 +1398,9 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg)
if (!errmsg) {
return false;
}
*argp = file_name_at_cursor(FNAME_MESS | FNAME_HYP | (regname == Ctrl_P ? FNAME_EXP : 0),
1L, NULL);
*argp
= (char *)file_name_at_cursor(FNAME_MESS | FNAME_HYP | (regname == Ctrl_P ? FNAME_EXP : 0),
1L, NULL);
*allocated = true;
return true;
@ -1411,7 +1412,7 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg)
cnt = find_ident_under_cursor(argp, (regname == Ctrl_W
? (FIND_IDENT|FIND_STRING)
: FIND_STRING));
*argp = cnt ? vim_strnsave(*argp, cnt) : NULL;
*argp = cnt ? xstrnsave(*argp, cnt) : NULL;
*allocated = true;
return true;
@ -1420,11 +1421,11 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg)
return false;
}
*argp = ml_get_buf(curwin->w_buffer, curwin->w_cursor.lnum, false);
*argp = (char *)ml_get_buf(curwin->w_buffer, curwin->w_cursor.lnum, false);
return true;
case '_': // black hole: always empty
*argp = (char_u *)"";
*argp = "";
return true;
}
@ -2961,7 +2962,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
int delcount;
int incr = 0;
struct block_def bd;
char_u **y_array = NULL;
char **y_array = NULL;
linenr_T nr_lines = 0;
pos_T new_cursor;
int indent;
@ -2970,7 +2971,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
bool first_indent = true;
int lendiff = 0;
pos_T old_pos;
char_u *insert_string = NULL;
char *insert_string = NULL;
bool allocated = false;
long cnt;
const pos_T orig_start = curbuf->b_op_start;
@ -3093,10 +3094,10 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
* Loop twice: count the number of lines and save them. */
for (;;) {
y_size = 0;
ptr = insert_string;
ptr = (char_u *)insert_string;
while (ptr != NULL) {
if (y_array != NULL) {
y_array[y_size] = ptr;
y_array[y_size] = (char *)ptr;
}
y_size++;
ptr = (char_u *)vim_strchr((char *)ptr, '\n');
@ -3115,7 +3116,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
if (y_array != NULL) {
break;
}
y_array = (char_u **)xmalloc(y_size * sizeof(char_u *));
y_array = xmalloc(y_size * sizeof(char_u *));
}
} else {
y_size = 1; // use fake one-line yank register
@ -3132,7 +3133,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
y_type = reg->y_type;
y_width = reg->y_width;
y_size = reg->y_size;
y_array = (char_u **)reg->y_array;
y_array = reg->y_array;
}
if (curbuf->terminal) {
@ -3341,7 +3342,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
// block
spaces = y_width + 1;
for (int j = 0; j < yanklen; j++) {
spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);
spaces -= lbr_chartabsize(NULL, (char_u *)(&y_array[i][j]), 0);
}
if (spaces < 0) {
spaces = 0;
@ -3580,7 +3581,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
for (; i < y_size; i++) {
if ((y_type != kMTCharWise || i < y_size - 1)) {
if (ml_append(lnum, (char *)y_array[i], (colnr_T)0, false) == FAIL) {
if (ml_append(lnum, y_array[i], (colnr_T)0, false) == FAIL) {
goto error;
}
new_lnum++;
@ -3670,8 +3671,8 @@ error:
if (col > 1) {
curbuf->b_op_end.col = col - 1;
if (len > 0) {
curbuf->b_op_end.col -= utf_head_off(y_array[y_size - 1],
y_array[y_size - 1] + len - 1);
curbuf->b_op_end.col -= utf_head_off((char_u *)y_array[y_size - 1],
(char_u *)y_array[y_size - 1] + len - 1);
}
} else {
curbuf->b_op_end.col = 0;
@ -3962,9 +3963,9 @@ static void dis_msg(const char_u *p, bool skip_esc)
/// comment.
char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_comment)
{
char_u *comment_flags = NULL;
char *comment_flags = NULL;
int lead_len;
int leader_offset = get_last_leader_offset((char *)line, (char **)&comment_flags);
int leader_offset = get_last_leader_offset((char *)line, &comment_flags);
*is_comment = false;
if (leader_offset != -1) {
@ -3986,7 +3987,7 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co
return line;
}
lead_len = get_leader_len((char *)line, (char **)&comment_flags, false, include_space);
lead_len = get_leader_len((char *)line, &comment_flags, false, include_space);
if (lead_len == 0) {
return line;
@ -5457,16 +5458,16 @@ void *get_reg_contents(int regname, int flags)
return NULL;
}
char_u *retval;
char *retval;
bool allocated;
if (get_spec_reg(regname, &retval, &allocated, false)) {
if (retval == NULL) {
return NULL;
}
if (allocated) {
return get_reg_wrap_one_line(retval, flags);
return get_reg_wrap_one_line((char_u *)retval, flags);
}
return get_reg_wrap_one_line(vim_strsave(retval), flags);
return get_reg_wrap_one_line(vim_strsave((char_u *)retval), flags);
}
yankreg_T *reg = get_yank_register(regname, YREG_PASTE);
@ -5557,11 +5558,11 @@ void write_reg_contents(int name, const char_u *str, ssize_t len, int must_appen
write_reg_contents_ex(name, str, len, must_append, kMTUnknown, 0L);
}
void write_reg_contents_lst(int name, char_u **strings, bool must_append, MotionType yank_type,
void write_reg_contents_lst(int name, char **strings, bool must_append, MotionType yank_type,
colnr_T block_len)
{
if (name == '/' || name == '=') {
char_u *s = strings[0];
char_u *s = (char_u *)strings[0];
if (strings[0] == NULL) {
s = (char_u *)"";
} else if (strings[1] != NULL) {
@ -5583,7 +5584,7 @@ void write_reg_contents_lst(int name, char_u **strings, bool must_append, Motion
return;
}
str_to_reg(reg, yank_type, (char_u *)strings, STRLEN((char_u *)strings),
str_to_reg(reg, yank_type, (char *)strings, STRLEN((char_u *)strings),
block_len, true);
finish_write_reg(name, reg, old_y_previous);
}
@ -5671,7 +5672,7 @@ void write_reg_contents_ex(int name, const char_u *str, ssize_t len, bool must_a
if (!(reg = init_write_reg(name, &old_y_previous, must_append))) {
return;
}
str_to_reg(reg, yank_type, str, (size_t)len, block_len, false);
str_to_reg(reg, yank_type, (char *)str, (size_t)len, block_len, false);
finish_write_reg(name, reg, old_y_previous);
}
@ -5685,7 +5686,7 @@ void write_reg_contents_ex(int name, const char_u *str, ssize_t len, bool must_a
/// @param len length of the string (Ignored when str_list=true.)
/// @param blocklen width of visual block, or -1 for "I don't know."
/// @param str_list True if str is `char_u **`.
static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char_u *str, size_t len,
static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str, size_t len,
colnr_T blocklen, bool str_list)
FUNC_ATTR_NONNULL_ALL
{
@ -5727,9 +5728,8 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char_u *str
}
// Grow the register array to hold the pointers to the new lines.
char_u **pp = xrealloc(y_ptr->y_array,
(y_ptr->y_size + newlines) * sizeof(char_u *));
y_ptr->y_array = (char **)pp;
char **pp = xrealloc(y_ptr->y_array, (y_ptr->y_size + newlines) * sizeof(char_u *));
y_ptr->y_array = pp;
size_t lnum = y_ptr->y_size; // The current line number.
@ -5747,7 +5747,7 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char_u *str
}
} else {
size_t line_len;
for (const char_u *start = str, *end = str + len;
for (const char_u *start = (char_u *)str, *end = (char_u *)str + len;
start < end + extraline;
start += line_len + 1, lnum++) {
assert(end - start >= 0);
@ -5770,7 +5770,7 @@ static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char_u *str
xfree(pp[lnum]);
append = false; // only first line is appended
}
pp[lnum] = (char_u *)s;
pp[lnum] = s;
// Convert NULs to '\n' to prevent truncation.
memchrsub(pp[lnum], NUL, '\n', s_len);

View File

@ -981,7 +981,7 @@ int do_set(char *arg, int opt_flags)
varnumber_T value;
int key;
uint32_t flags; // flags for current option
char_u *varp = NULL; // pointer to variable for current option
char *varp = NULL; // pointer to variable for current option
int did_show = false; // already showed one value
int adding; // "opt+=arg"
int prepending; // "opt^=arg"
@ -1109,7 +1109,7 @@ int do_set(char *arg, int opt_flags)
}
flags = options[opt_idx].flags;
varp = get_varp_scope(&(options[opt_idx]), opt_flags);
varp = (char *)get_varp_scope(&(options[opt_idx]), opt_flags);
} else {
flags = P_STRING;
}
@ -1191,7 +1191,7 @@ int do_set(char *arg, int opt_flags)
showoneopt(&options[opt_idx], opt_flags);
if (p_verbose > 0) {
// Mention where the option was last set.
if (varp == options[opt_idx].var) {
if (varp == (char *)options[opt_idx].var) {
option_last_set_msg(options[opt_idx].last_set);
} else if ((int)options[opt_idx].indir & PV_WIN) {
option_last_set_msg(curwin->w_p_script_ctx[
@ -1253,8 +1253,7 @@ int do_set(char *arg, int opt_flags)
}
}
errmsg = set_bool_option(opt_idx, varp, (int)value,
opt_flags);
errmsg = set_bool_option(opt_idx, (char_u *)varp, (int)value, opt_flags);
} else { // Numeric or string.
if (vim_strchr("=:&<", nextchar) == NULL
|| prefix != 1) {
@ -1313,7 +1312,7 @@ int do_set(char *arg, int opt_flags)
if (removing) {
value = *(long *)varp - value;
}
errmsg = set_num_option(opt_idx, varp, (long)value,
errmsg = set_num_option(opt_idx, (char_u *)varp, (long)value,
errbuf, sizeof(errbuf),
opt_flags);
} else if (opt_idx >= 0) { // String.
@ -1336,7 +1335,7 @@ int do_set(char *arg, int opt_flags)
// reset, use the global value here.
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
&& ((int)options[opt_idx].indir & PV_BOTH)) {
varp = options[opt_idx].var;
varp = (char *)options[opt_idx].var;
}
// The old value is kept until we are sure that the
@ -1385,23 +1384,16 @@ int do_set(char *arg, int opt_flags)
} else {
arg++; // jump to after the '=' or ':'
/*
* Set 'keywordprg' to ":help" if an empty
* value was passed to :set by the user.
* Misuse errbuf[] for the resulting string.
*/
if (varp == (char_u *)&p_kp
&& (*arg == NUL || *arg == ' ')) {
// Set 'keywordprg' to ":help" if an empty
// value was passed to :set by the user.
// Misuse errbuf[] for the resulting string.
if (varp == (char *)&p_kp && (*arg == NUL || *arg == ' ')) {
STRCPY(errbuf, ":help");
save_arg = (char_u *)arg;
arg = errbuf;
}
/*
* Convert 'backspace' number to string, for
* adding, prepending and removing string.
*/
else if (varp == (char_u *)&p_bs
&& ascii_isdigit(**(char_u **)varp)) {
} else if (varp == (char *)&p_bs && ascii_isdigit(**(char_u **)varp)) {
// Convert 'backspace' number to string, for
// adding, prepending and removing string.
i = getdigits_int((char **)varp, true, 0);
switch (i) {
case 0:
@ -1428,14 +1420,10 @@ int do_set(char *arg, int opt_flags)
origval_g = *(char_u **)varp;
}
oldval = *(char_u **)varp;
}
/*
* Convert 'whichwrap' number to string, for
* backwards compatibility with Vim 3.0.
* Misuse errbuf[] for the resulting string.
*/
else if (varp == (char_u *)&p_ww
&& ascii_isdigit(*arg)) {
} else if (varp == (char *)&p_ww && ascii_isdigit(*arg)) {
// Convert 'whichwrap' number to string, for
// backwards compatibility with Vim 3.0.
// Misuse errbuf[] for the resulting string.
*errbuf = NUL;
i = getdigits_int(&arg, true, 0);
if (i & 1) {
@ -1455,14 +1443,11 @@ int do_set(char *arg, int opt_flags)
}
save_arg = (char_u *)arg;
arg = errbuf;
}
/*
* Remove '>' before 'dir' and 'bdir', for
* backwards compatibility with version 3.0
*/
else if (*arg == '>'
&& (varp == (char_u *)&p_dir
|| varp == (char_u *)&p_bdir)) {
} else if (*arg == '>'
&& (varp == (char *)&p_dir
|| varp == (char *)&p_bdir)) {
// Remove '>' before 'dir' and 'bdir', for
// backwards compatibility with version 3.0
arg++;
}
@ -2444,7 +2429,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
size_t errbuflen, int opt_flags, int *value_checked)
{
char *errmsg = NULL;
char_u *s, *p;
char *s, *p;
int did_chartab = false;
char_u **gvarp;
bool free_oldval = (options[opt_idx].flags & P_ALLOCED);
@ -2533,7 +2518,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
errmsg = check_colorcolumn(curwin);
} else if (varp == &p_hlg) { // 'helplang'
// Check for "", "ab", "ab,cd", etc.
for (s = p_hlg; *s != NUL; s += 3) {
for (s = (char *)p_hlg; *s != NUL; s += 3) {
if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) {
errmsg = e_invarg;
break;
@ -2639,9 +2624,9 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
if (errmsg == NULL) {
// canonize the value, so that STRCMP() can be used on it
p = enc_canonize(*varp);
p = (char *)enc_canonize(*varp);
xfree(*varp);
*varp = p;
*varp = (char_u *)p;
if (varp == &p_enc) {
// only encoding=utf-8 allowed
if (STRCMP(p_enc, "utf-8") != 0) {
@ -2653,9 +2638,9 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
}
} else if (varp == &p_penc) {
// Canonize printencoding if VIM standard one
p = enc_canonize(p_penc);
p = (char *)enc_canonize(p_penc);
xfree(p_penc);
p_penc = p;
p_penc = (char_u *)p;
} else if (varp == &curbuf->b_p_keymap) {
if (!valid_filetype(*varp)) {
errmsg = e_invarg;
@ -2718,17 +2703,17 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
errmsg = e_invarg;
}
} else if (gvarp == &p_mps) { // 'matchpairs'
for (p = *varp; *p != NUL; p++) {
for (p = (char *)(*varp); *p != NUL; p++) {
int x2 = -1;
int x3 = -1;
p += utfc_ptr2len((char *)p);
p += utfc_ptr2len(p);
if (*p != NUL) {
x2 = *p++;
x2 = (unsigned char)(*p++);
}
if (*p != NUL) {
x3 = utf_ptr2char((char *)p);
p += utfc_ptr2len((char *)p);
x3 = utf_ptr2char(p);
p += utfc_ptr2len(p);
}
if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) {
errmsg = e_invarg;
@ -2739,7 +2724,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
}
}
} else if (gvarp == &p_com) { // 'comments'
for (s = *varp; *s;) {
for (s = (char *)(*varp); *s;) {
while (*s && *s != ':') {
if (vim_strchr(COM_ALL, *s) == NULL
&& !ascii_isdigit(*s) && *s != '-') {
@ -2762,7 +2747,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
}
s++;
}
s = skip_to_option_part(s);
s = (char *)skip_to_option_part((char_u *)s);
}
} else if (varp == &p_lcs) { // global 'listchars'
errmsg = set_chars_option(curwin, varp, false);
@ -2818,7 +2803,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
// there would be a disconnect between the check for P_ALLOCED at the start
// of the function and the set of P_ALLOCED at the end of the function.
free_oldval = (options[opt_idx].flags & P_ALLOCED);
for (s = p_shada; *s;) {
for (s = (char *)p_shada; *s;) {
// Check it's a valid character
if (vim_strchr("!\"%'/:<@cfhnrs", *s) == NULL) {
errmsg = illegal_char(errbuf, errbuflen, *s);
@ -2863,8 +2848,8 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
errmsg = N_("E528: Must specify a ' value");
}
} else if (gvarp == &p_sbr) { // 'showbreak'
for (s = *varp; *s;) {
if (ptr2cells((char *)s) != 1) {
for (s = (char *)(*varp); *s;) {
if (ptr2cells(s) != 1) {
errmsg = N_("E595: 'showbreak' contains unprintable or wide character");
}
MB_PTR_ADV(s);
@ -2988,13 +2973,13 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
if (varp == &p_ruf) { // reset ru_wid first
ru_wid = 0;
}
s = *varp;
s = (char *)(*varp);
if (varp == &p_ruf && *s == '%') {
// set ru_wid if 'ruf' starts with "%99("
if (*++s == '-') { // ignore a '-'
s++;
}
wid = getdigits_int((char **)&s, true, 0);
wid = getdigits_int(&s, true, 0);
if (wid && *s == '(' && (errmsg = check_stl_option((char *)p_ruf)) == NULL) {
ru_wid = wid;
} else {
@ -3002,7 +2987,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
}
} else if (varp == &p_ruf || s[0] != '%' || s[1] != '!') {
// check 'statusline', 'winbar' or 'tabline' only if it doesn't start with "%!"
errmsg = check_stl_option((char *)s);
errmsg = check_stl_option(s);
}
if (varp == &p_ruf && errmsg == NULL) {
comp_col();
@ -3013,7 +2998,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
}
} else if (gvarp == &p_cpt) {
// check if it is a valid value for 'complete' -- Acevedo
for (s = *varp; *s;) {
for (s = (char *)(*varp); *s;) {
while (*s == ',' || *s == ' ') {
s++;
}
@ -3082,11 +3067,11 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
p = NULL;
(void)replace_termcodes((char *)p_pt,
STRLEN(p_pt),
(char **)&p, REPTERM_FROM_PART | REPTERM_DO_LT, NULL,
&p, REPTERM_FROM_PART | REPTERM_DO_LT, NULL,
CPO_TO_CPO_FLAGS);
if (p != NULL) {
free_string_option(p_pt);
p_pt = p;
p_pt = (char_u *)p;
}
}
} else if (varp == &p_bs) { // 'backspace'
@ -3105,10 +3090,10 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
unsigned int *flags;
if (opt_flags & OPT_LOCAL) {
p = curbuf->b_p_tc;
p = (char *)curbuf->b_p_tc;
flags = &curbuf->b_tc_flags;
} else {
p = p_tc;
p = (char *)p_tc;
flags = &tc_flags;
}
@ -3116,7 +3101,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
// make the local value empty: use the global value
*flags = 0;
} else if (*p == NUL
|| opt_strings_flags(p, p_tc_values, flags, false) != OK) {
|| opt_strings_flags((char_u *)p, p_tc_values, flags, false) != OK) {
errmsg = e_invarg;
}
} else if (varp == &p_cmp) { // 'casemap'
@ -3142,10 +3127,10 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
foldUpdateAll(curwin);
}
} else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) { // 'foldmarker'
p = (char_u *)vim_strchr((char *)(*varp), ',');
p = vim_strchr((char *)(*varp), ',');
if (p == NULL) {
errmsg = N_("E536: comma required");
} else if (p == *varp || p[1] == NUL) {
} else if ((char_u *)p == *varp || p[1] == NUL) {
errmsg = e_invarg;
} else if (foldmethodIsMarker(curwin)) {
foldUpdateAll(curwin);
@ -3190,7 +3175,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
}
} else if (varp == &p_csqf) {
if (p_csqf != NULL) {
p = p_csqf;
p = (char *)p_csqf;
while (*p != NUL) {
if (vim_strchr(CSQF_CMDS, *p) == NULL
|| p[1] == NUL
@ -3302,22 +3287,22 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
// Options that are a list of flags.
p = NULL;
if (varp == &p_ww) { // 'whichwrap'
p = (char_u *)WW_ALL;
p = WW_ALL;
}
if (varp == &p_shm) { // 'shortmess'
p = (char_u *)SHM_ALL;
p = (char *)SHM_ALL;
} else if (varp == (char_u **)&(p_cpo)) { // 'cpoptions'
p = (char_u *)CPO_VI;
p = CPO_VI;
} else if (varp == &(curbuf->b_p_fo)) { // 'formatoptions'
p = (char_u *)FO_ALL;
p = FO_ALL;
} else if (varp == &curwin->w_p_cocu) { // 'concealcursor'
p = (char_u *)COCU_ALL;
p = COCU_ALL;
} else if (varp == &p_mouse) { // 'mouse'
p = (char_u *)MOUSE_ALL;
p = MOUSE_ALL;
}
if (p != NULL) {
for (s = *varp; *s; s++) {
if (vim_strchr((char *)p, *s) == NULL) {
for (s = (char *)(*varp); *s; s++) {
if (vim_strchr(p, *s) == NULL) {
errmsg = illegal_char(errbuf, errbuflen, *s);
break;
}
@ -3352,7 +3337,7 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
&& ((int)options[opt_idx].indir & PV_BOTH)) {
/* global option with local value set to use global value; free
* the local value and make it empty */
p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
p = (char *)get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
free_string_option(*(char_u **)p);
*(char_u **)p = empty_option;
} else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) {
@ -3415,14 +3400,14 @@ static char *did_set_string_option(int opt_idx, char_u **varp, char_u *oldval, c
* Use the first name in 'spelllang' up to '_region' or
* '.encoding'.
*/
for (p = q; *p != NUL; p++) {
for (p = (char *)q; *p != NUL; p++) {
if (!ASCII_ISALNUM(*p) && *p != '-') {
break;
}
}
if (p > q) {
if (p > (char *)q) {
vim_snprintf((char *)fname, sizeof(fname), "spell/%.*s.vim",
(int)(p - q), q);
(int)(p - (char *)q), q);
source_runtime((char *)fname, DIP_ALL);
}
}
@ -3483,7 +3468,7 @@ int check_signcolumn(char_u *val)
/// @return error message, NULL if it's OK.
char *check_colorcolumn(win_T *wp)
{
char_u *s;
char *s;
int col;
unsigned int count = 0;
int color_cols[256];
@ -3493,7 +3478,7 @@ char *check_colorcolumn(win_T *wp)
return NULL; // buffer was closed
}
for (s = wp->w_p_cc; *s != NUL && count < 255;) {
for (s = (char *)wp->w_p_cc; *s != NUL && count < 255;) {
if (*s == '-' || *s == '+') {
// -N and +N: add to 'textwidth'
col = (*s == '-') ? -1 : 1;
@ -3501,7 +3486,7 @@ char *check_colorcolumn(win_T *wp)
if (!ascii_isdigit(*s)) {
return e_invarg;
}
col = col * getdigits_int((char **)&s, true, 0);
col = col * getdigits_int(&s, true, 0);
if (wp->w_buffer->b_p_tw == 0) {
goto skip; // 'textwidth' not set, skip this item
}
@ -3516,7 +3501,7 @@ char *check_colorcolumn(win_T *wp)
goto skip;
}
} else if (ascii_isdigit(*s)) {
col = getdigits_int((char **)&s, true, 0);
col = getdigits_int(&s, true, 0);
} else {
return e_invarg;
}
@ -5669,7 +5654,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, uint6
char_u *s;
char_u *buf = NULL;
char_u *part = NULL;
char_u *p;
char *p;
if (fprintf(fd, "%s %s=", cmd, name) < 0) {
return FAIL;
@ -5705,14 +5690,14 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, uint6
if (put_eol(fd) == FAIL) {
goto fail;
}
p = buf;
p = (char *)buf;
while (*p != NUL) {
// for each comma separated option part, append value to
// the option, :set rtp+=value
if (fprintf(fd, "%s %s+=", cmd, name) < 0) {
goto fail;
}
(void)copy_option_part((char **)&p, (char *)part, size, ",");
(void)copy_option_part(&p, (char *)part, size, ",");
if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL) {
goto fail;
}
@ -7584,10 +7569,10 @@ bool tabstop_set(char_u *var, long **array)
for (cp = var; *cp != NUL; cp++) {
if (cp == var || cp[-1] == ',') {
char_u *end;
char *end;
if (strtol((char *)cp, (char **)&end, 10) <= 0) {
if (cp != end) {
if (strtol((char *)cp, &end, 10) <= 0) {
if (cp != (char_u *)end) {
emsg(_(e_positive));
} else {
semsg(_(e_invarg2), cp);

View File

@ -580,18 +580,18 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo
int prefix_len = (prefix == NULL) ? 0 : (int)STRLEN(prefix);
char_u *src = (char_u *)skipwhite((char *)srcp);
char *src = skipwhite((char *)srcp);
dstlen--; // leave one char space for "\,"
while (*src && dstlen > 0) {
// Skip over `=expr`.
if (src[0] == '`' && src[1] == '=') {
var = src;
var = (char_u *)src;
src += 2;
(void)skip_expr((char **)&src);
(void)skip_expr(&src);
if (*src == '`') {
src++;
}
size_t len = (size_t)(src - var);
size_t len = (size_t)(src - (char *)var);
if (len > (size_t)dstlen) {
len = (size_t)dstlen;
}
@ -608,7 +608,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo
// The variable name is copied into dst temporarily, because it may
// be a string in read-only memory and a NUL needs to be appended.
if (*src != '~') { // environment var
tail = src + 1;
tail = (char_u *)src + 1;
var = dst;
int c = dstlen - 1;
@ -646,11 +646,11 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo
|| vim_ispathsep(src[1])
|| vim_strchr(" ,\t\n", src[1]) != NULL) {
var = (char_u *)homedir;
tail = src + 1;
tail = (char_u *)src + 1;
} else { // user directory
#if defined(UNIX)
// Copy ~user to dst[], so we can put a NUL after it.
tail = src;
tail = (char_u *)src;
var = dst;
int c = dstlen - 1;
while (c-- > 0
@ -723,7 +723,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo
tail++;
}
dst += c;
src = tail;
src = (char *)tail;
copy_char = false;
}
if (mustfree) {
@ -737,17 +737,17 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo
// ":edit foo ~ foo".
at_start = false;
if (src[0] == '\\' && src[1] != NUL) {
*dst++ = *src++;
*dst++ = (char_u)(*src++);
dstlen--;
} else if ((src[0] == ' ' || src[0] == ',') && !one) {
at_start = true;
}
if (dstlen > 0) {
*dst++ = *src++;
*dst++ = (char_u)(*src++);
dstlen--;
if (prefix != NULL
&& src - prefix_len >= srcp
&& src - prefix_len >= (char *)srcp
&& STRNCMP(src - prefix_len, prefix, prefix_len) == 0) {
at_start = true;
}
@ -1069,9 +1069,8 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si
must_free = true;
size_t usedlen = 0;
size_t flen = strlen(homedir_env_mod);
char_u *fbuf = NULL;
(void)modify_fname(":p", false, &usedlen,
&homedir_env_mod, (char **)&fbuf, &flen);
char *fbuf = NULL;
(void)modify_fname(":p", false, &usedlen, &homedir_env_mod, &fbuf, &flen);
flen = strlen(homedir_env_mod);
assert(homedir_env_mod != homedir_env);
if (vim_ispathsep(homedir_env_mod[flen - 1])) {

View File

@ -339,7 +339,7 @@ static bool is_executable_ext(const char *name, char **abspath)
const char *ext_end = ext;
size_t ext_len =
copy_option_part((char_u **)&ext_end, (char_u *)buf_end,
copy_option_part(&ext_end, (char_u *)buf_end,
sizeof(os_buf) - (size_t)(buf_end - os_buf), ENV_SEPSTR);
if (ext_len != 0) {
bool in_pathext = nameext_len == ext_len

View File

@ -1141,7 +1141,7 @@ static int expand_in_path(garray_T *const gap, char_u *const pattern, const int
if (flags & EW_ADDSLASH) {
glob_flags |= WILD_ADD_SLASH;
}
globpath(paths, pattern, gap, glob_flags);
globpath((char *)paths, pattern, gap, glob_flags);
xfree(paths);
return gap->ga_len;

View File

@ -3119,7 +3119,7 @@ void qf_list(exarg_T *eap)
}
int idx1 = 1;
int idx2 = -1;
if (!get_list_range((char_u **)&arg, &idx1, &idx2) || *arg != NUL) {
if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL) {
semsg(_(e_trailing_arg), arg);
return;
}

View File

@ -482,16 +482,14 @@ static char_u *skip_anyof(char *p)
return (char_u *)p;
}
/*
* Skip past regular expression.
* Stop at end of "startp" or where "dirc" is found ('/', '?', etc).
* Take care of characters with a backslash in front of it.
* Skip strings inside [ and ].
* When "newp" is not NULL and "dirc" is '?', make an allocated copy of the
* expression and change "\?" to "?". If "*newp" is not NULL the expression
* is changed in-place.
*/
char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp)
/// Skip past regular expression.
/// Stop at end of "startp" or where "dirc" is found ('/', '?', etc).
/// Take care of characters with a backslash in front of it.
/// Skip strings inside [ and ].
/// When "newp" is not NULL and "dirc" is '?', make an allocated copy of the
/// expression and change "\?" to "?". If "*newp" is not NULL the expression
/// is changed in-place.
char_u *skip_regexp(char_u *startp, int dirc, int magic, char **newp)
{
int mymagic;
char_u *p = startp;
@ -517,8 +515,8 @@ char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp)
if (dirc == '?' && newp != NULL && p[1] == '?') {
// change "\?" to "?", make a copy first.
if (*newp == NULL) {
*newp = vim_strsave(startp);
p = *newp + (p - startp);
*newp = (char *)vim_strsave(startp);
p = (char_u *)(*newp) + (p - startp);
}
STRMOVE(p, p + 1);
} else {

View File

@ -120,10 +120,10 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback,
}
// Loop over all entries in 'runtimepath'.
char_u *rtp = rtp_copy;
char *rtp = (char *)rtp_copy;
while (*rtp != NUL && ((flags & DIP_ALL) || !did_one)) {
// Copy the path from 'runtimepath' to buf[].
copy_option_part((char **)&rtp, buf, MAXPATHL, ",");
copy_option_part(&rtp, buf, MAXPATHL, ",");
size_t buflen = STRLEN(buf);
// Skip after or non-after directories.
@ -144,12 +144,11 @@ int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback,
tail = (char_u *)buf + STRLEN(buf);
// Loop over all patterns in "name"
char_u *np = (char_u *)name;
char *np = name;
while (*np != NUL && ((flags & DIP_ALL) || !did_one)) {
// Append the pattern from "name" to buf[].
assert(MAXPATHL >= (tail - (char_u *)buf));
copy_option_part((char **)&np, (char *)tail, (size_t)(MAXPATHL - (tail - (char_u *)buf)),
"\t ");
copy_option_part(&np, (char *)tail, (size_t)(MAXPATHL - (tail - (char_u *)buf)), "\t ");
if (p_verbose > 10) {
verbose_enter();
@ -278,11 +277,11 @@ int do_in_cached_path(char_u *name, int flags, DoInRuntimepathCB callback, void
tail = buf + STRLEN(buf);
// Loop over all patterns in "name"
char_u *np = name;
char *np = (char *)name;
while (*np != NUL && ((flags & DIP_ALL) || !did_one)) {
// Append the pattern from "name" to buf[].
assert(MAXPATHL >= (tail - buf));
copy_option_part((char **)&np, (char *)tail, (size_t)(MAXPATHL - (tail - buf)), "\t ");
copy_option_part(&np, (char *)tail, (size_t)(MAXPATHL - (tail - buf)), "\t ");
if (p_verbose > 10) {
verbose_enter();
@ -1044,10 +1043,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
size_t size = STRLEN(dirnames[i]) + pat_len + 7;
char_u *s = xmalloc(size);
snprintf((char *)s, size, "%s/%s*.vim", dirnames[i], pat);
globpath(p_rtp, s, &ga, 0);
globpath((char *)p_rtp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf((char *)s, size, "%s/%s*.lua", dirnames[i], pat);
globpath(p_rtp, s, &ga, 0);
globpath((char *)p_rtp, s, &ga, 0);
}
xfree(s);
}
@ -1057,10 +1056,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
size_t size = STRLEN(dirnames[i]) + pat_len + 22;
char_u *s = xmalloc(size);
snprintf((char *)s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf((char *)s, size, "pack/*/start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
}
xfree(s);
}
@ -1069,10 +1068,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
size_t size = STRLEN(dirnames[i]) + pat_len + 22;
char_u *s = xmalloc(size);
snprintf((char *)s, size, "start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf((char *)s, size, "start/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
}
xfree(s);
}
@ -1083,10 +1082,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
size_t size = STRLEN(dirnames[i]) + pat_len + 20;
char_u *s = xmalloc(size);
snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
}
xfree(s);
}
@ -1095,10 +1094,10 @@ int ExpandRTDir(char_u *pat, int flags, int *num_file, char ***file, char *dirna
size_t size = STRLEN(dirnames[i]) + pat_len + 20;
char_u *s = xmalloc(size);
snprintf((char *)s, size, "opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
if (flags & DIP_LUA) {
snprintf((char *)s, size, "opt/*/%s/%s*.lua", dirnames[i], pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
}
xfree(s);
}
@ -1151,9 +1150,9 @@ int ExpandPackAddDir(char_u *pat, int *num_file, char ***file)
size_t buflen = pat_len + 26;
char_u *s = xmalloc(buflen);
snprintf((char *)s, buflen, "pack/*/opt/%s*", pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
snprintf((char *)s, buflen, "opt/%s*", pat); // NOLINT
globpath(p_pp, s, &ga, 0);
globpath((char *)p_pp, s, &ga, 0);
xfree(s);
for (int i = 0; i < ga.ga_len; i++) {

View File

@ -1038,7 +1038,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
char_u *p;
long c;
char_u *dircp;
char_u *strcopy = NULL;
char *strcopy = NULL;
char_u *ps;
char_u *msgbuf = NULL;
size_t len;
@ -1125,13 +1125,13 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
* Find end of regular expression.
* If there is a matching '/' or '?', toss it.
*/
ps = strcopy;
ps = (char_u *)strcopy;
p = skip_regexp(pat, search_delim, p_magic, &strcopy);
if (strcopy != ps) {
if (strcopy != (char *)ps) {
// made a copy of "pat" to change "\?" to "?"
searchcmdlen += (int)(STRLEN(pat) - STRLEN(strcopy));
pat = strcopy;
searchstr = strcopy;
pat = (char_u *)strcopy;
searchstr = (char_u *)strcopy;
}
if (*p == search_delim) {
dircp = p; // remember where we put the NUL

View File

@ -2039,7 +2039,7 @@ static int count_syllables(slang_T *slang, const char_u *word)
char *did_set_spelllang(win_T *wp)
{
garray_T ga;
char_u *splp;
char *splp;
char_u *region;
char_u region_cp[3];
bool filename;
@ -2051,7 +2051,7 @@ char *did_set_spelllang(win_T *wp)
int len;
char_u *p;
int round;
char_u *spf;
char *spf;
char_u *use_region = NULL;
bool dont_use_region = false;
bool nobreak = false;
@ -2081,9 +2081,9 @@ char *did_set_spelllang(win_T *wp)
wp->w_s->b_cjk = 0;
// Loop over comma separated language names.
for (splp = spl_copy; *splp != NUL;) {
for (splp = (char *)spl_copy; *splp != NUL;) {
// Get one language name.
copy_option_part((char **)&splp, (char *)lang, MAXWLEN, ",");
copy_option_part(&splp, (char *)lang, MAXWLEN, ",");
region = NULL;
len = (int)STRLEN(lang);
@ -2205,8 +2205,8 @@ char *did_set_spelllang(win_T *wp)
// round 1: load first name in 'spellfile'.
// round 2: load second name in 'spellfile.
// etc.
spf = curwin->w_s->b_p_spf;
for (round = 0; round == 0 || *spf != NUL; ++round) {
spf = (char *)curwin->w_s->b_p_spf;
for (round = 0; round == 0 || *spf != NUL; round++) {
if (round == 0) {
// Internal wordlist, if there is one.
if (int_wordlist == NULL) {
@ -2215,7 +2215,7 @@ char *did_set_spelllang(win_T *wp)
int_wordlist_spl(spf_name);
} else {
// One entry in 'spellfile'.
copy_option_part((char **)&spf, (char *)spf_name, MAXPATHL - 5, ",");
copy_option_part(&spf, (char *)spf_name, MAXPATHL - 5, ",");
STRCAT(spf_name, ".spl");
// If it was already found above then skip it.
@ -2796,21 +2796,21 @@ static int sps_limit = 9999; // max nr of suggestions given
// Sets "sps_flags" and "sps_limit".
int spell_check_sps(void)
{
char_u *p;
char_u *s;
char *p;
char *s;
char_u buf[MAXPATHL];
int f;
sps_flags = 0;
sps_limit = 9999;
for (p = p_sps; *p != NUL;) {
copy_option_part((char **)&p, (char *)buf, MAXPATHL, ",");
for (p = (char *)p_sps; *p != NUL;) {
copy_option_part(&p, (char *)buf, MAXPATHL, ",");
f = 0;
if (ascii_isdigit(*buf)) {
s = buf;
sps_limit = getdigits_int((char **)&s, true, 0);
s = (char *)buf;
sps_limit = getdigits_int(&s, true, 0);
if (*s != NUL && !ascii_isdigit(*s)) {
f = -1;
}
@ -3240,7 +3240,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
{
hlf_T attr = HLF_COUNT;
char_u buf[MAXPATHL];
char_u *p;
char *p;
bool do_combine = false;
char_u *sps_copy;
static bool expr_busy = false;
@ -3325,8 +3325,8 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
sps_copy = vim_strsave(p_sps);
// Loop over the items in 'spellsuggest'.
for (p = sps_copy; *p != NUL;) {
copy_option_part((char **)&p, (char *)buf, MAXPATHL, ",");
for (p = (char *)sps_copy; *p != NUL;) {
copy_option_part(&p, (char *)buf, MAXPATHL, ",");
if (STRNCMP(buf, "expr:", 5) == 0) {
// Evaluate an expression. Skip this when called recursively,

View File

@ -1408,8 +1408,7 @@ static int read_compound(FILE *fd, slang_T *slang, int len)
ga_init(gap, sizeof(char_u *), c);
ga_grow(gap, c);
while (--c >= 0) {
((char_u **)(gap->ga_data))[gap->ga_len++] =
read_cnt_string(fd, 1, &cnt);
((char **)(gap->ga_data))[gap->ga_len++] = (char *)read_cnt_string(fd, 1, &cnt);
// <comppatlen> <comppattext>
if (cnt < 0) {
return cnt;
@ -2300,18 +2299,15 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
// Only add the couple if it isn't already there.
for (i = 0; i < gap->ga_len - 1; i += 2) {
if (STRCMP(((char_u **)(gap->ga_data))[i], items[1]) == 0
&& STRCMP(((char_u **)(gap->ga_data))[i + 1],
items[2]) == 0) {
if (STRCMP(((char **)(gap->ga_data))[i], items[1]) == 0
&& STRCMP(((char **)(gap->ga_data))[i + 1], items[2]) == 0) {
break;
}
}
if (i >= gap->ga_len) {
ga_grow(gap, 2);
((char_u **)(gap->ga_data))[gap->ga_len++]
= getroom_save(spin, items[1]);
((char_u **)(gap->ga_data))[gap->ga_len++]
= getroom_save(spin, items[2]);
((char **)(gap->ga_data))[gap->ga_len++] = (char *)getroom_save(spin, items[1]);
((char **)(gap->ga_data))[gap->ga_len++] = (char *)getroom_save(spin, items[2]);
}
} else if (is_aff_rule(items, itemcnt, "SYLLABLE", 2)
&& syllable == NULL) {
@ -2968,7 +2964,7 @@ static void check_renumber(spellinfo_T *spin)
// Returns true if flag "flag" appears in affix list "afflist".
static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
{
char_u *p;
char *p;
unsigned n;
switch (flagtype) {
@ -2977,7 +2973,7 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
case AFT_CAPLONG:
case AFT_LONG:
for (p = afflist; *p != NUL;) {
for (p = (char *)afflist; *p != NUL;) {
n = (unsigned)mb_ptr2char_adv((const char_u **)&p);
if ((flagtype == AFT_LONG || (n >= 'A' && n <= 'Z'))
&& *p != NUL) {
@ -2990,8 +2986,8 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
break;
case AFT_NUM:
for (p = afflist; *p != NUL;) {
int digits = getdigits_int((char **)&p, true, 0);
for (p = (char *)afflist; *p != NUL;) {
int digits = getdigits_int(&p, true, 0);
assert(digits >= 0);
n = (unsigned int)digits;
if (n == 0) {
@ -4644,8 +4640,8 @@ static int write_vim_spell(spellinfo_T *spin, char_u *fname)
size_t l = STRLEN(spin->si_compflags);
assert(spin->si_comppat.ga_len >= 0);
for (size_t i = 0; i < (size_t)spin->si_comppat.ga_len; ++i) {
l += STRLEN(((char_u **)(spin->si_comppat.ga_data))[i]) + 1;
for (size_t i = 0; i < (size_t)spin->si_comppat.ga_len; i++) {
l += STRLEN(((char **)(spin->si_comppat.ga_data))[i]) + 1;
}
put_bytes(fd, l + 7, 4); // <sectionlen>
@ -4655,8 +4651,8 @@ static int write_vim_spell(spellinfo_T *spin, char_u *fname)
putc(0, fd); // for Vim 7.0b compatibility
putc(spin->si_compoptions, fd); // <compoptions>
put_bytes(fd, (uintmax_t)spin->si_comppat.ga_len, 2); // <comppatcount>
for (size_t i = 0; i < (size_t)spin->si_comppat.ga_len; ++i) {
char_u *p = ((char_u **)(spin->si_comppat.ga_data))[i];
for (size_t i = 0; i < (size_t)spin->si_comppat.ga_len; i++) {
char *p = ((char **)(spin->si_comppat.ga_data))[i];
assert(STRLEN(p) < INT_MAX);
putc((int)STRLEN(p), fd); // <comppatlen>
fwv &= fwrite(p, STRLEN(p), 1, fd); // <comppattext>
@ -5815,7 +5811,7 @@ static int write_spell_prefcond(FILE *fd, garray_T *gap, size_t *fwv)
size_t totlen = 2 + (size_t)gap->ga_len; // <prefcondcnt> and <condlen> bytes
for (int i = 0; i < gap->ga_len; i++) {
// <prefcond> : <condlen> <condstr>
char_u *p = ((char_u **)gap->ga_data)[i];
char *p = ((char **)gap->ga_data)[i];
if (p != NULL) {
size_t len = STRLEN(p);
if (fd != NULL) {

View File

@ -191,7 +191,7 @@ char *vim_strnsave_unquoted(const char *const string, const size_t length)
char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_newline)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
{
char_u *d;
char *d;
char_u *escaped_string;
size_t l;
int csh_like;
@ -238,7 +238,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
// Allocate memory for the result and fill it.
escaped_string = xmalloc(length);
d = escaped_string;
d = (char *)escaped_string;
// add opening quote
#ifdef WIN32
@ -248,7 +248,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
#endif
*d++ = '\'';
for (const char_u *p = string; *p != NUL;) {
for (const char *p = (char *)string; *p != NUL;) {
#ifdef WIN32
if (!p_ssl) {
if (*p == '"') {
@ -276,7 +276,7 @@ char_u *vim_strsave_shellescape(const char_u *string, bool do_special, bool do_n
*d++ = *p++;
continue;
}
if (do_special && find_cmdline_var(p, &l) >= 0) {
if (do_special && find_cmdline_var((char_u *)p, &l) >= 0) {
*d++ = '\\'; // insert backslash
while (--l != SIZE_MAX) { // copy the var
*d++ = *p++;

View File

@ -5049,7 +5049,7 @@ static void init_syn_patterns(void)
*/
static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
{
char_u *end;
char *end;
int *p;
int idx;
char *cpo_save;
@ -5059,13 +5059,13 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
return NULL;
}
end = skip_regexp(arg + 1, *arg, TRUE, NULL);
if (*end != *arg) { // end delimiter not found
end = (char *)skip_regexp(arg + 1, *arg, true, NULL);
if (*end != (char)(*arg)) { // end delimiter not found
semsg(_("E401: Pattern delimiter not found: %s"), arg);
return NULL;
}
// store the pattern and compiled regexp program
ci->sp_pattern = vim_strnsave(arg + 1, (size_t)(end - arg) - 1);
ci->sp_pattern = vim_strnsave(arg + 1, (size_t)(end - (char *)arg) - 1);
// Make 'cpoptions' empty, to avoid the 'l' flag
cpo_save = p_cpo;
@ -5107,7 +5107,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
ci->sp_off_flags |= (int16_t)(1 << idx);
if (idx == SPO_LC_OFF) { // lc=99
end += 3;
*p = getdigits_int((char **)&end, true, 0);
*p = getdigits_int(&end, true, 0);
// "lc=" offset automatically sets "ms=" offset
if (!(ci->sp_off_flags & (1 << SPO_MS_OFF))) {
@ -5118,10 +5118,10 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
end += 4;
if (*end == '+') {
end++;
*p = getdigits_int((char **)&end, true, 0); // positive offset
*p = getdigits_int(&end, true, 0); // positive offset
} else if (*end == '-') {
end++;
*p = -getdigits_int((char **)&end, true, 0); // negative offset
*p = -getdigits_int(&end, true, 0); // negative offset
}
}
if (*end != ',') {
@ -5136,7 +5136,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
semsg(_("E402: Garbage after pattern: %s"), arg);
return NULL;
}
return (char_u *)skipwhite((char *)end);
return (char_u *)skipwhite(end);
}
/*
@ -5145,7 +5145,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
static void syn_cmd_sync(exarg_T *eap, int syncing)
{
char_u *arg_start = (char_u *)eap->arg;
char_u *arg_end;
char *arg_end;
char_u *key = NULL;
char_u *next_arg;
int illegal = false;
@ -5158,21 +5158,21 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
}
while (!ends_excmd(*arg_start)) {
arg_end = skiptowhite(arg_start);
next_arg = (char_u *)skipwhite((char *)arg_end);
arg_end = (char *)skiptowhite(arg_start);
next_arg = (char_u *)skipwhite(arg_end);
xfree(key);
key = vim_strnsave_up(arg_start, (size_t)(arg_end - arg_start));
key = vim_strnsave_up(arg_start, (size_t)(arg_end - (char *)arg_start));
if (STRCMP(key, "CCOMMENT") == 0) {
if (!eap->skip) {
curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
}
if (!ends_excmd(*next_arg)) {
arg_end = skiptowhite(next_arg);
arg_end = (char *)skiptowhite(next_arg);
if (!eap->skip) {
curwin->w_s->b_syn_sync_id =
(int16_t)syn_check_group((char *)next_arg, (size_t)(arg_end - next_arg));
(int16_t)syn_check_group((char *)next_arg, (size_t)(arg_end - (char *)next_arg));
}
next_arg = (char_u *)skipwhite((char *)arg_end);
next_arg = (char_u *)skipwhite(arg_end);
} else if (!eap->skip) {
curwin->w_s->b_syn_sync_id = (int16_t)syn_name2id("Comment");
}
@ -5181,17 +5181,17 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
|| STRNCMP(key, "MAXLINES", 8) == 0
|| STRNCMP(key, "LINEBREAKS", 10) == 0) {
if (key[4] == 'S') {
arg_end = key + 6;
arg_end = (char *)key + 6;
} else if (key[0] == 'L') {
arg_end = key + 11;
arg_end = (char *)key + 11;
} else {
arg_end = key + 9;
arg_end = (char *)key + 9;
}
if (arg_end[-1] != '=' || !ascii_isdigit(*arg_end)) {
illegal = TRUE;
break;
}
linenr_T n = getdigits_int32((char **)&arg_end, false, 0);
linenr_T n = getdigits_int32(&arg_end, false, 0);
if (!eap->skip) {
if (key[4] == 'B') {
curwin->w_s->b_syn_sync_linebreaks = n;
@ -5216,16 +5216,16 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
finished = TRUE;
break;
}
arg_end = skip_regexp(next_arg + 1, *next_arg, TRUE, NULL);
if (*arg_end != *next_arg) { // end delimiter not found
illegal = TRUE;
arg_end = (char *)skip_regexp(next_arg + 1, *next_arg, true, NULL);
if (*arg_end != (char)(*next_arg)) { // end delimiter not found
illegal = true;
break;
}
if (!eap->skip) {
// store the pattern and compiled regexp program
curwin->w_s->b_syn_linecont_pat =
vim_strnsave(next_arg + 1, (size_t)(arg_end - next_arg) - 1);
vim_strnsave(next_arg + 1, (size_t)(arg_end - (char *)next_arg) - 1);
curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic;
// Make 'cpoptions' empty, to avoid the 'l' flag
@ -5242,7 +5242,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
break;
}
}
next_arg = (char_u *)skipwhite((char *)arg_end + 1);
next_arg = (char_u *)skipwhite(arg_end + 1);
} else {
eap->arg = (char *)next_arg;
if (STRCMP(key, "MATCH") == 0) {

View File

@ -1320,7 +1320,7 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
// Add all matches because tagfunc should do filtering.
ga_grow(ga, 1);
((char_u **)(ga->ga_data))[ga->ga_len++] = mfp;
((char **)(ga->ga_data))[ga->ga_len++] = (char *)mfp;
ntags++;
result = OK;
});
@ -1411,7 +1411,7 @@ int find_tags(char_u *pat, int *num_matches, char ***matchesp, int flags, int mi
int matchoff = 0;
int save_emsg_off;
char_u *mfp;
char *mfp;
garray_T ga_match[MT_COUNT]; // stores matches in sequence
hashtab_T ht_match[MT_COUNT]; // stores matches by key
hash_T hash = 0;
@ -1476,7 +1476,7 @@ int find_tags(char_u *pat, int *num_matches, char ***matchesp, int flags, int mi
lbuf = xmalloc((size_t)lbuf_size);
tag_fname = xmalloc(MAXPATHL + 1);
for (mtt = 0; mtt < MT_COUNT; mtt++) {
ga_init(&ga_match[mtt], sizeof(char_u *), 100);
ga_init(&ga_match[mtt], sizeof(char *), 100);
hash_init(&ht_match[mtt]);
}
@ -2088,9 +2088,9 @@ parse_line:
// The format is {tagname}@{lang}NUL{heuristic}NUL
*tagp.tagname_end = NUL;
len = (size_t)(tagp.tagname_end - tagp.tagname);
mfp = xmalloc(sizeof(char_u) + len + 10 + ML_EXTRA + 1);
mfp = xmalloc(sizeof(char) + len + 10 + ML_EXTRA + 1);
p = mfp;
p = (char_u *)mfp;
STRCPY(p, tagp.tagname);
p[len] = '@';
STRCPY(p + len + 1, help_lang);
@ -2122,7 +2122,7 @@ parse_line:
get_it_again = false;
} else {
len = (size_t)(tagp.tagname_end - tagp.tagname);
mfp = xmalloc(sizeof(char_u) + len + 1);
mfp = xmalloc(sizeof(char) + len + 1);
STRLCPY(mfp, tagp.tagname, len + 1);
// if wanted, re-read line to get long form too
@ -2140,8 +2140,8 @@ parse_line:
// without Emacs tags: <mtt><tag_fname><0x02><lbuf><NUL>
// Here <mtt> is the "mtt" value plus 1 to avoid NUL.
len = tag_fname_len + STRLEN(lbuf) + 3;
mfp = xmalloc(sizeof(char_u) + len + 1);
p = mfp;
mfp = xmalloc(sizeof(char) + len + 1);
p = (char_u *)mfp;
p[0] = (char_u)(mtt + 1);
STRCPY(p + 1, tag_fname);
#ifdef BACKSLASH_IN_FILENAME
@ -2166,15 +2166,14 @@ parse_line:
if (use_cscope) {
hash++;
} else {
hash = hash_hash(mfp);
hash = hash_hash((char_u *)mfp);
}
hi = hash_lookup(&ht_match[mtt], (const char *)mfp,
STRLEN(mfp), hash);
if (HASHITEM_EMPTY(hi)) {
hash_add_item(&ht_match[mtt], hi, mfp, hash);
hash_add_item(&ht_match[mtt], hi, (char_u *)mfp, hash);
ga_grow(&ga_match[mtt], 1);
((char_u **)(ga_match[mtt].ga_data))
[ga_match[mtt].ga_len++] = mfp;
((char **)(ga_match[mtt].ga_data))[ga_match[mtt].ga_len++] = mfp;
match_count++;
} else {
// duplicate tag, drop it
@ -2258,29 +2257,29 @@ findtag_end:
}
if (match_count > 0) {
matches = xmalloc((size_t)match_count * sizeof(char_u *));
matches = xmalloc((size_t)match_count * sizeof(char *));
} else {
matches = NULL;
}
match_count = 0;
for (mtt = 0; mtt < MT_COUNT; mtt++) {
for (i = 0; i < ga_match[mtt].ga_len; i++) {
mfp = ((char_u **)(ga_match[mtt].ga_data))[i];
mfp = ((char **)(ga_match[mtt].ga_data))[i];
if (matches == NULL) {
xfree(mfp);
} else {
if (!name_only) {
// Change mtt back to zero-based.
*mfp = (char_u)(*mfp - 1);
*mfp = (char)(*mfp - 1);
// change the TAG_SEP back to NUL
for (p = mfp + 1; *p != NUL; p++) {
for (p = (char_u *)mfp + 1; *p != NUL; p++) {
if (*p == TAG_SEP) {
*p = NUL;
}
}
}
matches[match_count++] = (char *)mfp;
matches[match_count++] = mfp;
}
}
@ -2353,7 +2352,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
*/
if (first) {
ga_clear_strings(&tag_fnames);
ga_init(&tag_fnames, (int)sizeof(char_u *), 10);
ga_init(&tag_fnames, (int)sizeof(char *), 10);
do_in_runtimepath("doc/tags doc/tags-??", DIP_ALL,
found_tagfile_cb, NULL);
}
@ -2373,13 +2372,12 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
simplify_filename(buf);
for (int i = 0; i < tag_fnames.ga_len; i++) {
if (STRCMP(buf, ((char_u **)(tag_fnames.ga_data))[i]) == 0) {
if (STRCMP(buf, ((char **)(tag_fnames.ga_data))[i]) == 0) {
return FAIL; // avoid duplicate file names
}
}
} else {
STRLCPY(buf, ((char_u **)(tag_fnames.ga_data))[tnp->tn_hf_idx++],
MAXPATHL);
STRLCPY(buf, ((char **)(tag_fnames.ga_data))[tnp->tn_hf_idx++], MAXPATHL);
}
return OK;
}
@ -2387,9 +2385,8 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
if (first) {
// Init. We make a copy of 'tags', because autocommands may change
// the value without notifying us.
tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL)
? curbuf->b_p_tags : p_tags);
tnp->tn_np = tnp->tn_tags;
tnp->tn_tags = vim_strsave((*curbuf->b_p_tags != NUL) ? curbuf->b_p_tags : p_tags);
tnp->tn_np = (char *)tnp->tn_tags;
}
/*
@ -2420,7 +2417,7 @@ int get_tagfname(tagname_T *tnp, int first, char_u *buf)
* Copy next file name into buf.
*/
buf[0] = NUL;
(void)copy_option_part((char **)&tnp->tn_np, (char *)buf, MAXPATHL - 1, " ,");
(void)copy_option_part(&tnp->tn_np, (char *)buf, MAXPATHL - 1, " ,");
r_ptr = vim_findfile_stopdir(buf);
// move the filename one char forward and truncate the

View File

@ -35,7 +35,7 @@
// Structure used for get_tagfname().
typedef struct {
char_u *tn_tags; // value of 'tags' when starting
char_u *tn_np; // current position in tn_tags
char *tn_np; // current position in tn_tags
int tn_did_filefind_init;
int tn_hf_idx;
void *tn_search_ctx;

View File

@ -681,7 +681,7 @@ static bool is_filter_char(int c)
return !!(tpf_flags & flag);
}
void terminal_paste(long count, char_u **y_array, size_t y_size)
void terminal_paste(long count, char **y_array, size_t y_size)
{
if (y_size == 0) {
return;
@ -702,7 +702,7 @@ void terminal_paste(long count, char_u **y_array, size_t y_size)
buff_len = len;
}
char_u *dst = buff;
char_u *src = y_array[j];
char_u *src = (char_u *)y_array[j];
while (*src != '\0') {
len = (size_t)utf_ptr2len((char *)src);
int c = utf_ptr2char((char *)src);

View File

@ -1162,7 +1162,7 @@ static char *uc_split_args(char *arg, char **args, size_t *arglens, size_t argc,
*q++ = ' ';
*q++ = '"';
} else {
mb_copy_char((const char_u **)&p, (char_u **)&q);
mb_copy_char((const char **)&p, &q);
}
}
} else {
@ -1175,7 +1175,7 @@ static char *uc_split_args(char *arg, char **args, size_t *arglens, size_t argc,
*q++ = '\\';
*q++ = *p++;
} else {
mb_copy_char((const char_u **)&p, (char_u **)&q);
mb_copy_char((const char **)&p, &q);
}
}
if (i != argc - 1) {

View File

@ -2063,7 +2063,7 @@ static void list_features(void)
/// List string items nicely aligned in columns.
/// When "size" is < 0 then the last entry is marked with NULL.
/// The entry with index "current" is inclosed in [].
void list_in_columns(char_u **items, int size, int current)
void list_in_columns(char **items, int size, int current)
{
int item_count = 0;
int width = 0;

View File

@ -1828,13 +1828,13 @@ static void parse_quoted_string(ParserState *const pstate, ExprASTNode *const no
v_p += special_len;
} else {
is_unknown = true;
mb_copy_char((const char_u **)&p, (char_u **)&v_p);
mb_copy_char(&p, &v_p);
}
break;
}
default:
is_unknown = true;
mb_copy_char((const char_u **)&p, (char_u **)&v_p);
mb_copy_char(&p, &v_p);
break;
}
if (pstate->colors) {

View File

@ -122,7 +122,7 @@ void do_window(int nchar, long Prenum, int xchar)
{
long Prenum1;
win_T *wp;
char_u *ptr;
char *ptr;
linenr_T lnum = -1;
int type = FIND_DEFINE;
size_t len;
@ -483,14 +483,14 @@ newwindow:
wingotofile:
CHECK_CMDWIN;
ptr = grab_file_name(Prenum1, &lnum);
ptr = (char *)grab_file_name(Prenum1, &lnum);
if (ptr != NULL) {
tabpage_T *oldtab = curtab;
win_T *oldwin = curwin;
setpcmark();
if (win_split(0, 0) == OK) {
RESET_BINDING(curwin);
if (do_ecmd(0, (char *)ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE, NULL) == FAIL) {
if (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE, NULL) == FAIL) {
// Failed to open the file, close the window opened for it.
win_close(curwin, false, false);
goto_tabpage_win(oldtab, oldwin);
@ -518,9 +518,9 @@ wingotofile:
}
// Make a copy, if the line was changed it will be freed.
ptr = vim_strnsave(ptr, len);
ptr = xstrnsave(ptr, len);
find_pattern_in_path(ptr, 0, len, true, Prenum == 0,
find_pattern_in_path((char_u *)ptr, 0, len, true, Prenum == 0,
type, Prenum1, ACTION_SPLIT, 1, MAXLNUM);
xfree(ptr);
curwin->w_set_curswant = true;
@ -6465,17 +6465,17 @@ char_u *grab_file_name(long count, linenr_T *file_lnum)
int options = FNAME_MESS | FNAME_EXP | FNAME_REL | FNAME_UNESC;
if (VIsual_active) {
size_t len;
char_u *ptr;
char *ptr;
if (get_visual_text(NULL, &ptr, &len) == FAIL) {
return NULL;
}
// Only recognize ":123" here
if (file_lnum != NULL && ptr[len] == ':' && isdigit(ptr[len + 1])) {
char *p = (char *)ptr + len + 1;
char *p = ptr + len + 1;
*file_lnum = (linenr_T)getdigits_long(&p, false, 0);
}
return find_file_name_in_path(ptr, len, options, count, (char_u *)curbuf->b_ffname);
return find_file_name_in_path((char_u *)ptr, len, options, count, (char_u *)curbuf->b_ffname);
}
return file_name_at_cursor(options | FNAME_HYP, count, file_lnum);
}