1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

style: change brace style to K&R in .clang-format

This commit is contained in:
Zetok Zalbavar 2017-02-23 21:59:17 +00:00
parent 297f0935f0
commit c1eac09931
No known key found for this signature in database
GPG Key ID: C953D3880212068A
2 changed files with 20 additions and 28 deletions

View File

@ -36,7 +36,7 @@ BinPackParameters: true
# Break handling # Break handling
ColumnLimit: 100 ColumnLimit: 100
BreakBeforeBraces: Allman BreakBeforeBraces: Mozilla
BreakBeforeBinaryOperators: NonAssignment BreakBeforeBinaryOperators: NonAssignment
AlwaysBreakTemplateDeclarations: true AlwaysBreakTemplateDeclarations: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerAllOnOneLineOrOnePerLine: false

View File

@ -76,18 +76,15 @@ public:
{ {
// Some code here // Some code here
switch (...) switch (...) {
{ case 0: {
case 0:
{
// Some code here // Some code here
} }
} }
// More code // More code
if (...) if (...) {
{
// Conditional code // Conditional code
} }
} }
@ -120,22 +117,17 @@ void foo(int a, int b)
int z = x + y; // Example binary operator int z = x + y; // Example binary operator
int x = z > 2 ? 1 : 3; // Example ternary operator int x = z > 2 ? 1 : 3; // Example ternary operator
if (z >= 1) if (z >= 1) {
{
// Some code here // Some code here
} } else {
else
{
// More code here // More code here
} }
for (std::size_t i = 0; i < 56; ++i) for (std::size_t i = 0; i < 56; ++i) {
{
// For loop body // For loop body
} }
while (true) while (true) {
{
// While loop body // While loop body
} }
} }
@ -184,9 +176,12 @@ statements. Clang-format will attempt to target this limit, going over the
limit slightly if there are tokens that should not be split. Comments should limit slightly if there are tokens that should not be split. Comments should
wrap around unless they include elements that cannot be split (e.g. URLs). wrap around unless they include elements that cannot be split (e.g. URLs).
Line breaks should be added before all opening braces and after all template Line breaks should be added before braces on enum, function, record definitions
specializations except for the `extern "C"` specifier. Lambdas have special and after all template specializations except for the `extern "C"` specifier.
rules that need to be handled seperately, see section below. Lambdas have special rules that need to be handled separately, see section
below.
Other control structures should not have line breaks before braces.
Braces should be added for all control structures, even those whose bodies only Braces should be added for all control structures, even those whose bodies only
contain a single line. contain a single line.
@ -217,12 +212,9 @@ void example(T veryLongArgumentName, T anotherVeryLongArgumentName, T aThirdVery
// This is a very long comment that has been broken into two lines due to it exceeding the 100 // This is a very long comment that has been broken into two lines due to it exceeding the 100
// characters per line rules. // characters per line rules.
if (...) if (...) {
{
// Single line control statements are still required to use braces. // Single line control statements are still required to use braces.
} } else {
else
{
// Multiline block // Multiline block
// Multiline block // Multiline block
} }
@ -320,13 +312,13 @@ int a = 0;
++a; // Preferred over "a++". ++a; // Preferred over "a++".
for (std::size_t i = 0; i < 5; ++i) // Usage of ++i rather than i++. // Usage of ++i rather than i++.
{ for (std::size_t i = 0; i < 5; ++i) {
// for-loop code // for-loop code
} }
if (a++ == 0) // Allowed since ++a is not equivalent. // Allowed since ++a is not equivalent.
{ if (a++ == 0) {
// if statement body // if statement body
} }
``` ```