Skip to content

Commit a134774

Browse files
committed
style: replace astyle with clang-format
- Add .clang-format configuration matching existing style - Update scripts/format.sh to use clang-format - Update .pre-commit-config.yaml to use clang-format hook - Reformat codebase with clang-format
1 parent 4584847 commit a134774

19 files changed

Lines changed: 482 additions & 492 deletions

.clang-format

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Language: Cpp
2+
BasedOnStyle: LLVM
3+
IndentWidth: 4
4+
ColumnLimit: 80
5+
BreakBeforeBraces: Custom
6+
BraceWrapping:
7+
AfterClass: false
8+
AfterControlStatement: Never
9+
AfterEnum: false
10+
AfterFunction: true
11+
AfterNamespace: false
12+
AfterObjCDeclaration: false
13+
AfterStruct: false
14+
AfterUnion: false
15+
BeforeCatch: false
16+
BeforeElse: false
17+
IndentBraces: false
18+
SplitEmptyFunction: true
19+
SplitEmptyRecord: true
20+
SplitEmptyNamespace: true
21+
PointerAlignment: Right
22+
SpaceAfterCStyleCast: false
23+
SpaceBeforeParens: ControlStatements
24+
SpacesInParentheses: false
25+
DerivePointerAlignment: false
26+
IncludeBlocks: Preserve
27+
SortIncludes: false
28+
MaxEmptyLinesToKeep: 2
29+
TabWidth: 4
30+
UseTab: Never
31+
IndentCaseLabels: false
32+
AlignAfterOpenBracket: Align
33+
AlwaysBreakAfterReturnType: None
34+
AllowShortFunctionsOnASingleLine: None
35+
AllowShortBlocksOnASingleLine: false
36+
AllowShortIfStatementsOnASingleLine: false
37+
AllowShortLoopsOnASingleLine: false
38+
BinPackArguments: true
39+
BinPackParameters: true
40+
ContinuationIndentWidth: 4
41+
BreakBeforeBinaryOperators: All

.pre-commit-config.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,5 @@ repos:
2323
hooks:
2424
- id: clang-tidy
2525
args: ["-p=builddir", "--warnings-as-errors=*"]
26-
- repo: local
27-
hooks:
28-
- id: format
29-
name: format
30-
entry: ./scripts/format.sh
31-
language: script
32-
pass_filenames: false
33-
files: \.(c|h)$
26+
- id: clang-format
27+
args: [-i]

scripts/format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

33
cd "${MESON_SOURCE_ROOT}"
4-
astyle --style=kr --align-pointer=name --max-code-length=80 src/*.c src/*.h
4+
clang-format -i src/*.c src/*.h

0 commit comments

Comments
 (0)