blob: c0dad9e27b48bdf8a4acf423e38a7567b230232c [file] [log] [blame]
If you are contributing code to the Subversion project, please read
this first.
We're using ANSI C, and following the GNU coding standards. Emacs
users can just load svn-dev.el to get the right indentation behavior
(most source files here will load it automatically, if
`enable-local-eval' is set appropriately).
Read http://www.gnu.org/prep/standards.html for a full description of
the GNU coding standards; but here is a short example demonstrating
the most important formatting guidelines:
char * /* func type on own line */
argblarg (char *arg1, int arg2) /* func name on own line */
{ /* first brace on own line */
if ((some_very_long_condition && arg2) /* indent 2 cols */
|| remaining_condition) /* new line before operator */
{ /* brace on own line, indent 2 */
arg1 = some_func (arg1, arg2); /* space before opening paren */
} /* close brace on own line */
else
{
do /* format do-while like this */
{
arg1 = another_func (arg1);
}
while (*arg1);
}
}
In general, be generous with parentheses even when you're sure about
the operator precedence, and be willing to add spaces and newlines to
avoid "code crunch". Don't worry too much about vertical density;
it's more important to make code readable than to fit that extra line
on the screen.
Other Conventions:
==================
In addition to the GNU standards, Subversion uses these conventions:
* Use only spaces for indenting code, never tabs. Tab display
width is not standardized enough, and anyway it's easier to
manually adjust indentation that uses spaces.
* Stay within 80 columns, the width of a minimal standard display
window.
* Signify internal variables by two underscores after the prefix.
That is, when a symbol must (for technical reasons) reside in the
global namespace despite not being part of a published interface,
then use two underscores following the module prefix. For
example:
svn_fs_get_ver_prop () /* Part of published API. */
svn_fs__parse_props () /* For internal use only. */
* Put this comment at the bottom of new source files to make Emacs
automatically load svn-dev.el:
/*
* local variables:
* eval: (load-file "svn-dev.el")
* end:
*/
(This assumes the C file is located in subversion/subversion/,
where svn-dev.el is.)