BSD KNF Style
Also known as Kernel Normal Form style, this is currently the form of most of the code used in the Berkeley Software Distribution operating systems. Although mostly intended for kernel code, it is widely used as well in userland code. It is essentially a thoroughly-documented variant of K&R style as used in the Bell Labs Version 6 & 7 UNIX source code.
The hard tabulator (ts in vi) is kept at 8 columns, while a soft tabulator is often defined as a helper as well (sw in vi), and set at 4.
The hard tabulators are used to indent code blocks, while a soft tabulator (4 spaces) of additional indent is used for all continuing lines that must be split over multiple lines.
Moreover, function calls do not use a space before the parenthesis, although C language native statements such as if
, while
, do
, switch
and return
do (in the case where return
is used with parens). Functions that declare no local variables in their top-level block should also leave an empty line after their opening block brace.
Here follow a few samples:
while (x == y) { something; somethingelse; } finalthing;if (data != NULL && res > 0) { if (JS_DefineProperty(cx, o, "data", STRING_TO_JSVAL(JS_NewStringCopyN(cx, data, res)), NULL, NULL, JSPROP_ENUMERATE) != 0) { QUEUE_EXCEPTION("Internal error!"); goto err; } PQfreemem(data); } else { if (JS_DefineProperty(cx, o, "data", OBJECT_TO_JSVAL(NULL), NULL, NULL, JSPROP_ENUMERATE) != 0) { QUEUE_EXCEPTION("Internal error!"); goto err; } }
static JSBool pgresult_constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { QUEUE_EXCEPTION("PGresult class not user-instantiable"); return (JS_FALSE); }
Read more about this topic: Indent Style
Famous quotes containing the word style:
“Hemingway was a prisoner of his style. No one can talk like the characters in Hemingway except the characters in Hemingway. His style in the wildest sense finally killed him.”
—William Burroughs (b. 1914)