*: Use const char * in set_one_cmd_context

Also renames functions added in master and renamed here.
This commit is contained in:
ZyX 2017-03-28 02:17:51 +03:00
parent 114eaa15f0
commit a1d590a08b
7 changed files with 311 additions and 283 deletions

View File

@ -1397,7 +1397,8 @@ void getvcols(win_T *wp, pos_T *pos1, pos_T *pos2, colnr_T *left,
/// ///
/// @return Pointer to character after the skipped whitespace. /// @return Pointer to character after the skipped whitespace.
char_u *skipwhite(const char_u *q) char_u *skipwhite(const char_u *q)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET
{ {
const char_u *p = q; const char_u *p = q;
while (ascii_iswhite(*p)) { while (ascii_iswhite(*p)) {
@ -1406,19 +1407,21 @@ char_u *skipwhite(const char_u *q)
return (char_u *)p; return (char_u *)p;
} }
/// skip over digits /// Skip over digits
/// ///
/// @param q /// @param[in] q String to skip digits in.
/// ///
/// @return Pointer to the character after the skipped digits. /// @return Pointer to the character after the skipped digits.
char_u* skipdigits(char_u *q) char_u *skipdigits(const char_u *q)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
FUNC_ATTR_NONNULL_RET
{ {
char_u *p = q; const char_u *p = q;
while (ascii_isdigit(*p)) { while (ascii_isdigit(*p)) {
// skip to next non-digit // skip to next non-digit
p++; p++;
} }
return p; return (char_u *)p;
} }
/// skip over binary digits /// skip over binary digits
@ -1564,17 +1567,17 @@ int vim_tolower(int c)
return TOLOWER_LOC(c); return TOLOWER_LOC(c);
} }
/// skiptowhite: skip over text until ' ' or '\t' or NUL. /// Skip over text until ' ' or '\t' or NUL
/// ///
/// @param p /// @param[in] p Text to skip over.
/// ///
/// @return Pointer to the next whitespace or NUL character. /// @return Pointer to the next whitespace or NUL character.
char_u* skiptowhite(char_u *p) char_u *skiptowhite(const char_u *p)
{ {
while (*p != ' ' && *p != '\t' && *p != NUL) { while (*p != ' ' && *p != '\t' && *p != NUL) {
p++; p++;
} }
return p; return (char_u *)p;
} }
/// skiptowhite_esc: Like skiptowhite(), but also skip escaped chars /// skiptowhite_esc: Like skiptowhite(), but also skip escaped chars

View File

@ -9462,8 +9462,8 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return; return;
} }
if (STRCMP(get_tv_string(&argvars[1]), "cmdline") == 0) { if (strcmp(tv_get_string(&argvars[1]), "cmdline") == 0) {
set_one_cmd_context(&xpc, get_tv_string(&argvars[0])); set_one_cmd_context(&xpc, tv_get_string(&argvars[0]));
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
goto theend; goto theend;
} }
@ -9484,7 +9484,7 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
if (xpc.xp_context == EXPAND_CSCOPE) { if (xpc.xp_context == EXPAND_CSCOPE) {
set_context_in_cscope_cmd(&xpc, xpc.xp_pattern, CMD_cscope); set_context_in_cscope_cmd(&xpc, (const char *)xpc.xp_pattern, CMD_cscope);
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
} }
@ -14562,7 +14562,7 @@ static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv)
} else if (title_arg->v_type == VAR_STRING) { } else if (title_arg->v_type == VAR_STRING) {
title = tv_get_string_chk(title_arg); title = tv_get_string_chk(title_arg);
if (!title) { if (!title) {
// Type error. Error already printed by get_tv_string_chk(). // Type error. Error already printed by tv_get_string_chk().
return; return;
} }
} else if (title_arg->v_type == VAR_DICT) { } else if (title_arg->v_type == VAR_DICT) {

View File

@ -957,23 +957,21 @@ char_u *get_profile_name(expand_T *xp, int idx)
} }
/// Handle command line completion for :profile command. /// Handle command line completion for :profile command.
void set_context_in_profile_cmd(expand_T *xp, char_u *arg) void set_context_in_profile_cmd(expand_T *xp, const char *arg)
{ {
char_u *end_subcmd;
// Default: expand subcommands. // Default: expand subcommands.
xp->xp_context = EXPAND_PROFILE; xp->xp_context = EXPAND_PROFILE;
pexpand_what = PEXP_SUBCMD; pexpand_what = PEXP_SUBCMD;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
end_subcmd = skiptowhite(arg); char_u *const end_subcmd = skiptowhite((const char_u *)arg);
if (*end_subcmd == NUL) { if (*end_subcmd == NUL) {
return; return;
} }
if (end_subcmd - arg == 5 && STRNCMP(arg, "start", 5) == 0) { if ((const char *)end_subcmd - arg == 5 && strncmp(arg, "start", 5) == 0) {
xp->xp_context = EXPAND_FILES; xp->xp_context = EXPAND_FILES;
xp->xp_pattern = skipwhite(end_subcmd); xp->xp_pattern = skipwhite((const char_u *)end_subcmd);
return; return;
} }

View File

@ -2633,32 +2633,27 @@ int cmd_exists(const char *const name)
* perfectly compatible with each other, but then the command line syntax * perfectly compatible with each other, but then the command line syntax
* probably won't change that much -- webb. * probably won't change that much -- webb.
*/ */
char_u * const char * set_one_cmd_context(
set_one_cmd_context (
expand_T *xp, expand_T *xp,
char_u *buff /* buffer for command string */ const char *buff // buffer for command string
) )
{ {
char_u *p; size_t len = 0;
char_u *cmd, *arg;
int len = 0;
exarg_T ea; exarg_T ea;
int compl = EXPAND_NOTHING; int context = EXPAND_NOTHING;
int delim; int forceit = false;
int forceit = FALSE; int usefilter = false; // Filter instead of file name.
int usefilter = FALSE; /* filter instead of file name */
ExpandInit(xp); ExpandInit(xp);
xp->xp_pattern = buff; xp->xp_pattern = (char_u *)buff;
xp->xp_context = EXPAND_COMMANDS; /* Default until we get past command */ xp->xp_context = EXPAND_COMMANDS; // Default until we get past command
ea.argt = 0; ea.argt = 0;
/* // 2. skip comment lines and leading space, colons or bars
* 2. skip comment lines and leading space, colons or bars const char *cmd;
*/ for (cmd = buff; strchr(" \t:|", *cmd) != NULL; cmd++) {
for (cmd = buff; vim_strchr((char_u *)" \t:|", *cmd) != NULL; cmd++) }
; xp->xp_pattern = (char_u *)cmd;
xp->xp_pattern = cmd;
if (*cmd == NUL) if (*cmd == NUL)
return NULL; return NULL;
@ -2670,14 +2665,15 @@ set_one_cmd_context (
/* /*
* 3. parse a range specifier of the form: addr [,addr] [;addr] .. * 3. parse a range specifier of the form: addr [,addr] [;addr] ..
*/ */
cmd = skip_range(cmd, &xp->xp_context); cmd = (const char *)skip_range((const char_u *)cmd, &xp->xp_context);
/* /*
* 4. parse command * 4. parse command
*/ */
xp->xp_pattern = cmd; xp->xp_pattern = (char_u *)cmd;
if (*cmd == NUL) if (*cmd == NUL) {
return NULL; return NULL;
}
if (*cmd == '"') { if (*cmd == '"') {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
return NULL; return NULL;
@ -2693,6 +2689,7 @@ set_one_cmd_context (
* do accept "keepmarks", "keepalt" and "keepjumps". * do accept "keepmarks", "keepalt" and "keepjumps".
* - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
*/ */
const char *p;
if (*cmd == 'k' && cmd[1] != 'e') { if (*cmd == 'k' && cmd[1] != 'e') {
ea.cmdidx = CMD_k; ea.cmdidx = CMD_k;
p = cmd + 1; p = cmd + 1;
@ -2715,20 +2712,21 @@ set_one_cmd_context (
} }
} }
// check for non-alpha command // check for non-alpha command
if (p == cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) { if (p == cmd && strchr("@*!=><&~#", *p) != NULL) {
p++; p++;
} }
len = (int)(p - cmd); len = (size_t)(p - cmd);
if (len == 0) { if (len == 0) {
xp->xp_context = EXPAND_UNSUCCESSFUL; xp->xp_context = EXPAND_UNSUCCESSFUL;
return NULL; return NULL;
} }
for (ea.cmdidx = (cmdidx_T)0; (int)ea.cmdidx < (int)CMD_SIZE; for (ea.cmdidx = (cmdidx_T)0; (int)ea.cmdidx < (int)CMD_SIZE;
ea.cmdidx = (cmdidx_T)((int)ea.cmdidx + 1)) ea.cmdidx = (cmdidx_T)((int)ea.cmdidx + 1)) {
if (STRNCMP(cmdnames[(int)ea.cmdidx].cmd_name, cmd, if (STRNCMP(cmdnames[(int)ea.cmdidx].cmd_name, cmd, len) == 0) {
(size_t)len) == 0)
break; break;
}
}
if (cmd[0] >= 'A' && cmd[0] <= 'Z') { if (cmd[0] >= 'A' && cmd[0] <= 'Z') {
while (ASCII_ISALNUM(*p) || *p == '*') { // Allow * wild card while (ASCII_ISALNUM(*p) || *p == '*') { // Allow * wild card
@ -2745,16 +2743,15 @@ set_one_cmd_context (
return NULL; return NULL;
if (ea.cmdidx == CMD_SIZE) { if (ea.cmdidx == CMD_SIZE) {
if (*cmd == 's' && vim_strchr((char_u *)"cgriI", cmd[1]) != NULL) { if (*cmd == 's' && strchr("cgriI", cmd[1]) != NULL) {
ea.cmdidx = CMD_substitute; ea.cmdidx = CMD_substitute;
p = cmd + 1; p = cmd + 1;
} else if (cmd[0] >= 'A' && cmd[0] <= 'Z') { } else if (cmd[0] >= 'A' && cmd[0] <= 'Z') {
ea.cmd = cmd; ea.cmd = (char_u *)cmd;
p = find_ucmd(&ea, p, NULL, xp, p = (const char *)find_ucmd(&ea, (char_u *)p, NULL, xp, &context);
&compl if (p == NULL) {
); ea.cmdidx = CMD_SIZE; // Ambiguous user command.
if (p == NULL) }
ea.cmdidx = CMD_SIZE; /* ambiguous user command */
} }
} }
if (ea.cmdidx == CMD_SIZE) { if (ea.cmdidx == CMD_SIZE) {
@ -2777,16 +2774,17 @@ set_one_cmd_context (
ea.argt = cmdnames[(int)ea.cmdidx].cmd_argt; ea.argt = cmdnames[(int)ea.cmdidx].cmd_argt;
} }
arg = skipwhite(p); const char *arg = (const char *)skipwhite((const char_u *)p);
if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) { if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) {
if (*arg == '>') { /* append */ if (*arg == '>') { // Append.
if (*++arg == '>') if (*++arg == '>') {
++arg; arg++;
arg = skipwhite(arg); }
} else if (*arg == '!' && ea.cmdidx == CMD_write) { /* :w !filter */ arg = (const char *)skipwhite((const char_u *)arg);
++arg; } else if (*arg == '!' && ea.cmdidx == CMD_write) { // :w !filter
usefilter = TRUE; arg++;
usefilter = true;
} }
} }
@ -2799,23 +2797,24 @@ set_one_cmd_context (
} }
if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) { if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) {
while (*arg == *cmd) /* allow any number of '>' or '<' */ while (*arg == *cmd) { // allow any number of '>' or '<'
++arg; arg++;
arg = skipwhite(arg); }
arg = (const char *)skipwhite((const char_u *)arg);
} }
/* Does command allow "+command"? */ /* Does command allow "+command"? */
if ((ea.argt & EDITCMD) && !usefilter && *arg == '+') { if ((ea.argt & EDITCMD) && !usefilter && *arg == '+') {
/* Check if we're in the +command */ /* Check if we're in the +command */
p = arg + 1; p = arg + 1;
arg = skip_cmd_arg(arg, FALSE); arg = (const char *)skip_cmd_arg((char_u *)arg, false);
/* Still touching the command after '+'? */ /* Still touching the command after '+'? */
if (*arg == NUL) if (*arg == NUL)
return p; return p;
/* Skip space(s) after +command to get to the real argument */ // Skip space(s) after +command to get to the real argument.
arg = skipwhite(arg); arg = (const char *)skipwhite((const char_u *)arg);
} }
/* /*
@ -2844,19 +2843,18 @@ set_one_cmd_context (
} }
// no arguments allowed // no arguments allowed
if (!(ea.argt & EXTRA) && *arg != NUL if (!(ea.argt & EXTRA) && *arg != NUL && strchr("|\"", *arg) == NULL) {
&& vim_strchr((char_u *)"|\"", *arg) == NULL) {
return NULL; return NULL;
} }
/* Find start of last argument (argument just before cursor): */ /* Find start of last argument (argument just before cursor): */
p = buff; p = buff;
xp->xp_pattern = p; xp->xp_pattern = (char_u *)p;
len = (int)STRLEN(buff); len = strlen(buff);
while (*p && p < buff + len) { while (*p && p < buff + len) {
if (*p == ' ' || *p == TAB) { if (*p == ' ' || *p == TAB) {
/* argument starts after a space */ // Argument starts after a space.
xp->xp_pattern = ++p; xp->xp_pattern = (char_u *)++p;
} else { } else {
if (*p == '\\' && *(p + 1) != NUL) if (*p == '\\' && *(p + 1) != NUL)
++p; /* skip over escaped character */ ++p; /* skip over escaped character */
@ -2866,25 +2864,26 @@ set_one_cmd_context (
if (ea.argt & XFILE) { if (ea.argt & XFILE) {
int c; int c;
int in_quote = FALSE; int in_quote = false;
char_u *bow = NULL; /* Beginning of word */ const char *bow = NULL; // Beginning of word.
/* /*
* Allow spaces within back-quotes to count as part of the argument * Allow spaces within back-quotes to count as part of the argument
* being expanded. * being expanded.
*/ */
xp->xp_pattern = skipwhite(arg); xp->xp_pattern = skipwhite((const char_u *)arg);
p = xp->xp_pattern; p = (const char *)xp->xp_pattern;
while (*p != NUL) { while (*p != NUL) {
if (has_mbyte) if (has_mbyte) {
c = mb_ptr2char(p); c = mb_ptr2char((const char_u *)p);
else } else {
c = *p; c = (uint8_t)(*p);
if (c == '\\' && p[1] != NUL) }
++p; if (c == '\\' && p[1] != NUL) {
else if (c == '`') { p++;
} else if (c == '`') {
if (!in_quote) { if (!in_quote) {
xp->xp_pattern = p; xp->xp_pattern = (char_u *)p;
bow = p + 1; bow = p + 1;
} }
in_quote = !in_quote; in_quote = !in_quote;
@ -2897,22 +2896,26 @@ set_one_cmd_context (
|| ascii_iswhite(c)) { || ascii_iswhite(c)) {
len = 0; /* avoid getting stuck when space is in 'isfname' */ len = 0; /* avoid getting stuck when space is in 'isfname' */
while (*p != NUL) { while (*p != NUL) {
if (has_mbyte) if (has_mbyte) {
c = mb_ptr2char(p); c = mb_ptr2char((const char_u *)p);
else } else {
c = *p; c = *p;
if (c == '`' || vim_isfilec_or_wc(c)) }
if (c == '`' || vim_isfilec_or_wc(c)) {
break; break;
if (has_mbyte) }
len = (*mb_ptr2len)(p); if (has_mbyte) {
else len = (size_t)(*mb_ptr2len)((const char_u *)p);
} else {
len = 1; len = 1;
}
mb_ptr_adv(p); mb_ptr_adv(p);
} }
if (in_quote) if (in_quote) {
bow = p; bow = p;
else } else {
xp->xp_pattern = p; xp->xp_pattern = (char_u *)p;
}
p -= len; p -= len;
} }
mb_ptr_adv(p); mb_ptr_adv(p);
@ -2922,8 +2925,9 @@ set_one_cmd_context (
* If we are still inside the quotes, and we passed a space, just * If we are still inside the quotes, and we passed a space, just
* expand from there. * expand from there.
*/ */
if (bow != NULL && in_quote) if (bow != NULL && in_quote) {
xp->xp_pattern = bow; xp->xp_pattern = (char_u *)bow;
}
xp->xp_context = EXPAND_FILES; xp->xp_context = EXPAND_FILES;
/* For a shell command more chars need to be escaped. */ /* For a shell command more chars need to be escaped. */
@ -2931,33 +2935,36 @@ set_one_cmd_context (
#ifndef BACKSLASH_IN_FILENAME #ifndef BACKSLASH_IN_FILENAME
xp->xp_shell = TRUE; xp->xp_shell = TRUE;
#endif #endif
/* When still after the command name expand executables. */ // When still after the command name expand executables.
if (xp->xp_pattern == skipwhite(arg)) if (xp->xp_pattern == skipwhite((const char_u *)arg)) {
xp->xp_context = EXPAND_SHELLCMD; xp->xp_context = EXPAND_SHELLCMD;
} }
}
/* Check for environment variable */ // Check for environment variable.
if (*xp->xp_pattern == '$' if (*xp->xp_pattern == '$') {
) { for (p = (const char *)xp->xp_pattern + 1; *p != NUL; p++) {
for (p = xp->xp_pattern + 1; *p != NUL; ++p) if (!vim_isIDc((uint8_t)(*p))) {
if (!vim_isIDc(*p))
break; break;
}
}
if (*p == NUL) { if (*p == NUL) {
xp->xp_context = EXPAND_ENV_VARS; xp->xp_context = EXPAND_ENV_VARS;
++xp->xp_pattern; xp->xp_pattern++;
/* Avoid that the assignment uses EXPAND_FILES again. */ // Avoid that the assignment uses EXPAND_FILES again.
if (compl != EXPAND_USER_DEFINED && compl != EXPAND_USER_LIST) if (context != EXPAND_USER_DEFINED && context != EXPAND_USER_LIST) {
compl = EXPAND_ENV_VARS; context = EXPAND_ENV_VARS;
}
} }
} }
/* Check for user names */ /* Check for user names */
if (*xp->xp_pattern == '~') { if (*xp->xp_pattern == '~') {
for (p = xp->xp_pattern + 1; *p != NUL && *p != '/'; ++p) for (p = (const char *)xp->xp_pattern + 1; *p != NUL && *p != '/'; p++) {
; }
/* Complete ~user only if it partially matches a user name. // Complete ~user only if it partially matches a user name.
* A full match ~user<Tab> will be replaced by user's home // A full match ~user<Tab> will be replaced by user's home
* directory i.e. something like ~user<Tab> -> /home/user/ */ // directory i.e. something like ~user<Tab> -> /home/user/
if (*p == NUL && p > xp->xp_pattern + 1 if (*p == NUL && p > (const char *)xp->xp_pattern + 1
&& match_user(xp->xp_pattern + 1) == 1) { && match_user(xp->xp_pattern + 1) == 1) {
xp->xp_context = EXPAND_USER; xp->xp_context = EXPAND_USER;
++xp->xp_pattern; ++xp->xp_pattern;
@ -2987,7 +2994,7 @@ set_one_cmd_context (
break; break;
case CMD_help: case CMD_help:
xp->xp_context = EXPAND_HELP; xp->xp_context = EXPAND_HELP;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
/* Command modifiers: return the argument. /* Command modifiers: return the argument.
@ -3030,13 +3037,14 @@ set_one_cmd_context (
if (*arg == NUL || !ends_excmd(*arg)) { if (*arg == NUL || !ends_excmd(*arg)) {
/* also complete "None" */ /* also complete "None" */
set_context_in_echohl_cmd(xp, arg); set_context_in_echohl_cmd(xp, arg);
arg = skipwhite(skiptowhite(arg)); arg = (const char *)skipwhite(skiptowhite((const char_u *)arg));
if (*arg != NUL) { if (*arg != NUL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
arg = skip_regexp(arg + 1, *arg, p_magic, NULL); arg = (const char *)skip_regexp((char_u *)arg + 1, (uint8_t)(*arg),
p_magic, NULL);
} }
} }
return find_nextcmd(arg); return (const char *)find_nextcmd((char_u *)arg);
/* /*
* All completion for the +cmdline_compl feature goes here. * All completion for the +cmdline_compl feature goes here.
@ -3045,15 +3053,15 @@ set_one_cmd_context (
case CMD_command: case CMD_command:
/* Check for attributes */ /* Check for attributes */
while (*arg == '-') { while (*arg == '-') {
arg++; /* Skip "-" */ arg++; // Skip "-".
p = skiptowhite(arg); p = (const char *)skiptowhite((const char_u *)arg);
if (*p == NUL) { if (*p == NUL) {
/* Cursor is still in the attribute */ // Cursor is still in the attribute.
p = vim_strchr(arg, '='); p = strchr(arg, '=');
if (p == NULL) { if (p == NULL) {
/* No "=", so complete attribute names */ // No "=", so complete attribute names.
xp->xp_context = EXPAND_USER_CMD_FLAGS; xp->xp_context = EXPAND_USER_CMD_FLAGS;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
return NULL; return NULL;
} }
@ -3061,73 +3069,81 @@ set_one_cmd_context (
// their arguments as well. // their arguments as well.
if (STRNICMP(arg, "complete", p - arg) == 0) { if (STRNICMP(arg, "complete", p - arg) == 0) {
xp->xp_context = EXPAND_USER_COMPLETE; xp->xp_context = EXPAND_USER_COMPLETE;
xp->xp_pattern = p + 1; xp->xp_pattern = (char_u *)p + 1;
return NULL; return NULL;
} else if (STRNICMP(arg, "nargs", p - arg) == 0) { } else if (STRNICMP(arg, "nargs", p - arg) == 0) {
xp->xp_context = EXPAND_USER_NARGS; xp->xp_context = EXPAND_USER_NARGS;
xp->xp_pattern = p + 1; xp->xp_pattern = (char_u *)p + 1;
return NULL; return NULL;
} else if (STRNICMP(arg, "addr", p - arg) == 0) { } else if (STRNICMP(arg, "addr", p - arg) == 0) {
xp->xp_context = EXPAND_USER_ADDR_TYPE; xp->xp_context = EXPAND_USER_ADDR_TYPE;
xp->xp_pattern = p + 1; xp->xp_pattern = (char_u *)p + 1;
return NULL; return NULL;
} }
return NULL; return NULL;
} }
arg = skipwhite(p); arg = (const char *)skipwhite((char_u *)p);
} }
/* After the attributes comes the new command name */ // After the attributes comes the new command name.
p = skiptowhite(arg); p = (const char *)skiptowhite((const char_u *)arg);
if (*p == NUL) { if (*p == NUL) {
xp->xp_context = EXPAND_USER_COMMANDS; xp->xp_context = EXPAND_USER_COMMANDS;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
} }
/* And finally comes a normal command */ // And finally comes a normal command.
return skipwhite(p); return (const char *)skipwhite((const char_u *)p);
case CMD_delcommand: case CMD_delcommand:
xp->xp_context = EXPAND_USER_COMMANDS; xp->xp_context = EXPAND_USER_COMMANDS;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_global: case CMD_global:
case CMD_vglobal: case CMD_vglobal: {
delim = *arg; /* get the delimiter */ const int delim = (uint8_t)(*arg); // Get the delimiter.
if (delim) if (delim) {
++arg; /* skip delimiter if there is one */ arg++; // Skip delimiter if there is one.
}
while (arg[0] != NUL && arg[0] != delim) { while (arg[0] != NUL && (uint8_t)arg[0] != delim) {
if (arg[0] == '\\' && arg[1] != NUL) if (arg[0] == '\\' && arg[1] != NUL) {
++arg; arg++;
++arg; }
arg++;
} }
if (arg[0] != NUL) if (arg[0] != NUL)
return arg + 1; return arg + 1;
break; break;
}
case CMD_and: case CMD_and:
case CMD_substitute: case CMD_substitute: {
delim = *arg; const int delim = (uint8_t)(*arg);
if (delim) { if (delim) {
/* skip "from" part */ // Skip "from" part.
++arg; arg++;
arg = skip_regexp(arg, delim, p_magic, NULL); arg = (const char *)skip_regexp((char_u *)arg, delim, p_magic, NULL);
} }
/* skip "to" part */ // Skip "to" part.
while (arg[0] != NUL && arg[0] != delim) { while (arg[0] != NUL && (uint8_t)arg[0] != delim) {
if (arg[0] == '\\' && arg[1] != NUL) if (arg[0] == '\\' && arg[1] != NUL) {
++arg; arg++;
++arg;
} }
if (arg[0] != NUL) /* skip delimiter */ arg++;
++arg; }
while (arg[0] && vim_strchr((char_u *)"|\"#", arg[0]) == NULL) if (arg[0] != NUL) { // Skip delimiter.
++arg; arg++;
if (arg[0] != NUL) }
while (arg[0] && strchr("|\"#", arg[0]) == NULL) {
arg++;
}
if (arg[0] != NUL) {
return arg; return arg;
}
break; break;
}
case CMD_isearch: case CMD_isearch:
case CMD_dsearch: case CMD_dsearch:
case CMD_ilist: case CMD_ilist:
@ -3137,36 +3153,40 @@ set_one_cmd_context (
case CMD_djump: case CMD_djump:
case CMD_isplit: case CMD_isplit:
case CMD_dsplit: case CMD_dsplit:
arg = skipwhite(skipdigits(arg)); /* skip count */ // Skip count.
if (*arg == '/') { /* Match regexp, not just whole words */ arg = (const char *)skipwhite(skipdigits((const char_u *)arg));
for (++arg; *arg && *arg != '/'; arg++) if (*arg == '/') { // Match regexp, not just whole words.
if (*arg == '\\' && arg[1] != NUL) for (++arg; *arg && *arg != '/'; arg++) {
if (*arg == '\\' && arg[1] != NUL) {
arg++; arg++;
}
}
if (*arg) { if (*arg) {
arg = skipwhite(arg + 1); arg = (const char *)skipwhite((const char_u *)arg + 1);
/* Check for trailing illegal characters */ // Check for trailing illegal characters.
if (*arg && vim_strchr((char_u *)"|\"\n", *arg) == NULL) if (*arg && strchr("|\"\n", *arg) == NULL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
else } else {
return arg; return arg;
} }
} }
}
break; break;
case CMD_autocmd: case CMD_autocmd:
return set_context_in_autocmd(xp, arg, FALSE); return (const char *)set_context_in_autocmd(xp, (char_u *)arg, false);
case CMD_doautocmd: case CMD_doautocmd:
case CMD_doautoall: case CMD_doautoall:
return set_context_in_autocmd(xp, arg, TRUE); return (const char *)set_context_in_autocmd(xp, (char_u *)arg, true);
case CMD_set: case CMD_set:
set_context_in_set_cmd(xp, arg, 0); set_context_in_set_cmd(xp, (char_u *)arg, 0);
break; break;
case CMD_setglobal: case CMD_setglobal:
set_context_in_set_cmd(xp, arg, OPT_GLOBAL); set_context_in_set_cmd(xp, (char_u *)arg, OPT_GLOBAL);
break; break;
case CMD_setlocal: case CMD_setlocal:
set_context_in_set_cmd(xp, arg, OPT_LOCAL); set_context_in_set_cmd(xp, (char_u *)arg, OPT_LOCAL);
break; break;
case CMD_tag: case CMD_tag:
case CMD_stag: case CMD_stag:
@ -3178,15 +3198,16 @@ set_one_cmd_context (
case CMD_tjump: case CMD_tjump:
case CMD_stjump: case CMD_stjump:
case CMD_ptjump: case CMD_ptjump:
if (*p_wop != NUL) if (*p_wop != NUL) {
xp->xp_context = EXPAND_TAGS_LISTFILES; xp->xp_context = EXPAND_TAGS_LISTFILES;
else } else {
xp->xp_context = EXPAND_TAGS; xp->xp_context = EXPAND_TAGS;
xp->xp_pattern = arg; }
xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_augroup: case CMD_augroup:
xp->xp_context = EXPAND_AUGROUP; xp->xp_context = EXPAND_AUGROUP;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_syntax: case CMD_syntax:
set_context_in_syntax_cmd(xp, arg); set_context_in_syntax_cmd(xp, arg);
@ -3203,20 +3224,21 @@ set_one_cmd_context (
case CMD_echoerr: case CMD_echoerr:
case CMD_call: case CMD_call:
case CMD_return: case CMD_return:
set_context_for_expression(xp, arg, ea.cmdidx); set_context_for_expression(xp, (char_u *)arg, ea.cmdidx);
break; break;
case CMD_unlet: case CMD_unlet:
while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) while ((xp->xp_pattern = (char_u *)strchr(arg, ' ')) != NULL) {
arg = xp->xp_pattern + 1; arg = (const char *)xp->xp_pattern + 1;
}
xp->xp_context = EXPAND_USER_VARS; xp->xp_context = EXPAND_USER_VARS;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_function: case CMD_function:
case CMD_delfunction: case CMD_delfunction:
xp->xp_context = EXPAND_USER_FUNC; xp->xp_context = EXPAND_USER_FUNC;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_echohl: case CMD_echohl:
@ -3231,33 +3253,37 @@ set_one_cmd_context (
set_context_in_cscope_cmd(xp, arg, ea.cmdidx); set_context_in_cscope_cmd(xp, arg, ea.cmdidx);
break; break;
case CMD_sign: case CMD_sign:
set_context_in_sign_cmd(xp, arg); set_context_in_sign_cmd(xp, (char_u *)arg);
break; break;
case CMD_bdelete: case CMD_bdelete:
case CMD_bwipeout: case CMD_bwipeout:
case CMD_bunload: case CMD_bunload:
while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) while ((xp->xp_pattern = (char_u *)strchr(arg, ' ')) != NULL) {
arg = xp->xp_pattern + 1; arg = (const char *)xp->xp_pattern + 1;
/*FALLTHROUGH*/ }
// FALLTHROUGH
case CMD_buffer: case CMD_buffer:
case CMD_sbuffer: case CMD_sbuffer:
case CMD_checktime: case CMD_checktime:
xp->xp_context = EXPAND_BUFFERS; xp->xp_context = EXPAND_BUFFERS;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_USER: case CMD_USER:
case CMD_USER_BUF: case CMD_USER_BUF:
if (compl != EXPAND_NOTHING) { if (context != EXPAND_NOTHING) {
/* XFILE: file names are handled above */ // XFILE: file names are handled above.
if (!(ea.argt & XFILE)) { if (!(ea.argt & XFILE)) {
if (compl == EXPAND_MENUS) if (context == EXPAND_MENUS) {
return set_context_in_menu_cmd(xp, cmd, arg, forceit); return (const char *)set_context_in_menu_cmd(xp, (char_u *)cmd,
if (compl == EXPAND_COMMANDS) (char_u *)arg, forceit);
} else if (context == EXPAND_COMMANDS) {
return arg; return arg;
if (compl == EXPAND_MAPPINGS) } else if (context == EXPAND_MAPPINGS) {
return set_context_in_map_cmd(xp, (char_u *)"map", return (const char *)set_context_in_map_cmd(
arg, forceit, FALSE, FALSE, CMD_map); xp, (char_u *)"map", (char_u *)arg, forceit, false, false,
/* Find start of last argument. */ CMD_map);
}
// Find start of last argument.
p = arg; p = arg;
while (*p) { while (*p) {
if (*p == ' ') if (*p == ' ')
@ -3267,9 +3293,9 @@ set_one_cmd_context (
++p; /* skip over escaped character */ ++p; /* skip over escaped character */
mb_ptr_adv(p); mb_ptr_adv(p);
} }
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
} }
xp->xp_context = compl; xp->xp_context = context;
} }
break; break;
case CMD_map: case CMD_noremap: case CMD_map: case CMD_noremap:
@ -3281,8 +3307,8 @@ set_one_cmd_context (
case CMD_lmap: case CMD_lnoremap: case CMD_lmap: case CMD_lnoremap:
case CMD_smap: case CMD_snoremap: case CMD_smap: case CMD_snoremap:
case CMD_xmap: case CMD_xnoremap: case CMD_xmap: case CMD_xnoremap:
return set_context_in_map_cmd(xp, cmd, arg, forceit, return (const char *)set_context_in_map_cmd(
FALSE, FALSE, ea.cmdidx); xp, (char_u *)cmd, (char_u *)arg, forceit, false, false, ea.cmdidx);
case CMD_unmap: case CMD_unmap:
case CMD_nunmap: case CMD_nunmap:
case CMD_vunmap: case CMD_vunmap:
@ -3292,18 +3318,18 @@ set_one_cmd_context (
case CMD_lunmap: case CMD_lunmap:
case CMD_sunmap: case CMD_sunmap:
case CMD_xunmap: case CMD_xunmap:
return set_context_in_map_cmd(xp, cmd, arg, forceit, return (const char *)set_context_in_map_cmd(
FALSE, TRUE, ea.cmdidx); xp, (char_u *)cmd, (char_u *)arg, forceit, false, true, ea.cmdidx);
case CMD_abbreviate: case CMD_noreabbrev: case CMD_abbreviate: case CMD_noreabbrev:
case CMD_cabbrev: case CMD_cnoreabbrev: case CMD_cabbrev: case CMD_cnoreabbrev:
case CMD_iabbrev: case CMD_inoreabbrev: case CMD_iabbrev: case CMD_inoreabbrev:
return set_context_in_map_cmd(xp, cmd, arg, forceit, return (const char *)set_context_in_map_cmd(
TRUE, FALSE, ea.cmdidx); xp, (char_u *)cmd, (char_u *)arg, forceit, true, false, ea.cmdidx);
case CMD_unabbreviate: case CMD_unabbreviate:
case CMD_cunabbrev: case CMD_cunabbrev:
case CMD_iunabbrev: case CMD_iunabbrev:
return set_context_in_map_cmd(xp, cmd, arg, forceit, return (const char *)set_context_in_map_cmd(
TRUE, TRUE, ea.cmdidx); xp, (char_u *)cmd, (char_u *)arg, forceit, true, true, ea.cmdidx);
case CMD_menu: case CMD_noremenu: case CMD_unmenu: case CMD_menu: case CMD_noremenu: case CMD_unmenu:
case CMD_amenu: case CMD_anoremenu: case CMD_aunmenu: case CMD_amenu: case CMD_anoremenu: case CMD_aunmenu:
case CMD_nmenu: case CMD_nnoremenu: case CMD_nunmenu: case CMD_nmenu: case CMD_nnoremenu: case CMD_nunmenu:
@ -3313,48 +3339,50 @@ set_one_cmd_context (
case CMD_cmenu: case CMD_cnoremenu: case CMD_cunmenu: case CMD_cmenu: case CMD_cnoremenu: case CMD_cunmenu:
case CMD_tmenu: case CMD_tunmenu: case CMD_tmenu: case CMD_tunmenu:
case CMD_popup: case CMD_emenu: case CMD_popup: case CMD_emenu:
return set_context_in_menu_cmd(xp, cmd, arg, forceit); return (const char *)set_context_in_menu_cmd(
xp, (char_u *)cmd, (char_u *)arg, forceit);
case CMD_colorscheme: case CMD_colorscheme:
xp->xp_context = EXPAND_COLORS; xp->xp_context = EXPAND_COLORS;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_compiler: case CMD_compiler:
xp->xp_context = EXPAND_COMPILER; xp->xp_context = EXPAND_COMPILER;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_ownsyntax: case CMD_ownsyntax:
xp->xp_context = EXPAND_OWNSYNTAX; xp->xp_context = EXPAND_OWNSYNTAX;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_setfiletype: case CMD_setfiletype:
xp->xp_context = EXPAND_FILETYPE; xp->xp_context = EXPAND_FILETYPE;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_packadd: case CMD_packadd:
xp->xp_context = EXPAND_PACKADD; xp->xp_context = EXPAND_PACKADD;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
#ifdef HAVE_WORKING_LIBINTL #ifdef HAVE_WORKING_LIBINTL
case CMD_language: case CMD_language:
p = skiptowhite(arg); p = (const char *)skiptowhite((const char_u *)arg);
if (*p == NUL) { if (*p == NUL) {
xp->xp_context = EXPAND_LANGUAGE; xp->xp_context = EXPAND_LANGUAGE;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
} else { } else {
if ( STRNCMP(arg, "messages", p - arg) == 0 if (strncmp(arg, "messages", p - arg) == 0
|| STRNCMP(arg, "ctype", p - arg) == 0 || strncmp(arg, "ctype", p - arg) == 0
|| STRNCMP(arg, "time", p - arg) == 0) { || strncmp(arg, "time", p - arg) == 0) {
xp->xp_context = EXPAND_LOCALES; xp->xp_context = EXPAND_LOCALES;
xp->xp_pattern = skipwhite(p); xp->xp_pattern = skipwhite((const char_u *)p);
} else } else {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} }
}
break; break;
#endif #endif
case CMD_profile: case CMD_profile:
@ -3362,16 +3390,16 @@ set_one_cmd_context (
break; break;
case CMD_behave: case CMD_behave:
xp->xp_context = EXPAND_BEHAVE; xp->xp_context = EXPAND_BEHAVE;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_history: case CMD_history:
xp->xp_context = EXPAND_HISTORY; xp->xp_context = EXPAND_HISTORY;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
case CMD_syntime: case CMD_syntime:
xp->xp_context = EXPAND_SYNTIME; xp->xp_context = EXPAND_SYNTIME;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
break; break;
@ -3390,10 +3418,9 @@ set_one_cmd_context (
* Also skip white space and ":" characters. * Also skip white space and ":" characters.
* Returns the "cmd" pointer advanced to beyond the range. * Returns the "cmd" pointer advanced to beyond the range.
*/ */
char_u * char_u *skip_range(
skip_range ( const char_u *cmd,
char_u *cmd, int *ctx // pointer to xp_context or NULL
int *ctx /* pointer to xp_context or NULL */
) )
{ {
unsigned delim; unsigned delim;
@ -3418,7 +3445,7 @@ skip_range (
while (*cmd == ':') while (*cmd == ':')
cmd = skipwhite(cmd + 1); cmd = skipwhite(cmd + 1);
return cmd; return (char_u *)cmd;
} }
/* /*
@ -4585,14 +4612,15 @@ int ends_excmd(int c) FUNC_ATTR_CONST
* Return the next command, after the first '|' or '\n'. * Return the next command, after the first '|' or '\n'.
* Return NULL if not found. * Return NULL if not found.
*/ */
char_u *find_nextcmd(char_u *p) char_u *find_nextcmd(const char_u *p)
{ {
while (*p != '|' && *p != '\n') { while (*p != '|' && *p != '\n') {
if (*p == NUL) if (*p == NUL) {
return NULL; return NULL;
++p;
} }
return p + 1; p++;
}
return (char_u *)p + 1;
} }
/* /*

View File

@ -3636,7 +3636,6 @@ set_cmd_context (
) )
{ {
int old_char = NUL; int old_char = NUL;
char_u *nextcomm;
/* /*
* Avoid a UMR warning from Purify, only save the character if it has been * Avoid a UMR warning from Purify, only save the character if it has been
@ -3645,7 +3644,7 @@ set_cmd_context (
if (col < len) if (col < len)
old_char = str[col]; old_char = str[col];
str[col] = NUL; str[col] = NUL;
nextcomm = str; const char *nextcomm = (const char *)str;
if (use_ccline && ccline.cmdfirstc == '=') { if (use_ccline && ccline.cmdfirstc == '=') {
// pass CMD_SIZE because there is no real command // pass CMD_SIZE because there is no real command
@ -3654,9 +3653,11 @@ set_cmd_context (
xp->xp_context = ccline.xp_context; xp->xp_context = ccline.xp_context;
xp->xp_pattern = ccline.cmdbuff; xp->xp_pattern = ccline.cmdbuff;
xp->xp_arg = ccline.xp_arg; xp->xp_arg = ccline.xp_arg;
} else } else {
while (nextcomm != NULL) while (nextcomm != NULL) {
nextcomm = set_one_cmd_context(xp, nextcomm); nextcomm = set_one_cmd_context(xp, nextcomm);
}
}
/* Store the string here so that call_user_expand_func() can get to them /* Store the string here so that call_user_expand_func() can get to them
* easily. */ * easily. */

View File

@ -140,33 +140,32 @@ char_u *get_cscope_name(expand_T *xp, int idx)
/* /*
* Handle command line completion for :cscope command. * Handle command line completion for :cscope command.
*/ */
void set_context_in_cscope_cmd(expand_T *xp, char_u *arg, cmdidx_T cmdidx) void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
{ {
char_u *p; // Default: expand subcommands.
/* Default: expand subcommands */
xp->xp_context = EXPAND_CSCOPE; xp->xp_context = EXPAND_CSCOPE;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
expand_what = (cmdidx == CMD_scscope) expand_what = ((cmdidx == CMD_scscope)
? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD; ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD);
/* (part of) subcommand already typed */ /* (part of) subcommand already typed */
if (*arg != NUL) { if (*arg != NUL) {
p = skiptowhite(arg); const char *p = (const char *)skiptowhite((const char_u *)arg);
if (*p != NUL) { /* past first word */ if (*p != NUL) { // Past first word.
xp->xp_pattern = skipwhite(p); xp->xp_pattern = skipwhite((const char_u *)p);
if (*skiptowhite(xp->xp_pattern) != NUL) if (*skiptowhite(xp->xp_pattern) != NUL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
else if (STRNICMP(arg, "add", p - arg) == 0) } else if (STRNICMP(arg, "add", p - arg) == 0) {
xp->xp_context = EXPAND_FILES; xp->xp_context = EXPAND_FILES;
else if (STRNICMP(arg, "kill", p - arg) == 0) } else if (STRNICMP(arg, "kill", p - arg) == 0) {
expand_what = EXP_CSCOPE_KILL; expand_what = EXP_CSCOPE_KILL;
else if (STRNICMP(arg, "find", p - arg) == 0) } else if (STRNICMP(arg, "find", p - arg) == 0) {
expand_what = EXP_CSCOPE_FIND; expand_what = EXP_CSCOPE_FIND;
else } else {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} }
} }
}
} }

View File

@ -5574,45 +5574,44 @@ void reset_expand_highlight(void)
* Handle command line completion for :match and :echohl command: Add "None" * Handle command line completion for :match and :echohl command: Add "None"
* as highlight group. * as highlight group.
*/ */
void set_context_in_echohl_cmd(expand_T *xp, char_u *arg) void set_context_in_echohl_cmd(expand_T *xp, const char *arg)
{ {
xp->xp_context = EXPAND_HIGHLIGHT; xp->xp_context = EXPAND_HIGHLIGHT;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
include_none = 1; include_none = 1;
} }
/* /*
* Handle command line completion for :syntax command. * Handle command line completion for :syntax command.
*/ */
void set_context_in_syntax_cmd(expand_T *xp, char_u *arg) void set_context_in_syntax_cmd(expand_T *xp, const char *arg)
{ {
char_u *p; // Default: expand subcommands.
/* Default: expand subcommands */
xp->xp_context = EXPAND_SYNTAX; xp->xp_context = EXPAND_SYNTAX;
expand_what = EXP_SUBCMD; expand_what = EXP_SUBCMD;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
include_link = 0; include_link = 0;
include_default = 0; include_default = 0;
/* (part of) subcommand already typed */ /* (part of) subcommand already typed */
if (*arg != NUL) { if (*arg != NUL) {
p = skiptowhite(arg); const char *p = (const char *)skiptowhite((const char_u *)arg);
if (*p != NUL) { /* past first word */ if (*p != NUL) { // Past first word.
xp->xp_pattern = skipwhite(p); xp->xp_pattern = skipwhite((const char_u *)p);
if (*skiptowhite(xp->xp_pattern) != NUL) if (*skiptowhite(xp->xp_pattern) != NUL) {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
else if (STRNICMP(arg, "case", p - arg) == 0) } else if (STRNICMP(arg, "case", p - arg) == 0) {
expand_what = EXP_CASE; expand_what = EXP_CASE;
else if ( STRNICMP(arg, "keyword", p - arg) == 0 } else if (STRNICMP(arg, "keyword", p - arg) == 0
|| STRNICMP(arg, "region", p - arg) == 0 || STRNICMP(arg, "region", p - arg) == 0
|| STRNICMP(arg, "match", p - arg) == 0 || STRNICMP(arg, "match", p - arg) == 0
|| STRNICMP(arg, "list", p - arg) == 0) || STRNICMP(arg, "list", p - arg) == 0) {
xp->xp_context = EXPAND_HIGHLIGHT; xp->xp_context = EXPAND_HIGHLIGHT;
else } else {
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} }
} }
}
} }
static char *(case_args[]) = {"match", "ignore", NULL}; static char *(case_args[]) = {"match", "ignore", NULL};
@ -7474,44 +7473,44 @@ int highlight_changed(void)
/* /*
* Handle command line completion for :highlight command. * Handle command line completion for :highlight command.
*/ */
void set_context_in_highlight_cmd(expand_T *xp, char_u *arg) void set_context_in_highlight_cmd(expand_T *xp, const char *arg)
{ {
char_u *p; // Default: expand group names.
/* Default: expand group names */
xp->xp_context = EXPAND_HIGHLIGHT; xp->xp_context = EXPAND_HIGHLIGHT;
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
include_link = 2; include_link = 2;
include_default = 1; include_default = 1;
/* (part of) subcommand already typed */ /* (part of) subcommand already typed */
if (*arg != NUL) { if (*arg != NUL) {
p = skiptowhite(arg); const char *p = (const char *)skiptowhite((const char_u *)arg);
if (*p != NUL) { /* past "default" or group name */ if (*p != NUL) { // Past "default" or group name.
include_default = 0; include_default = 0;
if (STRNCMP("default", arg, p - arg) == 0) { if (strncmp("default", arg, p - arg) == 0) {
arg = skipwhite(p); arg = (const char *)skipwhite((const char_u *)p);
xp->xp_pattern = arg; xp->xp_pattern = (char_u *)arg;
p = skiptowhite(arg); p = (const char *)skiptowhite((const char_u *)arg);
} }
if (*p != NUL) { /* past group name */ if (*p != NUL) { /* past group name */
include_link = 0; include_link = 0;
if (arg[1] == 'i' && arg[0] == 'N') if (arg[1] == 'i' && arg[0] == 'N') {
highlight_list(); highlight_list();
if (STRNCMP("link", arg, p - arg) == 0 }
|| STRNCMP("clear", arg, p - arg) == 0) { if (strncmp("link", arg, p - arg) == 0
xp->xp_pattern = skipwhite(p); || strncmp("clear", arg, p - arg) == 0) {
p = skiptowhite(xp->xp_pattern); xp->xp_pattern = skipwhite((const char_u *)p);
if (*p != NUL) { /* past first group name */ p = (const char *)skiptowhite(xp->xp_pattern);
xp->xp_pattern = skipwhite(p); if (*p != NUL) { // Past first group name.
p = skiptowhite(xp->xp_pattern); xp->xp_pattern = skipwhite((const char_u *)p);
p = (const char *)skiptowhite(xp->xp_pattern);
} }
} }
if (*p != NUL) /* past group name(s) */ if (*p != NUL) { // Past group name(s).
xp->xp_context = EXPAND_NOTHING; xp->xp_context = EXPAND_NOTHING;
} }
} }
} }
}
} }
/* /*