aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index cdf1564761..e845073c12 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1927,7 +1927,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
++p;
}
p = xstrnsave(ea.cmd, (size_t)(p - ea.cmd));
- int ret = apply_autocmds(EVENT_CMDUNDEFINED, (char_u *)p, (char_u *)p, true, NULL);
+ int ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, true, NULL);
xfree(p);
// If the autocommands did something and didn't cause an error, try
// finding the command again.
@@ -2554,7 +2554,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
break;
}
if (!skip_only) {
- cmdmod.filter_regmatch.regprog = vim_regcomp((char_u *)reg_pat, RE_MAGIC);
+ cmdmod.filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC);
if (cmdmod.filter_regmatch.regprog == NULL) {
break;
}
@@ -2971,7 +2971,7 @@ char *find_ex_command(exarg_T *eap, int *full)
}
// check for non-alpha command
- if (p == eap->cmd && vim_strchr((char_u *)"@!=><&~#", *p) != NULL) {
+ if (p == eap->cmd && vim_strchr("@!=><&~#", *p) != NULL) {
p++;
}
len = (int)(p - eap->cmd);
@@ -3297,7 +3297,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
// 2. skip comment lines and leading space, colons or bars
const char *cmd;
- for (cmd = buff; vim_strchr((const char_u *)" \t:|", *cmd) != NULL; cmd++) {}
+ for (cmd = buff; vim_strchr(" \t:|", *cmd) != NULL; cmd++) {}
xp->xp_pattern = (char *)cmd;
if (*cmd == NUL) {
@@ -3358,7 +3358,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
}
}
// check for non-alpha command
- if (p == cmd && vim_strchr((const char_u *)"@*!=><&~#", *p) != NULL) {
+ if (p == cmd && vim_strchr("@*!=><&~#", *p) != NULL) {
p++;
}
len = (size_t)(p - cmd);
@@ -3390,7 +3390,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
}
if (ea.cmdidx == CMD_SIZE) {
- if (*cmd == 's' && vim_strchr((const char_u *)"cgriI", cmd[1]) != NULL) {
+ if (*cmd == 's' && vim_strchr("cgriI", cmd[1]) != NULL) {
ea.cmdidx = CMD_substitute;
p = cmd + 1;
} else if (cmd[0] >= 'A' && cmd[0] <= 'Z') {
@@ -4135,7 +4135,7 @@ const char *set_one_cmd_context(expand_T *xp, const char *buff)
break;
case CMD_argdelete:
- while ((xp->xp_pattern = (char *)vim_strchr((const char_u *)arg, ' ')) != NULL) {
+ while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) {
arg = (const char *)(xp->xp_pattern + 1);
}
xp->xp_context = EXPAND_ARGLIST;
@@ -4166,7 +4166,7 @@ char *skip_range(const char *cmd, int *ctx)
{
unsigned delim;
- while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) {
+ while (vim_strchr(" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) {
if (*cmd == '\\') {
if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&') {
cmd++;
@@ -4536,7 +4536,7 @@ error:
/// Get flags from an Ex command argument.
static void get_flags(exarg_T *eap)
{
- while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) {
+ while (vim_strchr("lp#", *eap->arg) != NULL) {
if (*eap->arg == 'l') {
eap->flags |= EXFLAG_LIST;
} else if (*eap->arg == 'p') {
@@ -4792,8 +4792,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
* Quick check if this cannot be the start of a special string.
* Also removes backslash before '%', '#' and '<'.
*/
- if (vim_strchr((char_u *)"%#<", *p) == NULL) {
- ++p;
+ if (vim_strchr("%#<", *p) == NULL) {
+ p++;
continue;
}
@@ -4812,10 +4812,10 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
// Wildcards won't be expanded below, the replacement is taken
// literally. But do expand "~/file", "~user/file" and "$HOME/file".
- if (vim_strchr((char_u *)repl, '$') != NULL || vim_strchr((char_u *)repl, '~') != NULL) {
+ if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) {
char *l = repl;
- repl = (char *)expand_env_save((char_u *)repl);
+ repl = expand_env_save(repl);
xfree(l);
}
@@ -4845,8 +4845,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
# define ESCAPE_CHARS escape_chars
#endif
- for (l = repl; *l; ++l) {
- if (vim_strchr(ESCAPE_CHARS, *l) != NULL) {
+ for (l = repl; *l; l++) {
+ if (vim_strchr((char *)ESCAPE_CHARS, *l) != NULL) {
l = (char *)vim_strsave_escaped((char_u *)repl, ESCAPE_CHARS);
xfree(repl);
repl = l;
@@ -4885,8 +4885,8 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp)
* After expanding environment variables, check again
* if there are still wildcards present.
*/
- if (vim_strchr((char_u *)eap->arg, '$') != NULL
- || vim_strchr((char_u *)eap->arg, '~') != NULL) {
+ if (vim_strchr(eap->arg, '$') != NULL
+ || vim_strchr(eap->arg, '~') != NULL) {
expand_env_esc((char_u *)eap->arg, NameBuff, MAXPATHL, true, true, NULL);
has_wildcards = path_has_wildcard(NameBuff);
p = (char *)NameBuff;
@@ -6338,7 +6338,7 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
ct_NONE,
} type = ct_NONE;
- if ((vim_strchr((char_u *)"qQfF", *p) != NULL) && p[1] == '-') {
+ if ((vim_strchr("qQfF", *p) != NULL) && p[1] == '-') {
quote = (*p == 'q' || *p == 'Q') ? 1 : 2;
p += 2;
l -= 2;
@@ -6643,9 +6643,9 @@ static void do_ucmd(exarg_T *eap)
totlen = 0;
for (;;) {
- start = (char *)vim_strchr((char_u *)p, '<');
+ start = vim_strchr(p, '<');
if (start != NULL) {
- end = (char *)vim_strchr((char_u *)start + 1, '>');
+ end = vim_strchr(start + 1, '>');
}
if (buf != NULL) {
for (ksp = p; *ksp != NUL && (char_u)(*ksp) != K_SPECIAL; ksp++) {}
@@ -7781,7 +7781,7 @@ static void ex_tabs(exarg_T *eap)
if (buf_spname(wp->w_buffer) != NULL) {
STRLCPY(IObuff, buf_spname(wp->w_buffer), IOSIZE);
} else {
- home_replace(wp->w_buffer, wp->w_buffer->b_fname, IObuff, IOSIZE, true);
+ home_replace(wp->w_buffer, (char_u *)wp->w_buffer->b_fname, IObuff, IOSIZE, true);
}
msg_outtrans(IObuff);
ui_flush(); // output one line at a time
@@ -8096,7 +8096,7 @@ static void ex_read(exarg_T *eap)
if (check_fname() == FAIL) { // check for no file name
return;
}
- i = readfile((char *)curbuf->b_ffname, (char *)curbuf->b_fname,
+ i = readfile((char *)curbuf->b_ffname, curbuf->b_fname,
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false);
} else {
if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) {
@@ -8175,7 +8175,7 @@ static void post_chdir(CdScope scope, bool trigger_dirchanged)
char *pdir = get_prevdir(scope);
// If still in global directory, set CWD as the global directory.
if (globaldir == NULL && pdir != NULL) {
- globaldir = vim_strsave((char_u *)pdir);
+ globaldir = xstrdup(pdir);
}
}
@@ -8593,8 +8593,7 @@ static void ex_at(exarg_T *eap)
}
// Put the register in the typeahead buffer with the "silent" flag.
- if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE)
- == FAIL) {
+ if (do_execreg(c, true, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, true) == FAIL) {
beep_flush();
} else {
bool save_efr = exec_from_reg;
@@ -8737,7 +8736,7 @@ static void ex_redir(exarg_T *eap)
close_redir();
// Expand environment variables and "~/".
- fname = (char *)expand_env_save((char_u *)arg);
+ fname = expand_env_save(arg);
if (fname == NULL) {
return;
}
@@ -9478,7 +9477,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
result = "";
valid = 0; // Must have ":p:h" to be valid
} else {
- result = (char *)curbuf->b_fname;
+ result = curbuf->b_fname;
tilde_file = STRCMP(result, "~") == 0;
}
break;
@@ -9532,7 +9531,7 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum
result = "";
valid = 0; // Must have ":p:h" to be valid
} else {
- result = (char *)buf->b_fname;
+ result = buf->b_fname;
tilde_file = STRCMP(result, "~") == 0;
}
}