Some clang-format improvements ##indent

* Fix for clang-format parsing error
* Align consecutive macros for clang-format
* Dont align escaped newlines
* Use spaces for some alignment
* Add clang-format script
This commit is contained in:
Anton Kochkov 2020-12-10 14:46:19 +08:00 committed by pancake
parent e55d7c033b
commit ef462a4800
4 changed files with 69 additions and 6 deletions

View File

@ -8,7 +8,7 @@ ContinuationIndentWidth: 8
IndentCaseLabels: false
IndentFunctionDeclarationAfterType: false
IndentWidth: 8
UseTab: Always
UseTab: ForContinuationAndIndentation
ColumnLimit: 0
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
@ -17,8 +17,10 @@ AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: DontAlign
AlignConsecutiveMacros: true
AlignTrailingComments: false
AlignOperands: false
Cpp11BracedListStyle: false
ForEachMacros: ['r_list_foreach', 'ls_foreach', 'fcn_tree_foreach_intersect', 'r_skiplist_foreach', 'graph_foreach_anode']
SortIncludes: false
ForEachMacros: ['r_list_foreach', 'ls_foreach', 'fcn_tree_foreach_intersect', 'r_skiplist_foreach', 'graph_foreach_anode', 'r_list_foreach_safe', 'r_pvector_foreach', 'r_rbtree_foreach', 'r_interval_ tree_foreach']
SortIncludes: false

View File

@ -1,3 +1,4 @@
static insn_head_t c55x_list[] = {
{
.byte = 0x00,
.size = 0x03,
@ -3970,3 +3971,4 @@
.syntax = NULL,
},
},
};

View File

@ -1137,9 +1137,8 @@ int tms320_dasm(tms320_dasm_t * dasm, const ut8 * stream, int len)
return full_insn_size(dasm);
}
static insn_head_t c55x_list[] = {
# include "c55x/table.h"
};
// insn_head_t c55x_list[]
#include "c55x/table.h"
int tms320_dasm_init(tms320_dasm_t * dasm) {
int i = 0;

60
sys/clang-format.py Executable file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env python3
import glob
import os
import sys
dirlist = [
"binrz",
"librz",
"shlr/ar",
"shlr/bochs",
"shlr/gdb",
"shlr/java",
"shlr/ptrace-wrap",
"shlr/qnx",
"shlr/rar",
"shlr/tcc",
"shlr/w32dbg_wrap",
"shlr/winkd",
"test/unit",
]
skiplist = [
"/gnu/",
"librz/asm/arch/vax/",
"librz/asm/arch/riscv/",
"librz/asm/arch/sh/gnu/",
"librz/asm/arch/i8080/",
"librz/asm/arch/z80/",
"librz/asm/arch/avr/",
"librz/asm/arch/arm/aarch64/",
"librz/hash/xxhash/",
"librz/bin/mangling/cxx/",
"librz/util/bdiff.c",
]
pattern = ["*.c", "*.cpp", "*.h", "*.hpp", "*.inc"]
def skip(filename):
for s in skiplist:
if s in filename:
return True
return False
try:
for d in dirlist:
print("Processing directory: {0}".format(d))
for pat in pattern:
print("Processing pattern: {0}".format(pat))
for filename in glob.iglob(d + "/**/" + pat, recursive=True):
if not skip(filename):
CMD = "clang-format -style=file -i {0}".format(filename)
print(CMD)
os.system(CMD)
except KeyboardInterrupt:
print("clang-format.py interrupted by the user.")
sys.exit(1)