*: Fix linter errors

Big function in expressions.c may be refactored, if I ever catch the idea how to 
split it right.
This commit is contained in:
ZyX
2017-10-30 01:32:10 +03:00
parent b29a776550
commit a9b203d23f
6 changed files with 47 additions and 40 deletions

View File

@@ -6080,7 +6080,7 @@ char_u *add_char2buf(int c, char_u *s)
{
char_u temp[MB_MAXBYTES + 1];
const int len = utf_char2bytes(c, temp);
for (int i = 0; i < len; ++i) {
for (int i = 0; i < len; i++) {
c = temp[i];
// Need to escape K_SPECIAL and CSI like in the typeahead buffer.
if (c == K_SPECIAL) {

View File

@@ -25,21 +25,21 @@
*/
static const struct modmasktable {
short mod_mask; ///< Bit-mask for particular key modifier.
short mod_flag; ///< Bit(s) for particular key modifier.
uint16_t mod_mask; ///< Bit-mask for particular key modifier.
uint16_t mod_flag; ///< Bit(s) for particular key modifier.
char_u name; ///< Single letter name of modifier.
} mod_mask_table[] = {
{MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'M'},
{MOD_MASK_META, MOD_MASK_META, (char_u)'T'},
{MOD_MASK_CTRL, MOD_MASK_CTRL, (char_u)'C'},
{MOD_MASK_SHIFT, MOD_MASK_SHIFT, (char_u)'S'},
{MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, (char_u)'2'},
{MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, (char_u)'3'},
{MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4'},
{MOD_MASK_CMD, MOD_MASK_CMD, (char_u)'D'},
{ MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'M' },
{ MOD_MASK_META, MOD_MASK_META, (char_u)'T' },
{ MOD_MASK_CTRL, MOD_MASK_CTRL, (char_u)'C' },
{ MOD_MASK_SHIFT, MOD_MASK_SHIFT, (char_u)'S' },
{ MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, (char_u)'2' },
{ MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, (char_u)'3' },
{ MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4' },
{ MOD_MASK_CMD, MOD_MASK_CMD, (char_u)'D' },
// 'A' must be the last one
{MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A'},
{0, 0, NUL}
{ MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A' },
{ 0, 0, NUL }
};
/*

View File

@@ -98,15 +98,23 @@ const uint8_t utf8len_tab[] = {
// Like utf8len_tab above, but using a zero for illegal lead bytes.
const uint8_t utf8len_tab_zero[] = {
//1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 2
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 4
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 6
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 8
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // A
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // C
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0, // E
// ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?A ?B ?C ?D ?E ?F
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0?
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1?
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2?
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3?
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4?
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5?
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6?
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7?
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8?
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9?
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A?
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B?
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C?
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D?
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E?
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // F?
};
/*

View File

@@ -5930,7 +5930,8 @@ static void syntime_report(void)
// When making changes here, also change runtime/colors/default.vim!
static const char *highlight_init_both[] = {
"Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey",
"Conceal "
"ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey",
"Cursor guibg=fg guifg=bg",
"lCursor guibg=fg guifg=bg",
"DiffText cterm=bold ctermbg=Red gui=bold guibg=Red",
@@ -6211,11 +6212,9 @@ void syn_init_cmdline_highlight(bool reset, bool init)
///
/// @param both include groups where 'bg' doesn't matter
/// @param reset clear groups first
void
init_highlight(int both, int reset)
void init_highlight(bool both, bool reset)
{
int i;
static int had_both = FALSE;
static int had_both = false;
// Try finding the color scheme file. Used when a color file was loaded
// and 'background' or 't_Co' is changed.
@@ -6235,9 +6234,9 @@ init_highlight(int both, int reset)
* Didn't use a color file, use the compiled-in colors.
*/
if (both) {
had_both = TRUE;
had_both = true;
const char *const *const pp = highlight_init_both;
for (i = 0; pp[i] != NULL; i++) {
for (size_t i = 0; pp[i] != NULL; i++) {
do_highlight(pp[i], reset, true);
}
} else if (!had_both) {
@@ -6250,7 +6249,7 @@ init_highlight(int both, int reset)
const char *const *const pp = ((*p_bg == 'l')
? highlight_init_light
: highlight_init_dark);
for (i = 0; pp[i] != NULL; i++) {
for (size_t i = 0; pp[i] != NULL; i++) {
do_highlight(pp[i], reset, true);
}
@@ -6266,8 +6265,9 @@ init_highlight(int both, int reset)
: "Visual cterm=NONE ctermbg=DarkGrey"), false, true);
} else {
do_highlight("Visual cterm=reverse ctermbg=NONE", false, true);
if (*p_bg == 'l')
if (*p_bg == 'l') {
do_highlight("Search ctermfg=black", false, true);
}
}
/*
@@ -6452,7 +6452,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
restore_cterm_colors();
// Clear all default highlight groups and load the defaults.
for (int idx = 0; idx < highlight_ga.ga_len; ++idx) {
for (int idx = 0; idx < highlight_ga.ga_len; idx++) {
highlight_clear(idx);
}
init_highlight(true, true);
@@ -6690,9 +6690,8 @@ void do_highlight(const char *line, const bool forceit, const bool init)
}
}
if (i < 0) {
emsgf(_(
"E421: Color name or number not recognized: %s"),
key_start);
emsgf(_("E421: Color name or number not recognized: %s"),
key_start);
error = true;
break;
}

View File

@@ -1814,8 +1814,8 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags)
|| ((*kv_Z(ast_stack, 1))->type != kExprNodeConcat
&& ((*kv_Z(ast_stack, 1))->type
!= kExprNodeConcatOrSubscript))))
? kELFlagAllowFloat
: 0));
? kELFlagAllowFloat
: 0));
LexExprToken cur_token = viml_pexpr_next_token(
pstate, want_node_to_lexer_flags[want_node] | lexer_additional_flags);
if (cur_token.type == kExprLexEOC) {
@@ -1876,7 +1876,7 @@ viml_pexpr_parse_process_token:
// time.
//
// Here example will always contain a concat with "a:2" sucking colon,
// making expression invalid both because there is no longer a spare colon
// making expression invalid both because there is no longer a spare colon
// for ternary and because concatenating dictionary with anything is not
// valid. There are more cases when this will make a difference though.
const bool node_is_key = (
@@ -2853,7 +2853,7 @@ viml_pexpr_parse_end:
}
kvi_destroy(ast_stack);
return ast;
}
} // NOLINT(readability/fn_size)
#undef NEW_NODE
#undef HL

View File

@@ -189,7 +189,7 @@ typedef enum {
kExprNodeCall, ///< Function call.
/// Plain identifier: simple variable/function name
///
/// Looks like "string", "g:Foo", etc: consists from a single
/// Looks like "string", "g:Foo", etc: consists from a single
/// kExprLexPlainIdentifier token.
kExprNodePlainIdentifier,
/// Plain dictionary key, for use with kExprNodeConcatOrSubscript