mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 22:38:16 +00:00
*: Fix linter errors
This commit is contained in:
@@ -11148,17 +11148,18 @@ static void f_histadd(typval_T *argvars, typval_T *rettv)
|
|||||||
char_u *str;
|
char_u *str;
|
||||||
char_u buf[NUMBUFLEN];
|
char_u buf[NUMBUFLEN];
|
||||||
|
|
||||||
rettv->vval.v_number = FALSE;
|
rettv->vval.v_number = false;
|
||||||
if (check_restricted() || check_secure())
|
if (check_restricted() || check_secure()) {
|
||||||
return;
|
return;
|
||||||
str = get_tv_string_chk(&argvars[0]); /* NULL on type error */
|
}
|
||||||
|
str = get_tv_string_chk(&argvars[0]); // NULL on type error
|
||||||
histype = str != NULL ? get_histtype(str, STRLEN(str), false) : HIST_INVALID;
|
histype = str != NULL ? get_histtype(str, STRLEN(str), false) : HIST_INVALID;
|
||||||
if (histype != HIST_INVALID) {
|
if (histype != HIST_INVALID) {
|
||||||
str = get_tv_string_buf(&argvars[1], buf);
|
str = get_tv_string_buf(&argvars[1], buf);
|
||||||
if (*str != NUL) {
|
if (*str != NUL) {
|
||||||
init_history();
|
init_history();
|
||||||
add_to_history(histype, str, FALSE, NUL);
|
add_to_history(histype, str, false, NUL);
|
||||||
rettv->vval.v_number = TRUE;
|
rettv->vval.v_number = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11173,20 +11174,21 @@ static void f_histdel(typval_T *argvars, typval_T *rettv)
|
|||||||
char_u buf[NUMBUFLEN];
|
char_u buf[NUMBUFLEN];
|
||||||
char_u *str;
|
char_u *str;
|
||||||
|
|
||||||
str = get_tv_string_chk(&argvars[0]); /* NULL on type error */
|
str = get_tv_string_chk(&argvars[0]); // NULL on type error
|
||||||
if (str == NULL)
|
if (str == NULL) {
|
||||||
n = 0;
|
n = 0;
|
||||||
else if (argvars[1].v_type == VAR_UNKNOWN)
|
} else if (argvars[1].v_type == VAR_UNKNOWN) {
|
||||||
/* only one argument: clear entire history */
|
// only one argument: clear entire history
|
||||||
n = clr_history(get_histtype(str, STRLEN(str), false));
|
n = clr_history(get_histtype(str, STRLEN(str), false));
|
||||||
else if (argvars[1].v_type == VAR_NUMBER)
|
} else if (argvars[1].v_type == VAR_NUMBER) {
|
||||||
/* index given: remove that entry */
|
// index given: remove that entry
|
||||||
n = del_history_idx(get_histtype(str, STRLEN(str), false),
|
n = del_history_idx(get_histtype(str, STRLEN(str), false),
|
||||||
(int)get_tv_number(&argvars[1]));
|
(int) get_tv_number(&argvars[1]));
|
||||||
else
|
} else {
|
||||||
/* string given: remove all matching entries */
|
// string given: remove all matching entries
|
||||||
n = del_history_entry(get_histtype(str, STRLEN(str), false),
|
n = del_history_entry(get_histtype(str, STRLEN(str), false),
|
||||||
get_tv_string_buf(&argvars[1], buf));
|
get_tv_string_buf(&argvars[1], buf));
|
||||||
|
}
|
||||||
rettv->vval.v_number = n;
|
rettv->vval.v_number = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11199,7 +11201,7 @@ static void f_histget(typval_T *argvars, typval_T *rettv)
|
|||||||
int idx;
|
int idx;
|
||||||
char_u *str;
|
char_u *str;
|
||||||
|
|
||||||
str = get_tv_string_chk(&argvars[0]); /* NULL on type error */
|
str = get_tv_string_chk(&argvars[0]); // NULL on type error
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
rettv->vval.v_string = NULL;
|
rettv->vval.v_string = NULL;
|
||||||
} else {
|
} else {
|
||||||
@@ -11226,10 +11228,11 @@ static void f_histnr(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
i = history == NULL ? HIST_CMD - 1 : get_histtype(history, STRLEN(history),
|
i = history == NULL ? HIST_CMD - 1 : get_histtype(history, STRLEN(history),
|
||||||
false);
|
false);
|
||||||
if (i != HIST_INVALID)
|
if (i != HIST_INVALID) {
|
||||||
i = get_history_idx(i);
|
i = get_history_idx(i);
|
||||||
else
|
} else {
|
||||||
i = -1;
|
i = -1;
|
||||||
|
}
|
||||||
rettv->vval.v_number = i;
|
rettv->vval.v_number = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1177,25 +1177,28 @@ do_set (
|
|||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
if (arg[1] == 't' && arg[2] == '_') /* could be term code */
|
if (arg[1] == 't' && arg[2] == '_') { // could be term code
|
||||||
opt_idx = findoption_len(arg + 1, (size_t) (len - 1));
|
opt_idx = findoption_len(arg + 1, (size_t) (len - 1));
|
||||||
|
}
|
||||||
len++;
|
len++;
|
||||||
if (opt_idx == -1)
|
if (opt_idx == -1) {
|
||||||
key = find_key_option(arg + 1);
|
key = find_key_option(arg + 1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
len = 0;
|
len = 0;
|
||||||
/*
|
// The two characters after "t_" may not be alphanumeric.
|
||||||
* The two characters after "t_" may not be alphanumeric.
|
if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) {
|
||||||
*/
|
|
||||||
if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
|
|
||||||
len = 4;
|
len = 4;
|
||||||
else
|
} else {
|
||||||
while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
|
while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') {
|
||||||
++len;
|
len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
opt_idx = findoption_len(arg, (size_t) len);
|
opt_idx = findoption_len(arg, (size_t) len);
|
||||||
if (opt_idx == -1)
|
if (opt_idx == -1) {
|
||||||
key = find_key_option(arg);
|
key = find_key_option(arg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* remember character after option name */
|
/* remember character after option name */
|
||||||
afterchar = arg[len];
|
afterchar = arg[len];
|
||||||
@@ -4281,14 +4284,16 @@ static void check_redraw(uint32_t flags)
|
|||||||
redraw_all_later(NOT_VALID);
|
redraw_all_later(NOT_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Find index for named option
|
||||||
* Find index for option 'arg' that has given length.
|
///
|
||||||
* Return -1 if not found.
|
/// @param[in] arg Option to find index for.
|
||||||
*/
|
/// @param[in] len Length of the option.
|
||||||
|
///
|
||||||
|
/// @return Index of the option or -1 if option was not found.
|
||||||
int findoption_len(const char_u *const arg, const size_t len)
|
int findoption_len(const char_u *const arg, const size_t len)
|
||||||
{
|
{
|
||||||
char *s, *p;
|
char *s, *p;
|
||||||
static short quick_tab[27] = {0, 0}; /* quick access table */
|
static int quick_tab[27] = { 0, 0 }; // quick access table
|
||||||
int is_term_opt;
|
int is_term_opt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -4318,22 +4323,25 @@ int findoption_len(const char_u *const arg, const size_t len)
|
|||||||
|
|
||||||
int opt_idx;
|
int opt_idx;
|
||||||
is_term_opt = (len > 2 && arg[0] == 't' && arg[1] == '_');
|
is_term_opt = (len > 2 && arg[0] == 't' && arg[1] == '_');
|
||||||
if (is_term_opt)
|
if (is_term_opt) {
|
||||||
opt_idx = quick_tab[26];
|
opt_idx = quick_tab[26];
|
||||||
else
|
} else {
|
||||||
opt_idx = quick_tab[CharOrdLow(arg[0])];
|
opt_idx = quick_tab[CharOrdLow(arg[0])];
|
||||||
|
}
|
||||||
// Match full name
|
// Match full name
|
||||||
for (; (s = options[opt_idx].fullname) != NULL; opt_idx++) {
|
for (; (s = options[opt_idx].fullname) != NULL; opt_idx++) {
|
||||||
if (STRNCMP(arg, s, len) == 0 && s[len] == NUL)
|
if (STRNCMP(arg, s, len) == 0 && s[len] == NUL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (s == NULL && !is_term_opt) {
|
if (s == NULL && !is_term_opt) {
|
||||||
opt_idx = quick_tab[CharOrdLow(arg[0])];
|
opt_idx = quick_tab[CharOrdLow(arg[0])];
|
||||||
// Match short name
|
// Match short name
|
||||||
for (; options[opt_idx].fullname != NULL; opt_idx++) {
|
for (; options[opt_idx].fullname != NULL; opt_idx++) {
|
||||||
s = options[opt_idx].shortname;
|
s = options[opt_idx].shortname;
|
||||||
if (s != NULL && STRNCMP(arg, s, len) == 0 && s[len] == NUL)
|
if (s != NULL && STRNCMP(arg, s, len) == 0 && s[len] == NUL) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
s = NULL;
|
s = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4670,14 +4678,12 @@ int find_key_option_len(const char_u *arg, size_t len)
|
|||||||
int key;
|
int key;
|
||||||
int modifiers;
|
int modifiers;
|
||||||
|
|
||||||
/*
|
// Don't use get_special_key_code() for t_xx, we don't want it to call
|
||||||
* Don't use get_special_key_code() for t_xx, we don't want it to call
|
// add_termcap_entry().
|
||||||
* add_termcap_entry().
|
if (len >= 4 && arg[0] == 't' && arg[1] == '_') {
|
||||||
*/
|
|
||||||
if (len >= 4 && arg[0] == 't' && arg[1] == '_')
|
|
||||||
key = TERMCAP2KEY(arg[2], arg[3]);
|
key = TERMCAP2KEY(arg[2], arg[3]);
|
||||||
else {
|
} else {
|
||||||
--arg; /* put arg at the '<' */
|
arg--; // put arg at the '<'
|
||||||
modifiers = 0;
|
modifiers = 0;
|
||||||
key = find_special_key(&arg, len + 1, &modifiers, true, true);
|
key = find_special_key(&arg, len + 1, &modifiers, true, true);
|
||||||
if (modifiers) { // can't handle modifiers here
|
if (modifiers) { // can't handle modifiers here
|
||||||
|
Reference in New Issue
Block a user