source: libcaca/trunk/doc/style.dox @ 4333

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 10 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1/** \page libcaca-style Libcaca coding style
2
3 \section sty1 General guidelines
4
5 A pretty safe rule of thumb is: look at what has already been done and
6 try to do the same.
7
8 - Tabulations should be avoided and replaced with \e eight spaces.
9 - Indentation is generally 4 spaces.
10 - Lines should wrap at most at 79 characters.
11 - Do not leave whitespace at the end of lines.
12 - Do not use multiple spaces for anything else than indentation.
13 - Code qui fait des warnings == code de porc == deux baffes dans ta gueule
14
15 \section sty2 C coding style
16
17 Try to use short names whenever possible (\c i for indices, \c w for width,
18 \c cv for canvas...). Macros are always uppercase, variable and function
19 names are always lowercase. Use the underscore to separate words within
20 names:
21
22 \code
23#define BROKEN 0
24#define MAX(x, y) ((x > y) ? (x) : (y))
25
26unsigned int x, y, w, h;
27char *font_name;
28void frobulate_every_three_seconds(void);
29 \endcode
30
31 \c const is a \e suffix. It's \c char \c const \c *foo, not \c const \c char
32 \c *foo.
33
34 Use spaces after commas and between operators. Do not use spaces after an
35 opening parenthesis or before a closing one:
36
37 \code
38a += 2;
39b = (a * (c + d));
40x = min(x1, x2, x3);
41 \endcode
42
43 Do not put a space between functions and the corresponding opening
44 parenthesis:
45
46 \code
47int function(int);
48 \endcode
49
50 A space can be inserted after keywords such as \c for, \c while or \c if,
51 but consistency with the rest of the page is encouraged:
52
53 \code
54if(a == b)
55    return;
56
57if (p == NULL)
58 \endcode
59
60 Do not put parentheses around return values:
61
62 \code
63return a + (b & x) + d[10];
64 \endcode
65
66 Opening braces should be on a line of their own, aligned with the
67 current block. Braces are optional for one-liners:
68
69 \code
70int function(int a)
71{
72    if(a & 0x84)
73        return a;
74
75    if(a < 0)
76    {
77        return -a;
78    }
79    else
80    {
81        a /= 2;
82
83        switch(a)
84        {
85            case 0:
86            case 1:
87                return -1;
88                break;
89            default:
90                return a;
91        }
92    }
93}
94 \endcode
95
96 \section sty3 C++ coding style
97
98 Nothing here yet.
99
100*/
Note: See TracBrowser for help on using the repository browser.