blob: 26aa345db1dbd2fefb4c510604e96a374d8373a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
Indent:
=======
- Indent each level four spaces
Rules for braces
================
- if one branch of an if statement has braces, then both brances must
have braces
if (foo)
{
something();
something_else();
}
else
{
blah();
}
- if a branch of an if statement spans more than one line, then it must
have braces, even if the branch itself is only a single statement
if (foo)
{
a_long_function_name_with_lots (and, lots, and, lots, of
parameters, etc);
}
- if the condition of an if statement is spans more than one line, then
the branches must have braces
if (x && b &&
some_long_function_is_called_here (argument))
{
foo();
}
- don't use braces that are not required by the rules above:
if (something)
blach();
else
yuck();
- similar rules apply for for and while statements
do-while:
=========
- do-whiles are formatted like this
do
{
blah();
} while (foo);
|