-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce C style (via .clang-format) (see #51)
* Unix endings (LF, EOF) and UTF-8 only * space-only indentation * braces around single-line statements (always) * #includes sorted
- Loading branch information
Showing
327 changed files
with
18,545 additions
and
17,719 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: WebKit | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterFunction: true | ||
AlignEscapedNewlines: DontAlign | ||
ContinuationIndentWidth: 8 | ||
MaxEmptyLinesToKeep: 1 | ||
SpaceAfterCStyleCast: true | ||
PointerAlignment: Right | ||
|
||
# Include files ordering: | ||
# - first put standard includes, place non-nested first (this should | ||
# move library stuff at the end of < > includes) | ||
# - then place local includes | ||
IncludeBlocks: Regroup | ||
IncludeCategories: | ||
- Regex: '^<.*/' | ||
Priority: -1 | ||
SortPriority: -1 | ||
CaseSensitive: true | ||
- Regex: '^<' | ||
Priority: -1 | ||
SortPriority: -2 | ||
CaseSensitive: true | ||
- Regex: '^"' | ||
Priority: 0 | ||
CaseSensitive: true | ||
|
||
LineEnding: LF | ||
InsertNewlineAtEOF: true | ||
InsertBraces: true | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Clang format linter | ||
on: | ||
push: {} | ||
pull_request: {} | ||
|
||
jobs: | ||
clang-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Check C source formatting with clang-format | ||
uses: DoozyX/[email protected] | ||
with: | ||
clangFormatVersion: 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: File style | ||
on: | ||
push: {} | ||
pull_request: {} | ||
|
||
jobs: | ||
check-encoding: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Check correct encoding etc. | ||
run: ./contrib/check-encoding.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# Checks that text files are in proper encoding. | ||
|
||
set -ueo pipefail | ||
|
||
find_sources_0() { | ||
find -type f -and '-(' -name '*.[ch]' -or -name '*.in' -or -name '*.sh' '-)' -print0 | ||
} | ||
|
||
find_crlf_files() { | ||
find_sources_0 | xargs -0 grep -lUP '\r$' | ||
} | ||
|
||
print_non_utf8_files() { | ||
local i | ||
local mime | ||
local rc=0 | ||
for i in "$@"; do | ||
mime="$( file --mime-encoding -b "$i" )" | ||
case "$mime" in | ||
us-ascii|utf-8) ;; | ||
*) echo "Error: $i is in bad encoding ($mime)." >&2 ; rc=1 ;; | ||
esac | ||
done | ||
return "$rc" | ||
} | ||
export -f print_non_utf8_files | ||
|
||
find_non_utf8_files() { | ||
find_sources_0 | xargs -0 bash -c 'print_non_utf8_files "$@"' | ||
} | ||
|
||
echo "Checking line endings..." >&2 | ||
if [ "$( find_crlf_files | wc -l )" -ne 0 ]; then | ||
echo "Error: following file(s) have CR-LF line endings." >&2 | ||
find_crlf_files >&2 | ||
exit 1 | ||
fi | ||
|
||
echo "Checking file encodings..." >&2 | ||
find_non_utf8_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.