*: Fix linter errors

This commit is contained in:
ZyX
2016-04-18 02:29:45 +03:00
parent fdb68e35e4
commit 191fb638f4
2 changed files with 54 additions and 45 deletions

View File

@@ -11148,17 +11148,18 @@ static void f_histadd(typval_T *argvars, typval_T *rettv)
char_u *str;
char_u buf[NUMBUFLEN];
rettv->vval.v_number = FALSE;
if (check_restricted() || check_secure())
rettv->vval.v_number = false;
if (check_restricted() || check_secure()) {
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;
if (histype != HIST_INVALID) {
str = get_tv_string_buf(&argvars[1], buf);
if (*str != NUL) {
init_history();
add_to_history(histype, str, FALSE, NUL);
rettv->vval.v_number = TRUE;
add_to_history(histype, str, false, NUL);
rettv->vval.v_number = true;
return;
}
}
@@ -11173,20 +11174,21 @@ static void f_histdel(typval_T *argvars, typval_T *rettv)
char_u buf[NUMBUFLEN];
char_u *str;
str = get_tv_string_chk(&argvars[0]); /* NULL on type error */
if (str == NULL)
str = get_tv_string_chk(&argvars[0]); // NULL on type error
if (str == NULL) {
n = 0;
else if (argvars[1].v_type == VAR_UNKNOWN)
/* only one argument: clear entire history */
} else if (argvars[1].v_type == VAR_UNKNOWN) {
// only one argument: clear entire history
n = clr_history(get_histtype(str, STRLEN(str), false));
else if (argvars[1].v_type == VAR_NUMBER)
/* index given: remove that entry */
} else if (argvars[1].v_type == VAR_NUMBER) {
// index given: remove that entry
n = del_history_idx(get_histtype(str, STRLEN(str), false),
(int)get_tv_number(&argvars[1]));
else
/* string given: remove all matching entries */
(int) get_tv_number(&argvars[1]));
} else {
// string given: remove all matching entries
n = del_history_entry(get_histtype(str, STRLEN(str), false),
get_tv_string_buf(&argvars[1], buf));
}
rettv->vval.v_number = n;
}
@@ -11199,7 +11201,7 @@ static void f_histget(typval_T *argvars, typval_T *rettv)
int idx;
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) {
rettv->vval.v_string = NULL;
} 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),
false);
if (i != HIST_INVALID)
if (i != HIST_INVALID) {
i = get_history_idx(i);
else
} else {
i = -1;
}
rettv->vval.v_number = i;
}

View File

@@ -1177,25 +1177,28 @@ do_set (
errmsg = e_invarg;
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));
}
len++;
if (opt_idx == -1)
if (opt_idx == -1) {
key = find_key_option(arg + 1);
}
} else {
len = 0;
/*
* The two characters after "t_" may not be alphanumeric.
*/
if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
// The two characters after "t_" may not be alphanumeric.
if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) {
len = 4;
else
while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
++len;
} else {
while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') {
len++;
}
}
opt_idx = findoption_len(arg, (size_t) len);
if (opt_idx == -1)
if (opt_idx == -1) {
key = find_key_option(arg);
}
}
/* remember character after option name */
afterchar = arg[len];
@@ -4281,14 +4284,16 @@ static void check_redraw(uint32_t flags)
redraw_all_later(NOT_VALID);
}
/*
* Find index for option 'arg' that has given length.
* Return -1 if not found.
*/
/// Find index for named option
///
/// @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)
{
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;
/*
@@ -4318,22 +4323,25 @@ int findoption_len(const char_u *const arg, const size_t len)
int opt_idx;
is_term_opt = (len > 2 && arg[0] == 't' && arg[1] == '_');
if (is_term_opt)
if (is_term_opt) {
opt_idx = quick_tab[26];
else
} else {
opt_idx = quick_tab[CharOrdLow(arg[0])];
}
// Match full name
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;
}
}
if (s == NULL && !is_term_opt) {
opt_idx = quick_tab[CharOrdLow(arg[0])];
// Match short name
for (; options[opt_idx].fullname != NULL; opt_idx++) {
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;
}
s = NULL;
}
}
@@ -4670,14 +4678,12 @@ int find_key_option_len(const char_u *arg, size_t len)
int key;
int modifiers;
/*
* Don't use get_special_key_code() for t_xx, we don't want it to call
* add_termcap_entry().
*/
if (len >= 4 && arg[0] == 't' && arg[1] == '_')
// Don't use get_special_key_code() for t_xx, we don't want it to call
// add_termcap_entry().
if (len >= 4 && arg[0] == 't' && arg[1] == '_') {
key = TERMCAP2KEY(arg[2], arg[3]);
else {
--arg; /* put arg at the '<' */
} else {
arg--; // put arg at the '<'
modifiers = 0;
key = find_special_key(&arg, len + 1, &modifiers, true, true);
if (modifiers) { // can't handle modifiers here