Blame STYLE.txt

Packit ea8578
In general:
Packit ea8578
For minor changes to a function, copy the existing formatting.
Packit ea8578
When changing the style, commit that separately from other changes.
Packit ea8578
For new code and major changes to a function, switch to the official json-c style.
Packit ea8578

Packit ea8578
Official json-c style:
Packit ea8578
Aim for readability, not strict conformance to fixed style rules.
Packit ea8578
These rules are not comprehensive.  Look to existing code for guidelines.
Packit ea8578
Indentation is tab based, with continuations of long lines starting with tabs then spaces for alignment.
Packit ea8578
Try to line up components of continuation lines with corresponding part of the line above (i.e. "indent -lp" effect), but avoid excessive identation tha causes extra line wraps. 
Packit ea8578
 e.g. (T=tab, S=space):
Packit ea8578
TTTTsome_long_func_call(arg1, arg2,
Packit ea8578
TTTTSSSSSSSSSSSSSSSSSSSarg3, arg4);
Packit ea8578
TTTTsome_reallly_really_long_func_name(arg1,
Packit ea8578
TTTTTarg2, arg3, arg4);
Packit ea8578
There should be a space between "if"/"while" and the following parenthesis.
Packit ea8578
"case" lines are indented at the same level as the "switch" statement.
Packit ea8578
Commas are followed by a single space.
Packit ea8578
Include spaces around most non-unary, non-postfix operators, "=", "==', "&", "||", etc...
Packit ea8578
Function calls have no space between the name and the parenthesis.
Packit ea8578
Curly braces go on their own line.
Packit ea8578
Curly braces may be omitted.
Packit ea8578

Packit ea8578
Naming:
Packit ea8578
Words within function and variable names are separated with underscores.  Avoid camel case.
Packit ea8578
Prefer longer, more descriptive names, but not excessively so.  No single letter variable names.
Packit ea8578

Packit ea8578
Other:
Packit ea8578
Variables should be defined for the smallest scope needed.
Packit ea8578
Functions should be defined static when possible.
Packit ea8578
When possible, avoid exposing internals in the public API.