mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-04 23:28:07 +02:00
CODING_STYLE: Add notes on avoiding trailing whitespace.
This commit is contained in:
parent
ef10a0403a
commit
a21a2e935d
1 changed files with 17 additions and 3 deletions
20
CODING_STYLE
20
CODING_STYLE
|
|
@ -132,7 +132,7 @@ structure definition:
|
|||
|
||||
struct _cairo_gstate {
|
||||
cairo_operator_t op;
|
||||
|
||||
|
||||
double tolerance;
|
||||
|
||||
/* stroke style */
|
||||
|
|
@ -146,19 +146,33 @@ structure definition:
|
|||
double *dash;
|
||||
int num_dashes;
|
||||
double dash_offset;
|
||||
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
Use a single space before a left parenthesis, except where the
|
||||
standard will not allow it, (eg. when defining a parameterized macro).
|
||||
|
||||
Don't eliminate whitespace just because things would still fit on one
|
||||
Don't eliminate newlines just because things would still fit on one
|
||||
line. This breaks the expected visual structure of the code making it
|
||||
much harder to read and understand:
|
||||
|
||||
if (condition) foo (); else bar (); /* Yuck! */
|
||||
|
||||
Do eliminate trailing whitespace (space or tab characters) on any
|
||||
line. Also, avoid putting intial or final blank lines into any file,
|
||||
and never use multiple blank lines instead of a single blank line.
|
||||
|
||||
Do enable the default git pre-commit hook that detect trailing
|
||||
whitespace for you and help you to avoid corrupting cairo's tree with
|
||||
it. Do that as follows:
|
||||
|
||||
chmod a+x .git/hooks/pre-commit
|
||||
|
||||
You might also find the git-stripspace utility helpful which acts as a
|
||||
filter to remove trailing whitespace as well as initial, final, and
|
||||
duplicate blank lines.
|
||||
|
||||
As a special case of the bracing and whitespace guidelines, function
|
||||
definitions should always take the following form:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue