summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-format20
-rw-r--r--scripts/whitespace.pl11
2 files changed, 31 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000000000..6b75350e0
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,20 @@
+AlignEscapedNewlinesLeft: true
+AccessModifierOffset: -8 # so public: and private: stays at the left site
+AllowAllParametersOfDeclarationOnNextLine: false
+BinPackParameters: true
+BreakBeforeBinaryOperators: false
+BreakBeforeBraces: Linux
+BreakBeforeTernaryOperators: false
+BreakConstructorInitializersBeforeComma: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ColumnLimit: 0
+IndentFunctionDeclarationAfterType: false #personal taste, good for long methods
+IndentWidth: 8
+MaxEmptyLinesToKeep: 2
+NamespaceIndentation: All
+SpaceBeforeAssignmentOperators: true
+# doesn't work --> SpaceBeforeParens: ControlStatements
+SpacesInParentheses: false
+SpacesBeforeTrailingComments: 1
+UseTab: Always
+PointerBindsToType: false
diff --git a/scripts/whitespace.pl b/scripts/whitespace.pl
new file mode 100644
index 000000000..1d6548092
--- /dev/null
+++ b/scripts/whitespace.pl
@@ -0,0 +1,11 @@
+#! /usr/bin/perl
+
+my $input = $ARGV[0];
+my $source = `clang-format $input`;
+$source =~ s/^(.*each.*\(.*\).*)\n\s*{\s*$/$1 {/img;
+$source =~ s/^(.*struct.*)\n\s*{\s*$/$1 {/img;
+$source =~ s/^(.*class.*)\n\s*{\s*$/$1 {/img;
+$source =~ s/^(\S*::\S*.*)\n\s*: /$1 :\n\t/img;
+$source =~ s/(?:\G|^)[ ]{6}/\t/mg;
+open (DIFF, "| diff -u $input -");
+print DIFF $source ;