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:
“I am so tired of taking to others
translating my life for the deaf, the blind,
the I really want to know what your life is like without giving up any of my privileges
to live it white women
the I want to live my white life with Third World womens style and keep my skin
class privileges dykes”
—Lorraine Bethel, African American lesbian feminist poet. What Chou Mean We, White Girl? Lines 49-54 (1979)