ccache/HACKING.txt
2011-07-17 11:57:52 +02:00

60 lines
2.0 KiB
Plaintext

Hacking ccache
==============
Code formatting
---------------
* Use tabs for indenting and spaces for aligning C code. See
<http://www.emacswiki.org/emacs/SmartTabs>.
* Use 4 spaces for indenting other code (and spaces for aligning).
* Put the opening curly brace on a new line when defining a function, otherwise
at the end of the same line.
* Put no space between function name and the following parenthesis.
* Put one space between if/switch/for/while/do and opening curly brace.
* If possible, keep lines at most 80 character wide for a 2 character tab
width.
* Use only lowercase names for functions and variables.
* Use only uppercase names for enum items and (with some exceptions) macros.
* Don't use typedefs for structs and enums.
Idioms
------
* Use NULL to initialize null pointers.
* Don't use NULL when comparing pointers.
* Use format(), x_malloc() and friends instead of checking for memory
allocation failure explicitly.
* Use str_eq() instead of strcmp() when testing for string (in)equality.
* Consider using str_startswith() instead of strncmp().
* Use bool, true and false for boolean values.
* Use tmp_unlink() or x_unlink() instead of unlink().
* Use x_rename() instead of rename().
Other
-----
* Strive to minimize use of global variables.
* Write test cases for new code.
Commit messages
---------------
* Write a short description on the first line. If wanted, leave the second line
empty and write a longer description on line three and below.
* Start the short description with a capital letter. Optional: prefix the short
description with a context followed by a colon.
* The short description should be in "command form" (see examples below).
* Don't put a final period after the short description.
* Keep lines in the message at most 75 characters wide.
Example 1:
Hash a delimiter string between parts to separate them
Previously, "gcc -I-O2 -c file.c" and "gcc -I -O2 -c file.c" would hash to
the same sum.
Example 2:
win32: Add a space between filename and error string in x_fmmap()