author | Mikael Berthe <mikael@lilotux.net> |
Fri, 23 Oct 2015 19:55:08 +0200 | |
changeset 2209 | 412322678d59 |
parent 1509 | 189ffdd944b4 |
child 2337 | ffd0e57e9563 |
permissions | -rw-r--r-- |
1509
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
1 |
This document describes the preferred coding style for the mcabber project. |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
2 |
|
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
3 |
If you intend to patch and contribute to mcabber, please try to use the |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
4 |
existing style, and read the following points. |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
5 |
|
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
6 |
- Do not use tabs, use space characters; |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
7 |
- Avoid trailing whitespace; |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
8 |
- Avoid lines longer than 80 characters; |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
9 |
- Indentation is 2 spaces (ok, maybe it isn't a good idea but it's the |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
10 |
current style); |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
11 |
- Put a space after non-functions statements (e.g. if, while...) |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
12 |
- Put the opening brace last on the same line, and put the closing brace first |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
13 |
except for functions, where the opening brace should be alone on a new line. |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
14 |
|
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
15 |
Example: |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
16 |
|
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
17 |
void example(void) |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
18 |
{ |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
19 |
if (cond1) { |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
20 |
do_a(); |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
21 |
} else if (cond2) { |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
22 |
do_b(); |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
23 |
} else { |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
24 |
do_c(); |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
25 |
} |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
26 |
|
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
27 |
if (error) |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
28 |
exit(0); |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
29 |
} |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
30 |
|
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
31 |
- Look at existing code for rules not mentioned here. |
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
32 |
|
189ffdd944b4
Add a small Coding Style document
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
33 |
Mikael |