kr / beanstalkd

Beanstalk is a simple, fast work queue.

This URL has Read+Write access

beanstalkd / STYLE
100644 58 lines (35 sloc) 1.526 kb
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
Here is a description of the prevailing coding style in beanstalkd. Overall,
our style is pretty close to K&R style, but there are a few differences.
 
Really the only important rule is to follow the style of existing code. This
document is just to help you out by describing some aspects of that style
explicitly.
 
If in doubt, ask the list at beanstalk-talk@googlegroups.com.
 
 * Use no tabs, only spaces.
 
 * Limit lines to 80 columns.
 
 * Indent by four spaces.
 
 * Do not include trailing spaces.
 
 * Surround binary operators (indluding boolean, arithmetic, and assignment)
   with a space on each side.
 
 * Put the name of a function definition on the line after the function's
   return type.
 
 * Put the opening curly brace of a function on a line by itself in the first
   column.
 
 * Put a blank line after a block of declarations.
 
 * Put a blank line after each function.
 
 * Put the opening curly brace of an "if" or "for" statement on the same line
   as the "if" or "for" keyword.
 
 * If the body of an "if" or "for" statement fits on the same line, you can
   leave off the braces. For example, write
 
     if (x) return;
 
   instead of
 
     if (x) {
         return;
     }
 
   However, always include the braces when there is an "else" clause.
 
 * Put the "else" keyword on the same line as the preceding closing curly
   brace.
 
 * When testing pointers, don't compare them to NULL; instead test the value
   directly. For example, write
 
     if (x && !y)
 
   instead of
 
     if (x != NULL && y == NULL)