build(lint): remove clint.py rules for braces #20880

Uncrustify is the source of truth where possible.
Remove any redundant checks from clint.py.
See also https://github.com/neovim/neovim/pull/18563
This commit is contained in:
dundargoc 2022-11-01 15:39:49 +01:00 committed by GitHub
parent 582c044dbe
commit b05d1943f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 90 additions and 304 deletions

View File

@ -157,7 +157,6 @@ _ERROR_CATEGORIES = [
'build/printf_format', 'build/printf_format',
'build/storage_class', 'build/storage_class',
'readability/bool', 'readability/bool',
'readability/braces',
'readability/multiline_comment', 'readability/multiline_comment',
'readability/multiline_string', 'readability/multiline_string',
'readability/nul', 'readability/nul',
@ -2305,213 +2304,36 @@ def CheckBraces(filename, clean_lines, linenum, error):
prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0]
if (not Search(r'[,;:}{(]\s*$', prevline) and if (not Search(r'[,;:}{(]\s*$', prevline) and
not Match(r'\s*#', prevline)): not Match(r'\s*#', prevline)):
error(filename, linenum, 'whitespace/braces', 4, return
'{ should almost always be at the end'
' of the previous line')
# Brace must appear after function signature, but on the *next* line # Brace must appear after function signature, but on the *next* line
if Match(r'^(?:\w+(?: ?\*+)? )+\w+\(', line): if Match(r'^(?:\w+(?: ?\*+)? )+\w+\(', line):
pos = line.find('(') pos = line.find('(')
(endline, end_linenum, endpos) = CloseExpression( (endline, end_linenum, _) = CloseExpression(clean_lines, linenum, pos)
clean_lines, linenum, pos)
if endline.endswith('{'): if endline.endswith('{'):
error(filename, end_linenum, 'readability/braces', 5, return
'Brace starting function body must be placed on its own line')
else:
func_start_linenum = end_linenum + 1
while not clean_lines.lines[func_start_linenum] == "{":
attrline = Match(
r'^((?!# *define).*?)'
r'(?:FUNC_ATTR|FUNC_API|REAL_FATTR)_\w+'
r'(?:\(\d+(, \d+)*\))?',
clean_lines.lines[func_start_linenum],
)
if attrline:
if len(attrline.group(1)) != 2:
error(filename, func_start_linenum,
'whitespace/indent', 5,
'Function attribute line should have 2-space '
'indent')
func_start_linenum += 1 func_start_linenum = end_linenum + 1
else: while not clean_lines.lines[func_start_linenum] == "{":
func_start = clean_lines.lines[func_start_linenum] attrline = Match(
if not func_start.startswith('enum ') and func_start.endswith('{'): r'^((?!# *define).*?)'
error(filename, func_start_linenum, r'(?:FUNC_ATTR|FUNC_API|REAL_FATTR)_\w+'
'readability/braces', 5, r'(?:\(\d+(, \d+)*\))?',
'Brace starting function body must be placed ' clean_lines.lines[func_start_linenum],
'after the function signature') )
break if attrline:
if len(attrline.group(1)) != 2:
# An else clause should be on the same line as the preceding closing brace. error(filename, func_start_linenum,
# If there is no preceding closing brace, there should be one. 'whitespace/indent', 5,
if Match(r'\s*else\s*', line): 'Function attribute line should have 2-space '
prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] 'indent')
if Match(r'\s*}\s*$', prevline):
error(filename, linenum, 'whitespace/newline', 4,
'An else should appear on the same line as the preceding }')
else:
error(filename, linenum, 'readability/braces', 5,
'An else should always have braces before it')
# If should always have a brace
for blockstart in ('if', 'while', 'for'):
if Match(r'\s*{0}(?!\w)[^{{]*$'.format(blockstart), line):
pos = line.find(blockstart)
pos = line.find('(', pos)
if pos > 0:
(endline, _, endpos) = CloseExpression(
clean_lines, linenum, pos)
if endline[endpos:].find('{') == -1:
error(filename, linenum, 'readability/braces', 5,
'{} should always use braces'.format(blockstart))
# If braces come on one side of an else, they should be on both.
# However, we have to worry about "else if" that spans multiple lines!
if Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line):
if Search(r'}\s*else if([^{]*)$', line): # could be multi-line if
# find the ( after the if
pos = line.find('else if')
pos = line.find('(', pos)
if pos > 0:
(endline, _, endpos) = CloseExpression(
clean_lines, linenum, pos)
# must be brace after if
if endline[endpos:].find('{') == -1:
error(filename, linenum, 'readability/braces', 5,
'If an else has a brace on one side,'
' it should have it on both')
else: # common case: else not followed by a multi-line if
error(filename, linenum, 'readability/braces', 5,
'If an else has a brace on one side,'
' it should have it on both')
# Likewise, an else should never have the else clause on the same line
if Search(r'\belse [^\s{]', line) and not Search(r'\belse if\b', line):
error(filename, linenum, 'whitespace/newline', 4,
'Else clause should never be on same line as else (use 2 lines)')
# In the same way, a do/while should never be on one line
if Match(r'\s*do [^\s{]', line):
error(filename, linenum, 'whitespace/newline', 4,
'do/while clauses should not be on a single line')
# Block bodies should not be followed by a semicolon. Due to C++11
# brace initialization, there are more places where semicolons are
# required than not, so we use a whitelist approach to check these
# rather than a blacklist. These are the places where "};" should
# be replaced by just "}":
# 1. Some flavor of block following closing parenthesis:
# for (;;) {};
# while (...) {};
# switch (...) {};
# Function(...) {};
# if (...) {};
# if (...) else if (...) {};
#
# 2. else block:
# if (...) else {};
#
# 3. const member function:
# Function(...) const {};
#
# 4. Block following some statement:
# x = 42;
# {};
#
# 5. Block at the beginning of a function:
# Function(...) {
# {};
# }
#
# Note that naively checking for the preceding "{" will also match
# braces inside multi-dimensional arrays, but this is fine since
# that expression will not contain semicolons.
#
# 6. Block following another block:
# while (true) {}
# {};
#
# 7. End of namespaces:
# namespace {};
#
# These semicolons seems far more common than other kinds of
# redundant semicolons, possibly due to people converting classes
# to namespaces. For now we do not warn for this case.
#
# Try matching case 1 first.
match = Match(r'^(.*\)\s*)\{', line)
if match:
# Matched closing parenthesis (case 1). Check the token before the
# matching opening parenthesis, and don't warn if it looks like a
# macro. This avoids these false positives:
# - macro that defines a base class
# - multi-line macro that defines a base class
# - macro that defines the whole class-head
#
# But we still issue warnings for macros that we know are safe to
# warn, specifically:
# - TEST, TEST_F, TEST_P, MATCHER, MATCHER_P
# - TYPED_TEST
# - INTERFACE_DEF
# - EXCLUSIVE_LOCKS_REQUIRED, SHARED_LOCKS_REQUIRED, LOCKS_EXCLUDED:
#
# We implement a whitelist of safe macros instead of a blacklist of
# unsafe macros, even though the latter appears less frequently in
# google code and would have been easier to implement. This is because
# the downside for getting the whitelist wrong means some extra
# semicolons, while the downside for getting the blacklist wrong
# would result in compile errors.
#
# In addition to macros, we also don't want to warn on compound
# literals.
closing_brace_pos = match.group(1).rfind(')')
opening_parenthesis = ReverseCloseExpression(
clean_lines, linenum, closing_brace_pos)
if opening_parenthesis[2] > -1:
line_prefix = opening_parenthesis[0][0:opening_parenthesis[2]]
macro = Search(r'\b([A-Z_]+)\s*$', line_prefix)
if ((macro and
macro.group(1) not in (
'TEST', 'TEST_F', 'MATCHER', 'MATCHER_P', 'TYPED_TEST',
'EXCLUSIVE_LOCKS_REQUIRED', 'SHARED_LOCKS_REQUIRED',
'LOCKS_EXCLUDED', 'INTERFACE_DEF')) or
Search(r'\s+=\s*$', line_prefix) or
Search(r'^\s*return\s*$', line_prefix)):
match = None
else:
# Try matching cases 2-3.
match = Match(r'^(.*(?:else|\)\s*const)\s*)\{', line)
if not match:
# Try matching cases 4-6. These are always matched on separate
# lines.
#
# Note that we can't simply concatenate the previous line to the
# current line and do a single match, otherwise we may output
# duplicate warnings for the blank line case:
# if (cond) {
# // blank line
# }
prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0]
if prevline and Search(r'[;{}]\s*$', prevline):
match = Match(r'^(\s*)\{', line)
# Check matching closing brace
if match:
(endline, endlinenum, endpos) = CloseExpression(
clean_lines, linenum, len(match.group(1)))
if endpos > -1 and Match(r'^\s*;', endline[endpos:]):
# Current {} pair is eligible for semicolon check, and we have found
# the redundant semicolon, output warning here.
#
# Note: because we are scanning forward for opening braces, and
# outputting warnings for the matching closing brace, if there are
# nested blocks with trailing semicolons, we will get the error
# messages in reversed order.
error(filename, endlinenum, 'readability/braces', 4,
"You don't need a ; after a }")
func_start_linenum += 1
else:
func_start = clean_lines.lines[func_start_linenum]
if not func_start.startswith('enum ') and func_start.endswith('{'):
return
break
def CheckStyle(filename, clean_lines, linenum, error): def CheckStyle(filename, clean_lines, linenum, error):
"""Checks rules from the 'C++ style rules' section of cppguide.html. """Checks rules from the 'C++ style rules' section of cppguide.html.
@ -2681,8 +2503,7 @@ def CheckLanguage(filename, clean_lines, linenum, error):
# Check for suspicious usage of "if" like # Check for suspicious usage of "if" like
# } if (a == b) { # } if (a == b) {
if Search(r'\}\s*if\s*\(', line): if Search(r'\}\s*if\s*\(', line):
error(filename, linenum, 'readability/braces', 4, return
'Did you mean "else if"? If not, start a new line for "if".')
# Check for potential format string bugs like printf(foo). # Check for potential format string bugs like printf(foo).
# We constrain the pattern not to pick things like DocidForPrintf(foo). # We constrain the pattern not to pick things like DocidForPrintf(foo).

View File

@ -1404,7 +1404,9 @@ struct window_S {
}; };
/// Macros defined in Vim, but not in Neovim /// Macros defined in Vim, but not in Neovim
// uncrustify:off
#define CHANGEDTICK(buf) \ #define CHANGEDTICK(buf) \
(=== Include buffer.h & use buf_(get|set|inc) _changedtick ===) (=== Include buffer.h & use buf_(get|set|inc) _changedtick ===)
// uncrustify:on
#endif // NVIM_BUFFER_DEFS_H #endif // NVIM_BUFFER_DEFS_H

View File

@ -19,8 +19,7 @@
#endif #endif
/// Handling of cursor and mouse pointer shapes in various modes. /// Handling of cursor and mouse pointer shapes in various modes.
cursorentry_T shape_table[SHAPE_IDX_COUNT] = cursorentry_T shape_table[SHAPE_IDX_COUNT] = {
{
// Values are set by 'guicursor' and 'mouseshape'. // Values are set by 'guicursor' and 'mouseshape'.
// Adjust the SHAPE_IDX_ defines when changing this! // Adjust the SHAPE_IDX_ defines when changing this!
{ "normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR + SHAPE_MOUSE }, { "normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR + SHAPE_MOUSE },

View File

@ -52,7 +52,6 @@ static garray_T user_digraphs = { 0, 0, (int)sizeof(digr_T), 10, NULL };
/// Note: Characters marked with XX are not included literally, because some /// Note: Characters marked with XX are not included literally, because some
/// compilers cannot handle them (Amiga SAS/C is the most picky one). /// compilers cannot handle them (Amiga SAS/C is the most picky one).
static digr_T digraphdefault[] = static digr_T digraphdefault[] =
// digraphs for Unicode from RFC1345 // digraphs for Unicode from RFC1345
// (also work for ISO-8859-1 aka latin1) // (also work for ISO-8859-1 aka latin1)
{ {

View File

@ -133,8 +133,7 @@ static struct vimvar {
char *vv_name; ///< Name of the variable, without v:. char *vv_name; ///< Name of the variable, without v:.
TV_DICTITEM_STRUCT(VIMVAR_KEY_LEN + 1) vv_di; ///< Value and name for key (max 16 chars). TV_DICTITEM_STRUCT(VIMVAR_KEY_LEN + 1) vv_di; ///< Value and name for key (max 16 chars).
char vv_flags; ///< Flags: #VV_COMPAT, #VV_RO, #VV_RO_SBX. char vv_flags; ///< Flags: #VV_COMPAT, #VV_RO, #VV_RO_SBX.
} vimvars[] = } vimvars[] = {
{
// VV_ tails differing from upcased string literals: // VV_ tails differing from upcased string literals:
// VV_CC_FROM "charconvert_from" // VV_CC_FROM "charconvert_from"
// VV_CC_TO "charconvert_to" // VV_CC_TO "charconvert_to"

View File

@ -3595,13 +3595,13 @@ bool tv_check_str_or_nr(const typval_T *const tv)
#define FUNC_ERROR "E703: Using a Funcref as a Number" #define FUNC_ERROR "E703: Using a Funcref as a Number"
static const char *const num_errors[] = { static const char *const num_errors[] = {
[VAR_PARTIAL]=N_(FUNC_ERROR), [VAR_PARTIAL]= N_(FUNC_ERROR),
[VAR_FUNC]=N_(FUNC_ERROR), [VAR_FUNC]= N_(FUNC_ERROR),
[VAR_LIST]=N_("E745: Using a List as a Number"), [VAR_LIST]= N_("E745: Using a List as a Number"),
[VAR_DICT]=N_("E728: Using a Dictionary as a Number"), [VAR_DICT]= N_("E728: Using a Dictionary as a Number"),
[VAR_FLOAT]=N_("E805: Using a Float as a Number"), [VAR_FLOAT]= N_("E805: Using a Float as a Number"),
[VAR_BLOB]=N_("E974: Using a Blob as a Number"), [VAR_BLOB]= N_("E974: Using a Blob as a Number"),
[VAR_UNKNOWN]=N_("E685: using an invalid value as a Number"), [VAR_UNKNOWN]= N_("E685: using an invalid value as a Number"),
}; };
#undef FUNC_ERROR #undef FUNC_ERROR
@ -3640,13 +3640,13 @@ bool tv_check_num(const typval_T *const tv)
#define FUNC_ERROR "E729: using Funcref as a String" #define FUNC_ERROR "E729: using Funcref as a String"
static const char *const str_errors[] = { static const char *const str_errors[] = {
[VAR_PARTIAL]=N_(FUNC_ERROR), [VAR_PARTIAL]= N_(FUNC_ERROR),
[VAR_FUNC]=N_(FUNC_ERROR), [VAR_FUNC]= N_(FUNC_ERROR),
[VAR_LIST]=N_("E730: using List as a String"), [VAR_LIST]= N_("E730: using List as a String"),
[VAR_DICT]=N_("E731: using Dictionary as a String"), [VAR_DICT]= N_("E731: using Dictionary as a String"),
[VAR_FLOAT]=((const char *)e_float_as_string), [VAR_FLOAT]= ((const char *)e_float_as_string),
[VAR_BLOB]=N_("E976: using Blob as a String"), [VAR_BLOB]= N_("E976: using Blob as a String"),
[VAR_UNKNOWN]=N_("E908: using an invalid value as a String"), [VAR_UNKNOWN]= N_("E908: using an invalid value as a String"),
}; };
#undef FUNC_ERROR #undef FUNC_ERROR

View File

@ -998,7 +998,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett
listitem_T *li = &fc->l_listitems[ai]; listitem_T *li = &fc->l_listitems[ai];
*TV_LIST_ITEM_TV(li) = argvars[i]; *TV_LIST_ITEM_TV(li) = argvars[i];
TV_LIST_ITEM_TV(li)->v_lock = VAR_FIXED; TV_LIST_ITEM_TV(li)->v_lock = VAR_FIXED;
tv_list_append(&fc->l_varlist, li); tv_list_append(&fc->l_varlist, li);
} }
} }

View File

@ -1083,7 +1083,7 @@ void ex_endwhile(exarg_T *eap)
} }
// Try to find the matching ":while" and report what's missing. // Try to find the matching ":while" and report what's missing.
for (idx = cstack->cs_idx; idx > 0; idx--) { for (idx = cstack->cs_idx; idx > 0; idx--) {
fl = cstack->cs_flags[idx]; fl = cstack->cs_flags[idx];
if ((fl & CSF_TRY) && !(fl & CSF_FINALLY)) { if ((fl & CSF_TRY) && !(fl & CSF_FINALLY)) {
// Give up at a try conditional not in its finally clause. // Give up at a try conditional not in its finally clause.
// Ignore the ":endwhile"/":endfor". // Ignore the ":endwhile"/":endfor".

View File

@ -1083,7 +1083,7 @@ static int foldLevelWin(win_T *wp, linenr_T lnum)
{ {
fold_T *fp; fold_T *fp;
linenr_T lnum_rel = lnum; linenr_T lnum_rel = lnum;
int level = 0; int level = 0;
// Recursively search for a fold that contains "lnum". // Recursively search for a fold that contains "lnum".
garray_T *gap = &wp->w_folds; garray_T *gap = &wp->w_folds;

View File

@ -613,7 +613,7 @@ EXTERN int State INIT(= MODE_NORMAL);
EXTERN bool debug_mode INIT(= false); EXTERN bool debug_mode INIT(= false);
EXTERN bool finish_op INIT(= false); // true while an operator is pending EXTERN bool finish_op INIT(= false); // true while an operator is pending
EXTERN long opcount INIT(= 0); // count for pending operator EXTERN long opcount INIT(= 0); // count for pending operator
EXTERN int motion_force INIT(=0); // motion force for pending operator EXTERN int motion_force INIT(= 0); // motion force for pending operator
// Ex Mode (Q) state // Ex Mode (Q) state
EXTERN bool exmode_active INIT(= false); // true if Ex mode is active EXTERN bool exmode_active INIT(= false); // true if Ex mode is active
@ -621,7 +621,7 @@ EXTERN bool exmode_active INIT(= false); // true if Ex mode is active
/// Flag set when normal_check() should return 0 when entering Ex mode. /// Flag set when normal_check() should return 0 when entering Ex mode.
EXTERN bool pending_exmode_active INIT(= false); EXTERN bool pending_exmode_active INIT(= false);
EXTERN bool ex_no_reprint INIT(=false); // No need to print after z or p. EXTERN bool ex_no_reprint INIT(= false); // No need to print after z or p.
// 'inccommand' command preview state // 'inccommand' command preview state
EXTERN bool cmdpreview INIT(= false); EXTERN bool cmdpreview INIT(= false);

View File

@ -140,8 +140,7 @@ static int page_count;
#define OPT_MBFONT_BOLDOBLIQUE 5 #define OPT_MBFONT_BOLDOBLIQUE 5
#define OPT_MBFONT_NUM_OPTIONS 6 #define OPT_MBFONT_NUM_OPTIONS 6
static option_table_T mbfont_opts[OPT_MBFONT_NUM_OPTIONS] = static option_table_T mbfont_opts[OPT_MBFONT_NUM_OPTIONS] = {
{
{ "c", false, 0, NULL, 0, false }, { "c", false, 0, NULL, 0, false },
{ "a", false, 0, NULL, 0, false }, { "a", false, 0, NULL, 0, false },
{ "r", false, 0, NULL, 0, false }, { "r", false, 0, NULL, 0, false },
@ -208,8 +207,7 @@ typedef enum {
} PrtResourceType; } PrtResourceType;
// String versions of PS resource types // String versions of PS resource types
static const char *const prt_resource_types[] = static const char *const prt_resource_types[] = {
{
[PRT_RESOURCE_TYPE_PROCSET] = "procset", [PRT_RESOURCE_TYPE_PROCSET] = "procset",
[PRT_RESOURCE_TYPE_ENCODING] = "encoding", [PRT_RESOURCE_TYPE_ENCODING] = "encoding",
[PRT_RESOURCE_TYPE_CMAP] = "cmap", [PRT_RESOURCE_TYPE_CMAP] = "cmap",
@ -945,8 +943,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
#define PRT_MEDIASIZE_LEN ARRAY_SIZE(prt_mediasize) #define PRT_MEDIASIZE_LEN ARRAY_SIZE(prt_mediasize)
static struct prt_mediasize_S prt_mediasize[] = static struct prt_mediasize_S prt_mediasize[] = {
{
{ "A4", 595.0, 842.0 }, { "A4", 595.0, 842.0 },
{ "letter", 612.0, 792.0 }, { "letter", 612.0, 792.0 },
{ "10x14", 720.0, 1008.0 }, { "10x14", 720.0, 1008.0 },
@ -969,8 +966,7 @@ static struct prt_mediasize_S prt_mediasize[] =
#define PRT_PS_FONT_BOLDOBLIQUE (3) #define PRT_PS_FONT_BOLDOBLIQUE (3)
// Standard font metrics for Courier family // Standard font metrics for Courier family
static struct prt_ps_font_S prt_ps_courier_font = static struct prt_ps_font_S prt_ps_courier_font = {
{
600, 600,
-100, 50, -100, 50,
-250, 805, -250, 805,
@ -978,8 +974,7 @@ static struct prt_ps_font_S prt_ps_courier_font =
}; };
// Generic font metrics for multi-byte fonts // Generic font metrics for multi-byte fonts
static struct prt_ps_font_S prt_ps_mb_font = static struct prt_ps_font_S prt_ps_mb_font = {
{
1000, 1000,
-100, 50, -100, 50,
-250, 805, -250, 805,
@ -999,8 +994,7 @@ static struct prt_ps_font_S *prt_ps_font;
#define CS_KANJITALK7 (0x80) #define CS_KANJITALK7 (0x80)
// Japanese encodings and charsets // Japanese encodings and charsets
static struct prt_ps_encoding_S j_encodings[] = static struct prt_ps_encoding_S j_encodings[] = {
{
{ "iso-2022-jp", NULL, (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990| { "iso-2022-jp", NULL, (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990|
CS_NEC) }, CS_NEC) },
{ "euc-jp", "EUC", (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990) }, { "euc-jp", "EUC", (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990) },
@ -1010,8 +1004,7 @@ static struct prt_ps_encoding_S j_encodings[] =
{ "ucs-2", "UCS2", CS_JIS_X_1990 }, { "ucs-2", "UCS2", CS_JIS_X_1990 },
{ "utf-8", "UTF8", CS_JIS_X_1990 } { "utf-8", "UTF8", CS_JIS_X_1990 }
}; };
static struct prt_ps_charset_S j_charsets[] = static struct prt_ps_charset_S j_charsets[] = {
{
{ "JIS_C_1978", "78", CS_JIS_C_1978 }, { "JIS_C_1978", "78", CS_JIS_C_1978 },
{ "JIS_X_1983", NULL, CS_JIS_X_1983 }, { "JIS_X_1983", NULL, CS_JIS_X_1983 },
{ "JIS_X_1990", "Hojo", CS_JIS_X_1990 }, { "JIS_X_1990", "Hojo", CS_JIS_X_1990 },
@ -1031,8 +1024,7 @@ static struct prt_ps_charset_S j_charsets[] =
#define CS_SC_ISO10646 (0x40) #define CS_SC_ISO10646 (0x40)
// Simplified Chinese encodings and charsets // Simplified Chinese encodings and charsets
static struct prt_ps_encoding_S sc_encodings[] = static struct prt_ps_encoding_S sc_encodings[] = {
{
{ "iso-2022", NULL, (CS_GB_2312_80|CS_GBT_12345_90) }, { "iso-2022", NULL, (CS_GB_2312_80|CS_GBT_12345_90) },
{ "gb18030", NULL, CS_GBK2K }, { "gb18030", NULL, CS_GBK2K },
{ "euc-cn", "EUC", (CS_GB_2312_80|CS_GBT_12345_90|CS_SC_MAC| { "euc-cn", "EUC", (CS_GB_2312_80|CS_GBT_12345_90|CS_SC_MAC|
@ -1041,8 +1033,7 @@ static struct prt_ps_encoding_S sc_encodings[] =
{ "ucs-2", "UCS2", CS_SC_ISO10646 }, { "ucs-2", "UCS2", CS_SC_ISO10646 },
{ "utf-8", "UTF8", CS_SC_ISO10646 } { "utf-8", "UTF8", CS_SC_ISO10646 }
}; };
static struct prt_ps_charset_S sc_charsets[] = static struct prt_ps_charset_S sc_charsets[] = {
{
{ "GB_2312-80", "GB", CS_GB_2312_80 }, { "GB_2312-80", "GB", CS_GB_2312_80 },
{ "GBT_12345-90", "GBT", CS_GBT_12345_90 }, { "GBT_12345-90", "GBT", CS_GBT_12345_90 },
{ "MAC", "GBpc", CS_SC_MAC }, { "MAC", "GBpc", CS_SC_MAC },
@ -1067,8 +1058,7 @@ static struct prt_ps_charset_S sc_charsets[] =
#define CS_TC_ISO10646 (0x1000) #define CS_TC_ISO10646 (0x1000)
// Traditional Chinese encodings and charsets // Traditional Chinese encodings and charsets
static struct prt_ps_encoding_S tc_encodings[] = static struct prt_ps_encoding_S tc_encodings[] = {
{
{ "iso-2022", NULL, (CS_CNS_PLANE_1|CS_CNS_PLANE_2) }, { "iso-2022", NULL, (CS_CNS_PLANE_1|CS_CNS_PLANE_2) },
{ "euc-tw", "EUC", CS_CNS_PLANE_1_2 }, { "euc-tw", "EUC", CS_CNS_PLANE_1_2 },
{ "big5", "B5", (CS_B5|CS_ETEN|CS_HK_GCCS|CS_HK_SCS| { "big5", "B5", (CS_B5|CS_ETEN|CS_HK_GCCS|CS_HK_SCS|
@ -1080,8 +1070,7 @@ static struct prt_ps_encoding_S tc_encodings[] =
{ "utf-16", "UTF16", CS_TC_ISO10646 }, { "utf-16", "UTF16", CS_TC_ISO10646 },
{ "utf-32", "UTF32", CS_TC_ISO10646 } { "utf-32", "UTF32", CS_TC_ISO10646 }
}; };
static struct prt_ps_charset_S tc_charsets[] = static struct prt_ps_charset_S tc_charsets[] = {
{
{ "CNS_1992_1", "CNS1", CS_CNS_PLANE_1 }, { "CNS_1992_1", "CNS1", CS_CNS_PLANE_1 },
{ "CNS_1992_2", "CNS2", CS_CNS_PLANE_2 }, { "CNS_1992_2", "CNS2", CS_CNS_PLANE_2 },
{ "CNS_1993", "CNS", CS_CNS_PLANE_1_2 }, { "CNS_1993", "CNS", CS_CNS_PLANE_1_2 },
@ -1104,8 +1093,7 @@ static struct prt_ps_charset_S tc_charsets[] =
#define CS_KR_ISO10646 (0x08) #define CS_KR_ISO10646 (0x08)
// Korean encodings and charsets // Korean encodings and charsets
static struct prt_ps_encoding_S k_encodings[] = static struct prt_ps_encoding_S k_encodings[] = {
{
{ "iso-2022-kr", NULL, CS_KR_X_1992 }, { "iso-2022-kr", NULL, CS_KR_X_1992 },
{ "euc-kr", "EUC", (CS_KR_X_1992|CS_KR_MAC) }, { "euc-kr", "EUC", (CS_KR_X_1992|CS_KR_MAC) },
{ "johab", "Johab", CS_KR_X_1992 }, { "johab", "Johab", CS_KR_X_1992 },
@ -1115,8 +1103,7 @@ static struct prt_ps_encoding_S k_encodings[] =
{ "ucs-2", "UCS2", CS_KR_ISO10646 }, { "ucs-2", "UCS2", CS_KR_ISO10646 },
{ "utf-8", "UTF8", CS_KR_ISO10646 } { "utf-8", "UTF8", CS_KR_ISO10646 }
}; };
static struct prt_ps_charset_S k_charsets[] = static struct prt_ps_charset_S k_charsets[] = {
{
{ "KS_X_1992", "KSC", CS_KR_X_1992 }, { "KS_X_1992", "KSC", CS_KR_X_1992 },
{ "CP1361", "KSC", CS_KR_X_1992 }, { "CP1361", "KSC", CS_KR_X_1992 },
{ "MAC", "KSCpc", CS_KR_MAC }, { "MAC", "KSCpc", CS_KR_MAC },
@ -1126,8 +1113,7 @@ static struct prt_ps_charset_S k_charsets[] =
{ "ISO10646", "UniKS", CS_KR_ISO10646 } { "ISO10646", "UniKS", CS_KR_ISO10646 }
}; };
static struct prt_ps_mbfont_S prt_ps_mbfonts[] = static struct prt_ps_mbfont_S prt_ps_mbfonts[] = {
{
{ {
ARRAY_SIZE(j_encodings), ARRAY_SIZE(j_encodings),
j_encodings, j_encodings,
@ -1193,8 +1179,7 @@ static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
#define PRT_DSC_ENDCOMMENTS "%%EndComments:" #define PRT_DSC_ENDCOMMENTS "%%EndComments:"
#define SIZEOF_CSTR(s) (sizeof(s) - 1) #define SIZEOF_CSTR(s) (sizeof(s) - 1)
static struct prt_dsc_comment_S prt_dsc_table[] = static struct prt_dsc_comment_S prt_dsc_table[] = {
{
{ PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE }, { PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE },
{ PRT_DSC_VERSION, SIZEOF_CSTR(PRT_DSC_VERSION), { PRT_DSC_VERSION, SIZEOF_CSTR(PRT_DSC_VERSION),
PRT_DSC_VERSION_TYPE }, PRT_DSC_VERSION_TYPE },

View File

@ -77,8 +77,7 @@
#define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT] #define CTRL_X_MSG(i) ctrl_x_msgs[(i) & ~CTRL_X_WANT_IDENT]
/// Message for CTRL-X mode, index is ctrl_x_mode. /// Message for CTRL-X mode, index is ctrl_x_mode.
static char *ctrl_x_msgs[] = static char *ctrl_x_msgs[] = {
{
N_(" Keyword completion (^N^P)"), // CTRL_X_NORMAL, ^P/^N compl. N_(" Keyword completion (^N^P)"), // CTRL_X_NORMAL, ^P/^N compl.
N_(" ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)"), N_(" ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)"),
NULL, // CTRL_X_SCROLL: depends on state NULL, // CTRL_X_SCROLL: depends on state

View File

@ -46,8 +46,7 @@ static const struct modmasktable {
#define MOD_KEYS_ENTRY_SIZE 5 #define MOD_KEYS_ENTRY_SIZE 5
static char_u modifier_keys_table[] = static char_u modifier_keys_table[] = {
{
// mod mask with modifier without modifier // mod mask with modifier without modifier
MOD_MASK_SHIFT, '&', '9', '@', '1', // begin MOD_MASK_SHIFT, '&', '9', '@', '1', // begin
MOD_MASK_SHIFT, '&', '0', '@', '2', // cancel MOD_MASK_SHIFT, '&', '0', '@', '2', // cancel
@ -347,8 +346,7 @@ static struct mousetable {
int button; // Which mouse button is it? int button; // Which mouse button is it?
bool is_click; // Is it a mouse button click event? bool is_click; // Is it a mouse button click event?
bool is_drag; // Is it a mouse drag event? bool is_drag; // Is it a mouse drag event?
} mouse_table[] = } mouse_table[] = {
{
{ KE_LEFTMOUSE, MOUSE_LEFT, true, false }, { KE_LEFTMOUSE, MOUSE_LEFT, true, false },
{ KE_LEFTDRAG, MOUSE_LEFT, false, true }, { KE_LEFTDRAG, MOUSE_LEFT, false, true },
{ KE_LEFTRELEASE, MOUSE_LEFT, false, false }, { KE_LEFTRELEASE, MOUSE_LEFT, false, false },

View File

@ -400,7 +400,7 @@ static int nlua_wait(lua_State *lstate)
bool fast_only = false; bool fast_only = false;
if (lua_top >= 4) { if (lua_top >= 4) {
fast_only = lua_toboolean(lstate, 4); fast_only = lua_toboolean(lstate, 4);
} }
MultiQueue *loop_events = fast_only || in_fast_callback > 0 MultiQueue *loop_events = fast_only || in_fast_callback > 0

View File

@ -136,8 +136,7 @@ const uint8_t utf8len_tab_zero[] = {
// "iso-8859-n" is handled by enc_canonize() directly. // "iso-8859-n" is handled by enc_canonize() directly.
static struct static struct
{ const char *name; int prop; int codepage; } { const char *name; int prop; int codepage; }
enc_canon_table[] = enc_canon_table[] = {
{
#define IDX_LATIN_1 0 #define IDX_LATIN_1 0
{ "latin1", ENC_8BIT + ENC_LATIN1, 1252 }, { "latin1", ENC_8BIT + ENC_LATIN1, 1252 },
#define IDX_ISO_2 1 #define IDX_ISO_2 1
@ -270,8 +269,7 @@ enc_canon_table[] =
// Aliases for encoding names. // Aliases for encoding names.
static struct static struct
{ const char *name; int canon; } { const char *name; int canon; }
enc_alias_table[] = enc_alias_table[] = {
{
{ "ansi", IDX_LATIN_1 }, { "ansi", IDX_LATIN_1 },
{ "iso-8859-1", IDX_LATIN_1 }, { "iso-8859-1", IDX_LATIN_1 },
{ "latin2", IDX_ISO_2 }, { "latin2", IDX_ISO_2 },
@ -1024,8 +1022,7 @@ bool utf_printable(int c)
{ {
// Sorted list of non-overlapping intervals. // Sorted list of non-overlapping intervals.
// 0xd800-0xdfff is reserved for UTF-16, actually illegal. // 0xd800-0xdfff is reserved for UTF-16, actually illegal.
static struct interval nonprint[] = static struct interval nonprint[] = {
{
{ 0x070f, 0x070f }, { 0x180b, 0x180e }, { 0x200b, 0x200f }, { 0x202a, 0x202e }, { 0x070f, 0x070f }, { 0x180b, 0x180e }, { 0x200b, 0x200f }, { 0x202a, 0x202e },
{ 0x2060, 0x206f }, { 0xd800, 0xdfff }, { 0xfeff, 0xfeff }, { 0xfff9, 0xfffb }, { 0x2060, 0x206f }, { 0xd800, 0xdfff }, { 0xfeff, 0xfeff }, { 0xfff9, 0xfffb },
{ 0xfffe, 0xffff } { 0xfffe, 0xffff }

View File

@ -39,7 +39,7 @@ extern MemRealloc mem_realloc;
extern bool entered_free_all_mem; extern bool entered_free_all_mem;
#endif #endif
EXTERN size_t arena_alloc_count INIT(=0); EXTERN size_t arena_alloc_count INIT(= 0);
typedef struct consumed_blk { typedef struct consumed_blk {
struct consumed_blk *prev; struct consumed_blk *prev;

View File

@ -144,8 +144,7 @@ static const struct nv_cmd {
nv_func_T cmd_func; ///< function for this command nv_func_T cmd_func; ///< function for this command
uint16_t cmd_flags; ///< NV_ flags uint16_t cmd_flags; ///< NV_ flags
int16_t cmd_arg; ///< value for ca.arg int16_t cmd_arg; ///< value for ca.arg
} nv_cmds[] = } nv_cmds[] = {
{
{ NUL, nv_error, 0, 0 }, { NUL, nv_error, 0, 0 },
{ Ctrl_A, nv_addsub, 0, 0 }, { Ctrl_A, nv_addsub, 0, 0 },
{ Ctrl_B, nv_page, NV_STS, BACKWARD }, { Ctrl_B, nv_page, NV_STS, BACKWARD },
@ -4896,7 +4895,7 @@ static void nv_pcmark(cmdarg_T *cap)
fm = get_changelist(curbuf, curwin, (int)cap->count1); fm = get_changelist(curbuf, curwin, (int)cap->count1);
} else { } else {
fm = get_jumplist(curwin, (int)cap->count1); fm = get_jumplist(curwin, (int)cap->count1);
flags |= KMarkNoContext | kMarkJumpList; flags |= KMarkNoContext | kMarkJumpList;
} }
// Changelist and jumplist have their own error messages. Therefore avoid // Changelist and jumplist have their own error messages. Therefore avoid
// calling nv_mark_move_to() when not found to avoid incorrect error // calling nv_mark_move_to() when not found to avoid incorrect error

View File

@ -95,8 +95,7 @@ struct block_def {
// The names of operators. // The names of operators.
// IMPORTANT: Index must correspond with defines in vim.h!!! // IMPORTANT: Index must correspond with defines in vim.h!!!
// The third field indicates whether the operator always works on lines. // The third field indicates whether the operator always works on lines.
static char opchars[][3] = static char opchars[][3] = {
{
{ NUL, NUL, 0 }, // OP_NOP { NUL, NUL, 0 }, // OP_NOP
{ 'd', NUL, OPF_CHANGE }, // OP_DELETE { 'd', NUL, OPF_CHANGE }, // OP_DELETE
{ 'y', NUL, 0 }, // OP_YANK { 'y', NUL, 0 }, // OP_YANK

View File

@ -337,8 +337,7 @@ static const size_t LINE_MAXLEN = 4096;
static struct fmtpattern { static struct fmtpattern {
char convchar; char convchar;
char *pattern; char *pattern;
} fmt_pat[FMT_PATTERNS] = } fmt_pat[FMT_PATTERNS] = {
{
{ 'f', ".\\+" }, // only used when at end { 'f', ".\\+" }, // only used when at end
{ 'n', "\\d\\+" }, // 1 { 'n', "\\d\\+" }, // 1
{ 'l', "\\d\\+" }, // 2 { 'l', "\\d\\+" }, // 2
@ -7066,7 +7065,7 @@ static void hgr_search_in_rtp(qf_list_T *qfl, regmatch_T *p_regmatch, const char
void ex_helpgrep(exarg_T *eap) void ex_helpgrep(exarg_T *eap)
{ {
qf_info_T *qi = &ql_info; qf_info_T *qi = &ql_info;
char *au_name = NULL; char *au_name = NULL;
switch (eap->cmdidx) { switch (eap->cmdidx) {
case CMD_helpgrep: case CMD_helpgrep:

View File

@ -181,8 +181,7 @@ static int backslash_trans(int c)
/// recognized. Otherwise "pp" is advanced to after the item. /// recognized. Otherwise "pp" is advanced to after the item.
static int get_char_class(char **pp) static int get_char_class(char **pp)
{ {
static const char *(class_names[]) = static const char *(class_names[]) = {
{
"alnum:]", "alnum:]",
#define CLASS_ALNUM 0 #define CLASS_ALNUM 0
"alpha:]", "alpha:]",
@ -1328,8 +1327,7 @@ typedef struct {
} decomp_T; } decomp_T;
// 0xfb20 - 0xfb4f // 0xfb20 - 0xfb4f
static decomp_T decomp_table[0xfb4f - 0xfb20 + 1] = static decomp_T decomp_table[0xfb4f - 0xfb20 + 1] = {
{
{ 0x5e2, 0, 0 }, // 0xfb20 alt ayin { 0x5e2, 0, 0 }, // 0xfb20 alt ayin
{ 0x5d0, 0, 0 }, // 0xfb21 alt alef { 0x5d0, 0, 0 }, // 0xfb21 alt alef
{ 0x5d3, 0, 0 }, // 0xfb22 alt dalet { 0x5d3, 0, 0 }, // 0xfb22 alt dalet
@ -2276,16 +2274,14 @@ list_T *reg_submatch_list(int no)
# include "nvim/regexp_nfa.c" # include "nvim/regexp_nfa.c"
#endif #endif
static regengine_T bt_regengine = static regengine_T bt_regengine = {
{
bt_regcomp, bt_regcomp,
bt_regfree, bt_regfree,
bt_regexec_nl, bt_regexec_nl,
bt_regexec_multi, bt_regexec_multi,
}; };
static regengine_T nfa_regengine = static regengine_T nfa_regengine = {
{
nfa_regcomp, nfa_regcomp,
nfa_regfree, nfa_regfree,
nfa_regexec_nl, nfa_regexec_nl,

View File

@ -80,8 +80,7 @@
// one for other searches. last_idx points to the one that was used the last // one for other searches. last_idx points to the one that was used the last
// time. // time.
static struct spat spats[2] = static struct spat spats[2] = {
{
// Last used search pattern // Last used search pattern
[0] = { NULL, true, false, 0, { '/', false, false, 0L }, NULL }, [0] = { NULL, true, false, 0, { '/', false, false, 0L }, NULL },
// Last used substitute pattern // Last used substitute pattern

View File

@ -1476,7 +1476,7 @@ static char *shada_filename(const char *file)
file = p_shadafile; file = p_shadafile;
} else { } else {
if ((file = (char *)find_shada_parameter('n')) == NULL || *file == NUL) { if ((file = (char *)find_shada_parameter('n')) == NULL || *file == NUL) {
file = shada_get_default_file(); file = shada_get_default_file();
} }
// XXX It used to be one level lower, so that whatever is in // XXX It used to be one level lower, so that whatever is in
// `p_shadafile` was expanded. I intentionally moved it here // `p_shadafile` was expanded. I intentionally moved it here

View File

@ -1041,7 +1041,7 @@ int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, t
break; break;
} }
if (arg > 0) { if (arg > 0) {
arg_sign = 1; arg_sign = 1;
} else if (arg < 0) { } else if (arg < 0) {
arg_sign = -1; arg_sign = -1;
} }

View File

@ -3344,8 +3344,7 @@ static int last_matchgroup;
static void syn_list_one(const int id, const bool syncing, const bool link_only) static void syn_list_one(const int id, const bool syncing, const bool link_only)
{ {
bool did_header = false; bool did_header = false;
static struct name_list namelist1[] = static struct name_list namelist1[] = {
{
{ HL_DISPLAY, "display" }, { HL_DISPLAY, "display" },
{ HL_CONTAINED, "contained" }, { HL_CONTAINED, "contained" },
{ HL_ONELINE, "oneline" }, { HL_ONELINE, "oneline" },
@ -3358,8 +3357,7 @@ static void syn_list_one(const int id, const bool syncing, const bool link_only)
{ HL_CONCEALENDS, "concealends" }, { HL_CONCEALENDS, "concealends" },
{ 0, NULL } { 0, NULL }
}; };
static struct name_list namelist2[] = static struct name_list namelist2[] = {
{
{ HL_SKIPWHITE, "skipwhite" }, { HL_SKIPWHITE, "skipwhite" },
{ HL_SKIPNL, "skipnl" }, { HL_SKIPNL, "skipnl" },
{ HL_SKIPEMPTY, "skipempty" }, { HL_SKIPEMPTY, "skipempty" },
@ -5238,8 +5236,7 @@ struct subcommand {
void (*func)(exarg_T *, int); // function to call void (*func)(exarg_T *, int); // function to call
}; };
static struct subcommand subcommands[] = static struct subcommand subcommands[] = {
{
{ "case", syn_cmd_case }, { "case", syn_cmd_case },
{ "clear", syn_cmd_clear }, { "clear", syn_cmd_clear },
{ "cluster", syn_cmd_cluster }, { "cluster", syn_cmd_cluster },

View File

@ -36,8 +36,7 @@ static char e_no_such_user_defined_command_in_current_buffer_str[]
/// List of names for completion for ":command" with the EXPAND_ flag. /// List of names for completion for ":command" with the EXPAND_ flag.
/// Must be alphabetical for completion. /// Must be alphabetical for completion.
static const char *command_complete[] = static const char *command_complete[] = {
{
[EXPAND_ARGLIST] = "arglist", [EXPAND_ARGLIST] = "arglist",
[EXPAND_AUGROUP] = "augroup", [EXPAND_AUGROUP] = "augroup",
[EXPAND_BEHAVE] = "behave", [EXPAND_BEHAVE] = "behave",
@ -86,8 +85,7 @@ static struct {
cmd_addr_T expand; cmd_addr_T expand;
char *name; char *name;
char *shortname; char *shortname;
} addr_type_complete[] = } addr_type_complete[] = {
{
{ ADDR_ARGUMENTS, "arguments", "arg" }, { ADDR_ARGUMENTS, "arguments", "arg" },
{ ADDR_LINES, "lines", "line" }, { ADDR_LINES, "lines", "line" },
{ ADDR_LOADED_BUFFERS, "loaded_buffers", "load" }, { ADDR_LOADED_BUFFERS, "loaded_buffers", "load" },

View File

@ -125,7 +125,7 @@ sp_before_assign = ignore # ignore/add/remove/force/not_defined
# Add or remove space after assignment operator '=', '+=', etc. # Add or remove space after assignment operator '=', '+=', etc.
# #
# Overrides sp_assign. # Overrides sp_assign.
sp_after_assign = ignore # ignore/add/remove/force/not_defined sp_after_assign = force # ignore/add/remove/force/not_defined
# Add or remove space in 'enum {'. # Add or remove space in 'enum {'.
# #
@ -1642,7 +1642,7 @@ nl_end_of_file = force # ignore/add/remove/force/not_defined
nl_end_of_file_min = 1 # unsigned number nl_end_of_file_min = 1 # unsigned number
# Add or remove newline between '=' and '{'. # Add or remove newline between '=' and '{'.
nl_assign_brace = ignore # ignore/add/remove/force/not_defined nl_assign_brace = remove # ignore/add/remove/force/not_defined
# (D) Add or remove newline between '=' and '['. # (D) Add or remove newline between '=' and '['.
nl_assign_square = ignore # ignore/add/remove/force/not_defined nl_assign_square = ignore # ignore/add/remove/force/not_defined
@ -3515,5 +3515,5 @@ set QUESTION REAL_FATTR_CONST
set QUESTION REAL_FATTR_NONNULL_ALL set QUESTION REAL_FATTR_NONNULL_ALL
set QUESTION REAL_FATTR_PURE set QUESTION REAL_FATTR_PURE
set QUESTION REAL_FATTR_WARN_UNUSED_RESULT set QUESTION REAL_FATTR_WARN_UNUSED_RESULT
# option(s) with 'not default' value: 110 # option(s) with 'not default' value: 112
# #