Skip to content

Commit

Permalink
Adding clang-format configuration and script
Browse files Browse the repository at this point in the history
  • Loading branch information
llaniewski committed Oct 20, 2023
1 parent 365770c commit 4d2ce21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BasedOnStyle: Google
ColumnLimit: 300
IndentWidth: 4
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: Always
6 changes: 6 additions & 0 deletions tools/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

PP=$(dirname $0)
clang-format --style=file:$PP/.clang-format "$@" \
| sed -E 's/for[[:blank:]]*[(]([[:alpha:]_]*[[:blank:]]|)[[:blank:]]*([[:alnum:]_]+)[[:blank:]]*=[[:blank:]]*([[:alnum:]_]+)[[:blank:]]*;[[:blank:]]*([[:alnum:]_]+)[[:blank:]]*([<=]*)[[:blank:]]*([[:alnum:]_]+)[[:blank:]]*;[[:blank:]]*([[:alnum:]_]+)[+][+][[:blank:]]*\)/for (\1\2=\3; \4\5\6; \7++)/g' \
| sed -E 's| ([*/]) |\1|g'

0 comments on commit 4d2ce21

Please sign in to comment.